| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 var successes = 0; | 894 var successes = 0; |
| 895 var completer = new Completer(); | 895 var completer = new Completer(); |
| 896 checkComplete() { | 896 checkComplete() { |
| 897 if (failures.length + successes != matches.length) return; | 897 if (failures.length + successes != matches.length) return; |
| 898 if (successes > 0) { | 898 if (successes > 0) { |
| 899 completer.complete(); | 899 completer.complete(); |
| 900 return; | 900 return; |
| 901 } | 901 } |
| 902 | 902 |
| 903 var error = new StringBuffer(); | 903 var error = new StringBuffer(); |
| 904 error.add("No files named $name in $dir were valid:\n"); | 904 error.write("No files named $name in $dir were valid:\n"); |
| 905 for (var failure in failures) { | 905 for (var failure in failures) { |
| 906 error.add(" $failure\n"); | 906 error.write(" $failure\n"); |
| 907 } | 907 } |
| 908 completer.completeError( | 908 completer.completeError( |
| 909 new TestFailure(error.toString()), stackTrace); | 909 new TestFailure(error.toString()), stackTrace); |
| 910 } | 910 } |
| 911 | 911 |
| 912 for (var match in matches) { | 912 for (var match in matches) { |
| 913 var future = validate(match).then((_) { | 913 var future = validate(match).then((_) { |
| 914 successes++; | 914 successes++; |
| 915 checkComplete(); | 915 checkComplete(); |
| 916 }).catchError((e) { | 916 }).catchError((e) { |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 /// calling [completion] is unnecessary. | 1634 /// calling [completion] is unnecessary. |
| 1635 void expectLater(Future actual, matcher, {String reason, | 1635 void expectLater(Future actual, matcher, {String reason, |
| 1636 FailureHandler failureHandler, bool verbose: false}) { | 1636 FailureHandler failureHandler, bool verbose: false}) { |
| 1637 _schedule((_) { | 1637 _schedule((_) { |
| 1638 return actual.then((value) { | 1638 return actual.then((value) { |
| 1639 expect(value, matcher, reason: reason, failureHandler: failureHandler, | 1639 expect(value, matcher, reason: reason, failureHandler: failureHandler, |
| 1640 verbose: false); | 1640 verbose: false); |
| 1641 }); | 1641 }); |
| 1642 }); | 1642 }); |
| 1643 } | 1643 } |
| OLD | NEW |