OLD | NEW |
1 library test_pub; | 1 library test_pub; |
2 import 'dart:async'; | 2 import 'dart:async'; |
3 import 'dart:convert'; | 3 import 'dart:convert'; |
4 import 'dart:io'; | 4 import 'dart:io'; |
5 import 'dart:math'; | 5 import 'dart:math'; |
6 import 'package:http/testing.dart'; | 6 import 'package:http/testing.dart'; |
7 import 'package:path/path.dart' as p; | 7 import 'package:path/path.dart' as p; |
8 import 'package:scheduled_test/scheduled_process.dart'; | 8 import 'package:scheduled_test/scheduled_process.dart'; |
9 import 'package:scheduled_test/scheduled_server.dart'; | 9 import 'package:scheduled_test/scheduled_server.dart'; |
10 import 'package:scheduled_test/scheduled_stream.dart'; | 10 import 'package:scheduled_test/scheduled_stream.dart'; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 pub.stdout.expect(startsWith('Publishing test_pkg 1.0.0 to ')); | 276 pub.stdout.expect(startsWith('Publishing test_pkg 1.0.0 to ')); |
277 pub.stdout.expect( | 277 pub.stdout.expect( |
278 emitsLines( | 278 emitsLines( |
279 "|-- LICENSE\n" "|-- lib\n" "| '-- test_pkg.dart\n" "'-- pubspec.yam
l\n" "\n" | 279 "|-- LICENSE\n" "|-- lib\n" "| '-- test_pkg.dart\n" "'-- pubspec.yam
l\n" "\n" |
280 "Looks great! Are you ready to upload your package (y/n)?")); | 280 "Looks great! Are you ready to upload your package (y/n)?")); |
281 pub.writeLine("y"); | 281 pub.writeLine("y"); |
282 } | 282 } |
283 String _pathInSandbox(String relPath) { | 283 String _pathInSandbox(String relPath) { |
284 return p.join(p.absolute(sandboxDir), relPath); | 284 return p.join(p.absolute(sandboxDir), relPath); |
285 } | 285 } |
286 Map getPubTestEnvironment([Uri tokenEndpoint]) { | 286 Map getPubTestEnvironment([String tokenEndpoint]) { |
287 var environment = {}; | 287 var environment = {}; |
288 environment['_PUB_TESTING'] = 'true'; | 288 environment['_PUB_TESTING'] = 'true'; |
289 environment['PUB_CACHE'] = _pathInSandbox(cachePath); | 289 environment['PUB_CACHE'] = _pathInSandbox(cachePath); |
290 environment['_PUB_TEST_SDK_VERSION'] = "0.1.2+3"; | 290 environment['_PUB_TEST_SDK_VERSION'] = "0.1.2+3"; |
291 if (tokenEndpoint != null) { | 291 if (tokenEndpoint != null) { |
292 environment['_PUB_TEST_TOKEN_ENDPOINT'] = tokenEndpoint.toString(); | 292 environment['_PUB_TEST_TOKEN_ENDPOINT'] = tokenEndpoint.toString(); |
293 } | 293 } |
294 return environment; | 294 return environment; |
295 } | 295 } |
296 ScheduledProcess startPub({List args, Future<Uri> tokenEndpoint}) { | 296 ScheduledProcess startPub({List args, Future<String> tokenEndpoint}) { |
297 ensureDir(_pathInSandbox(appPath)); | 297 ensureDir(_pathInSandbox(appPath)); |
298 var dartBin = Platform.executable; | 298 var dartBin = Platform.executable; |
299 if (dartBin.contains(Platform.pathSeparator)) { | 299 if (dartBin.contains(Platform.pathSeparator)) { |
300 dartBin = p.absolute(dartBin); | 300 dartBin = p.absolute(dartBin); |
301 } | 301 } |
302 var pubPath = p.join(p.dirname(dartBin), 'snapshots/pub.dart.snapshot'); | 302 var pubPath = p.join(p.dirname(dartBin), 'snapshots/pub.dart.snapshot'); |
303 var dartArgs = [pubPath, '--verbose']; | 303 var dartArgs = [pubPath, '--verbose']; |
304 dartArgs.addAll(args); | 304 dartArgs.addAll(args); |
305 if (tokenEndpoint == null) tokenEndpoint = new Future.value(); | 305 if (tokenEndpoint == null) tokenEndpoint = new Future.value(); |
306 var environmentFuture = tokenEndpoint.then((tokenEndpoint) { | 306 var environmentFuture = tokenEndpoint.then((tokenEndpoint) { |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 bool matches(item, Map matchState) { | 600 bool matches(item, Map matchState) { |
601 if (item is! Pair) return false; | 601 if (item is! Pair) return false; |
602 return _firstMatcher.matches(item.first, matchState) && | 602 return _firstMatcher.matches(item.first, matchState) && |
603 _lastMatcher.matches(item.last, matchState); | 603 _lastMatcher.matches(item.last, matchState); |
604 } | 604 } |
605 Description describe(Description description) { | 605 Description describe(Description description) { |
606 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 606 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
607 } | 607 } |
608 } | 608 } |
609 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); | 609 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); |
OLD | NEW |