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. | 5 /// Test infrastructure for testing pub. |
6 /// | 6 /// |
7 /// Unlike typical unit tests, most pub tests are integration tests that stage | 7 /// Unlike typical unit tests, most pub tests are integration tests that stage |
8 /// some stuff on the file system, run pub, and then validate the results. This | 8 /// some stuff on the file system, run pub, and then validate the results. This |
9 /// library provides an API to build tests like that. | 9 /// library provides an API to build tests like that. |
10 library test_pub; | 10 library test_pub; |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 /// | 707 /// |
708 /// [sandbox] is a list of path dependencies to be found in the sandbox | 708 /// [sandbox] is a list of path dependencies to be found in the sandbox |
709 /// directory. [pkg] is a list of packages in the Dart repo's "pkg" directory; | 709 /// directory. [pkg] is a list of packages in the Dart repo's "pkg" directory; |
710 /// each package listed here and all its dependencies will be linked to the | 710 /// each package listed here and all its dependencies will be linked to the |
711 /// version in the Dart repo. | 711 /// version in the Dart repo. |
712 /// | 712 /// |
713 /// [hosted] is a list of package names to version strings for dependencies on | 713 /// [hosted] is a list of package names to version strings for dependencies on |
714 /// hosted packages. | 714 /// hosted packages. |
715 void createLockFile(String package, {Iterable<String> sandbox, | 715 void createLockFile(String package, {Iterable<String> sandbox, |
716 Iterable<String> pkg, Map<String, String> hosted}) { | 716 Iterable<String> pkg, Map<String, String> hosted}) { |
717 var cache = new SystemCache.withSources( | 717 schedule(() async { |
718 rootDir: p.join(sandboxDir, cachePath)); | 718 var cache = new SystemCache.withSources( |
| 719 rootDir: p.join(sandboxDir, cachePath)); |
719 | 720 |
720 var lockFile = _createLockFile(cache.sources, | 721 var lockFile = _createLockFile(cache.sources, |
721 sandbox: sandbox, pkg: pkg, hosted: hosted); | 722 sandbox: sandbox, pkg: pkg, hosted: hosted); |
722 | 723 |
723 d.dir(package, [ | 724 await d.dir(package, [ |
724 d.file('pubspec.lock', lockFile.serialize(null)), | 725 d.file('pubspec.lock', lockFile.serialize(null)), |
725 d.file('.packages', lockFile.packagesFile(package)) | 726 d.file('.packages', lockFile.packagesFile(package)) |
726 ]).create(); | 727 ]).create(); |
| 728 }, "creating lockfile for $package"); |
| 729 } |
| 730 |
| 731 /// Like [createLockFile], but creates only a `.packages` file without a |
| 732 /// lockfile. |
| 733 void createPackagesFile(String package, {Iterable<String> sandbox, |
| 734 Iterable<String> pkg, Map<String, String> hosted}) { |
| 735 schedule(() async { |
| 736 var cache = new SystemCache.withSources( |
| 737 rootDir: p.join(sandboxDir, cachePath)); |
| 738 |
| 739 var lockFile = _createLockFile(cache.sources, |
| 740 sandbox: sandbox, pkg: pkg, hosted: hosted); |
| 741 |
| 742 await d.dir(package, [ |
| 743 d.file('.packages', lockFile.packagesFile(package)) |
| 744 ]).create(); |
| 745 }, "creating .packages for $package"); |
727 } | 746 } |
728 | 747 |
729 /// Creates a lock file for [package] without running `pub get`. | 748 /// Creates a lock file for [package] without running `pub get`. |
730 /// | 749 /// |
731 /// [sandbox] is a list of path dependencies to be found in the sandbox | 750 /// [sandbox] is a list of path dependencies to be found in the sandbox |
732 /// directory. [pkg] is a list of packages in the Dart repo's "pkg" directory; | 751 /// directory. [pkg] is a list of packages in the Dart repo's "pkg" directory; |
733 /// each package listed here and all its dependencies will be linked to the | 752 /// each package listed here and all its dependencies will be linked to the |
734 /// version in the Dart repo. | 753 /// version in the Dart repo. |
735 /// | 754 /// |
736 /// [hosted] is a list of package names to version strings for dependencies on | 755 /// [hosted] is a list of package names to version strings for dependencies on |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 _lastMatcher.matches(item.last, matchState); | 1020 _lastMatcher.matches(item.last, matchState); |
1002 } | 1021 } |
1003 | 1022 |
1004 Description describe(Description description) { | 1023 Description describe(Description description) { |
1005 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 1024 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
1006 } | 1025 } |
1007 } | 1026 } |
1008 | 1027 |
1009 /// A [StreamMatcher] that matches multiple lines of output. | 1028 /// A [StreamMatcher] that matches multiple lines of output. |
1010 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); | 1029 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); |
OLD | NEW |