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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 | 927 |
928 /// Schedules a single [Validator] to run on the [appPath]. | 928 /// Schedules a single [Validator] to run on the [appPath]. |
929 /// | 929 /// |
930 /// Returns a scheduled Future that contains the errors and warnings produced | 930 /// Returns a scheduled Future that contains the errors and warnings produced |
931 /// by that validator. | 931 /// by that validator. |
932 Future<Pair<List<String>, List<String>>> schedulePackageValidation( | 932 Future<Pair<List<String>, List<String>>> schedulePackageValidation( |
933 ValidatorCreator fn) { | 933 ValidatorCreator fn) { |
934 return schedule(() { | 934 return schedule(() { |
935 var cache = new SystemCache.withSources(p.join(sandboxDir, cachePath)); | 935 var cache = new SystemCache.withSources(p.join(sandboxDir, cachePath)); |
936 | 936 |
937 return syncFuture(() { | 937 return new Future.sync(() { |
938 var validator = fn(new Entrypoint(p.join(sandboxDir, appPath), cache)); | 938 var validator = fn(new Entrypoint(p.join(sandboxDir, appPath), cache)); |
939 return validator.validate().then((_) { | 939 return validator.validate().then((_) { |
940 return new Pair(validator.errors, validator.warnings); | 940 return new Pair(validator.errors, validator.warnings); |
941 }); | 941 }); |
942 }); | 942 }); |
943 }, "validating package"); | 943 }, "validating package"); |
944 } | 944 } |
945 | 945 |
946 /// A matcher that matches a Pair. | 946 /// A matcher that matches a Pair. |
947 Matcher pairOf(Matcher firstMatcher, Matcher lastMatcher) => | 947 Matcher pairOf(Matcher firstMatcher, Matcher lastMatcher) => |
(...skipping 11 matching lines...) Expand all Loading... |
959 _lastMatcher.matches(item.last, matchState); | 959 _lastMatcher.matches(item.last, matchState); |
960 } | 960 } |
961 | 961 |
962 Description describe(Description description) { | 962 Description describe(Description description) { |
963 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 963 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
964 } | 964 } |
965 } | 965 } |
966 | 966 |
967 /// A [StreamMatcher] that matches multiple lines of output. | 967 /// A [StreamMatcher] that matches multiple lines of output. |
968 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); | 968 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); |
OLD | NEW |