OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub | 5 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub |
6 /// tests are integration tests that stage some stuff on the file system, run | 6 /// tests are integration tests that stage some stuff on the file system, run |
7 /// pub, and then validate the results. This library provides an API to build | 7 /// pub, and then validate the results. This library provides an API to build |
8 /// tests like that. | 8 /// tests like that. |
9 library test_pub; | 9 library test_pub; |
10 | 10 |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 /// Any futures in [args] will be resolved before the process is started. | 429 /// Any futures in [args] will be resolved before the process is started. |
430 ScheduledProcess startPub({List args, Future<Uri> tokenEndpoint}) { | 430 ScheduledProcess startPub({List args, Future<Uri> tokenEndpoint}) { |
431 String pathInSandbox(String relPath) { | 431 String pathInSandbox(String relPath) { |
432 return path.join(path.absolute(sandboxDir), relPath); | 432 return path.join(path.absolute(sandboxDir), relPath); |
433 } | 433 } |
434 | 434 |
435 ensureDir(pathInSandbox(appPath)); | 435 ensureDir(pathInSandbox(appPath)); |
436 | 436 |
437 // Find a Dart executable we can use to spawn. Use the same one that was | 437 // Find a Dart executable we can use to spawn. Use the same one that was |
438 // used to run this script itself. | 438 // used to run this script itself. |
439 var dartBin = new Options().executable; | 439 var dartBin = Platform.executable; |
440 | 440 |
441 // If the executable looks like a path, get its full path. That way we | 441 // If the executable looks like a path, get its full path. That way we |
442 // can still find it when we spawn it with a different working directory. | 442 // can still find it when we spawn it with a different working directory. |
443 if (dartBin.contains(Platform.pathSeparator)) { | 443 if (dartBin.contains(Platform.pathSeparator)) { |
444 dartBin = path.absolute(dartBin); | 444 dartBin = path.absolute(dartBin); |
445 } | 445 } |
446 | 446 |
447 // Find the main pub entrypoint. | 447 // Find the main pub entrypoint. |
448 var pubPath = path.join(testDirectory, '..', 'bin', 'pub.dart'); | 448 var pubPath = path.join(testDirectory, '..', 'bin', 'pub.dart'); |
449 | 449 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 _stderr = pair.first; | 549 _stderr = pair.first; |
550 return pair.last; | 550 return pair.last; |
551 } | 551 } |
552 } | 552 } |
553 | 553 |
554 // TODO(nweiz): use the built-in mechanism for accessing this once it exists | 554 // TODO(nweiz): use the built-in mechanism for accessing this once it exists |
555 // (issue 9119). | 555 // (issue 9119). |
556 /// The path to the `packages` directory from which pub loads its dependencies. | 556 /// The path to the `packages` directory from which pub loads its dependencies. |
557 String get _packageRoot { | 557 String get _packageRoot { |
558 return path.absolute(path.join( | 558 return path.absolute(path.join( |
559 path.dirname(new Options().executable), '..', '..', 'packages')); | 559 path.dirname(Platform.executable), '..', '..', 'packages')); |
560 } | 560 } |
561 | 561 |
562 /// Skips the current test if Git is not installed. This validates that the | 562 /// Skips the current test if Git is not installed. This validates that the |
563 /// current test is running on a buildbot in which case we expect git to be | 563 /// current test is running on a buildbot in which case we expect git to be |
564 /// installed. If we are not running on the buildbot, we will instead see if | 564 /// installed. If we are not running on the buildbot, we will instead see if |
565 /// git is installed and skip the test if not. This way, users don't need to | 565 /// git is installed and skip the test if not. This way, users don't need to |
566 /// have git installed to run the tests locally (unless they actually care | 566 /// have git installed to run the tests locally (unless they actually care |
567 /// about the pub git tests). | 567 /// about the pub git tests). |
568 /// | 568 /// |
569 /// This will also increase the [Schedule] timeout to 30 seconds on Windows, | 569 /// This will also increase the [Schedule] timeout to 30 seconds on Windows, |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 bool matches(item, Map matchState) { | 795 bool matches(item, Map matchState) { |
796 if (item is! Pair) return false; | 796 if (item is! Pair) return false; |
797 return _firstMatcher.matches(item.first, matchState) && | 797 return _firstMatcher.matches(item.first, matchState) && |
798 _lastMatcher.matches(item.last, matchState); | 798 _lastMatcher.matches(item.last, matchState); |
799 } | 799 } |
800 | 800 |
801 Description describe(Description description) { | 801 Description describe(Description description) { |
802 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 802 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
803 } | 803 } |
804 } | 804 } |
OLD | NEW |