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 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 withTempDir((tempDir) { | 1166 withTempDir((tempDir) { |
1167 return create(tempDir).then((tar) { | 1167 return create(tempDir).then((tar) { |
1168 var sourceStream = new File(tar).openRead(); | 1168 var sourceStream = new File(tar).openRead(); |
1169 return store(sourceStream, controller); | 1169 return store(sourceStream, controller); |
1170 }); | 1170 }); |
1171 }); | 1171 }); |
1172 return new ByteStream(controller.stream); | 1172 return new ByteStream(controller.stream); |
1173 } | 1173 } |
1174 } | 1174 } |
1175 | 1175 |
1176 /// A descriptor that validates that no file exists with the given name. | 1176 /// A descriptor that validates that no file or directory exists with the given |
| 1177 /// name. |
1177 class NothingDescriptor extends Descriptor { | 1178 class NothingDescriptor extends Descriptor { |
1178 NothingDescriptor(String name) : super(name); | 1179 NothingDescriptor(String name) : super(name); |
1179 | 1180 |
1180 Future create(dir) => new Future.immediate(null); | 1181 Future create(dir) => new Future.immediate(null); |
1181 Future delete(dir) => new Future.immediate(null); | 1182 Future delete(dir) => new Future.immediate(null); |
1182 | 1183 |
1183 Future validate(String dir) { | 1184 Future validate(String dir) { |
1184 return defer(() { | 1185 return defer(() { |
1185 if (entryExists(path.join(dir, name))) { | 1186 if (entryExists(path.join(dir, name))) { |
1186 throw new TestFailure('File $name in $dir should not exist.'); | 1187 throw new TestFailure('Entry $name in $dir should not exist.'); |
1187 } | 1188 } |
1188 }); | 1189 }); |
1189 } | 1190 } |
1190 | 1191 |
1191 ByteStream load(List<String> path) { | 1192 ByteStream load(List<String> path) { |
1192 if (path.isEmpty) { | 1193 if (path.isEmpty) { |
1193 throw "Can't load the contents of $name: it doesn't exist."; | 1194 throw "Can't load the contents of $name: it doesn't exist."; |
1194 } else { | 1195 } else { |
1195 throw "Can't load ${path.join('/')} from within $name: $name doesn't " | 1196 throw "Can't load ${path.join('/')} from within $name: $name doesn't " |
1196 "exist."; | 1197 "exist."; |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 /// calling [completion] is unnecessary. | 1634 /// calling [completion] is unnecessary. |
1634 void expectLater(Future actual, matcher, {String reason, | 1635 void expectLater(Future actual, matcher, {String reason, |
1635 FailureHandler failureHandler, bool verbose: false}) { | 1636 FailureHandler failureHandler, bool verbose: false}) { |
1636 _schedule((_) { | 1637 _schedule((_) { |
1637 return actual.then((value) { | 1638 return actual.then((value) { |
1638 expect(value, matcher, reason: reason, failureHandler: failureHandler, | 1639 expect(value, matcher, reason: reason, failureHandler: failureHandler, |
1639 verbose: false); | 1640 verbose: false); |
1640 }); | 1641 }); |
1641 }); | 1642 }); |
1642 } | 1643 } |
OLD | NEW |