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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 "homepage": "http://pub.dartlang.org", | 802 "homepage": "http://pub.dartlang.org", |
803 "description": "A package, I guess." | 803 "description": "A package, I guess." |
804 }; | 804 }; |
805 | 805 |
806 if (dependencies != null) package["dependencies"] = dependencies; | 806 if (dependencies != null) package["dependencies"] = dependencies; |
807 | 807 |
808 return package; | 808 return package; |
809 } | 809 } |
810 | 810 |
811 /// Resolves [target] relative to the path to pub's `test/asset` directory. | 811 /// Resolves [target] relative to the path to pub's `test/asset` directory. |
812 String testAssetPath(String target) { | 812 String testAssetPath(String target) => |
813 var libPath = libraryPath('test_pub'); | 813 p.join(p.dirname(libraryPath('test_pub')), 'asset', target); |
814 | |
815 // We are running from the generated directory, but non-dart assets are only | |
816 // in the canonical directory. | |
817 // TODO(rnystrom): Remove this when #104 is fixed. | |
818 libPath = libPath.replaceAll('pub_generated', 'pub'); | |
819 | |
820 return p.join(p.dirname(libPath), 'asset', target); | |
821 } | |
822 | 814 |
823 /// Returns a Map in the format used by the pub.dartlang.org API to represent a | 815 /// Returns a Map in the format used by the pub.dartlang.org API to represent a |
824 /// package version. | 816 /// package version. |
825 /// | 817 /// |
826 /// [pubspec] is the parsed pubspec of the package version. If [full] is true, | 818 /// [pubspec] is the parsed pubspec of the package version. If [full] is true, |
827 /// this returns the complete map, including metadata that's only included when | 819 /// this returns the complete map, including metadata that's only included when |
828 /// requesting the package version directly. | 820 /// requesting the package version directly. |
829 Map packageVersionApiMap(Map pubspec, {bool full: false}) { | 821 Map packageVersionApiMap(Map pubspec, {bool full: false}) { |
830 var name = pubspec['name']; | 822 var name = pubspec['name']; |
831 var version = pubspec['version']; | 823 var version = pubspec['version']; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 _lastMatcher.matches(item.last, matchState); | 972 _lastMatcher.matches(item.last, matchState); |
981 } | 973 } |
982 | 974 |
983 Description describe(Description description) { | 975 Description describe(Description description) { |
984 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 976 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
985 } | 977 } |
986 } | 978 } |
987 | 979 |
988 /// A [StreamMatcher] that matches multiple lines of output. | 980 /// A [StreamMatcher] that matches multiple lines of output. |
989 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); | 981 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); |
OLD | NEW |