| 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 library test; | 5 library test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // In order to run the tests, we set up our own Declarer via | 48 // In order to run the tests, we set up our own Declarer via |
| 49 // [_globalDeclarer], and schedule a microtask to run the tests once they're | 49 // [_globalDeclarer], and schedule a microtask to run the tests once they're |
| 50 // finished being defined. | 50 // finished being defined. |
| 51 _globalDeclarer = new Declarer(); | 51 _globalDeclarer = new Declarer(); |
| 52 scheduleMicrotask(() { | 52 scheduleMicrotask(() { |
| 53 var suite = | 53 var suite = |
| 54 new Suite(_globalDeclarer.tests, | 54 new Suite(_globalDeclarer.tests, |
| 55 path: p.prettyUri(Uri.base), | 55 path: p.prettyUri(Uri.base), |
| 56 platform: "VM") | 56 platform: "VM") |
| 57 .forPlatform(TestPlatform.vm, os: currentOSGuess); | 57 .forPlatform(TestPlatform.vm, os: currentOSGuess); |
| 58 // TODO(nweiz): Set the exit code on the VM when issue 6943 is fixed. | 58 |
| 59 new NoIoCompactReporter([suite], color: true).run(); | 59 new NoIoCompactReporter([suite], color: true).run().then((success) { |
| 60 // TODO(nweiz): Set the exit code on the VM when issue 6943 is fixed. |
| 61 if (success) return; |
| 62 print(''); |
| 63 new Future.error("Dummy exception to set exit code."); |
| 64 }); |
| 60 }); | 65 }); |
| 61 return _globalDeclarer; | 66 return _globalDeclarer; |
| 62 } | 67 } |
| 63 | 68 |
| 64 // TODO(nweiz): This and other top-level functions should throw exceptions if | 69 // TODO(nweiz): This and other top-level functions should throw exceptions if |
| 65 // they're called after the declarer has finished declaring. | 70 // they're called after the declarer has finished declaring. |
| 66 /// Creates a new test case with the given description and body. | 71 /// Creates a new test case with the given description and body. |
| 67 /// | 72 /// |
| 68 /// The description will be added to the descriptions of any surrounding | 73 /// The description will be added to the descriptions of any surrounding |
| 69 /// [group]s. If [testOn] is passed, it's parsed as a [platform selector][]; the | 74 /// [group]s. If [testOn] is passed, it's parsed as a [platform selector][]; the |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 174 |
| 170 /// Handle an error that occurs outside of any test. | 175 /// Handle an error that occurs outside of any test. |
| 171 void handleExternalError(error, String message, [stackTrace]) { | 176 void handleExternalError(error, String message, [stackTrace]) { |
| 172 // TODO(nweiz): handle this better. | 177 // TODO(nweiz): handle this better. |
| 173 registerException(error, stackTrace); | 178 registerException(error, stackTrace); |
| 174 } | 179 } |
| 175 | 180 |
| 176 /// Registers an exception that was caught for the current test. | 181 /// Registers an exception that was caught for the current test. |
| 177 void registerException(error, [StackTrace stackTrace]) => | 182 void registerException(error, [StackTrace stackTrace]) => |
| 178 Invoker.current.handleError(error, stackTrace); | 183 Invoker.current.handleError(error, stackTrace); |
| OLD | NEW |