| 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 |
| 11 import 'src/backend/declarer.dart'; | 11 import 'src/backend/declarer.dart'; |
| 12 import 'src/backend/suite.dart'; | 12 import 'src/backend/suite.dart'; |
| 13 import 'src/backend/test_platform.dart'; | 13 import 'src/backend/test_platform.dart'; |
| 14 import 'src/frontend/timeout.dart'; | 14 import 'src/frontend/timeout.dart'; |
| 15 import 'src/runner/engine.dart'; |
| 15 import 'src/runner/reporter/expanded.dart'; | 16 import 'src/runner/reporter/expanded.dart'; |
| 16 import 'src/utils.dart'; | 17 import 'src/utils.dart'; |
| 17 | 18 |
| 18 export 'package:matcher/matcher.dart'; | 19 export 'package:matcher/matcher.dart'; |
| 19 | 20 |
| 20 export 'src/frontend/expect.dart'; | 21 export 'src/frontend/expect.dart'; |
| 21 export 'src/frontend/expect_async.dart'; | 22 export 'src/frontend/expect_async.dart'; |
| 22 export 'src/frontend/future_matchers.dart'; | 23 export 'src/frontend/future_matchers.dart'; |
| 23 export 'src/frontend/on_platform.dart'; | 24 export 'src/frontend/on_platform.dart'; |
| 24 export 'src/frontend/prints_matcher.dart'; | 25 export 'src/frontend/prints_matcher.dart'; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 48 // [_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 |
| 49 // finished being defined. | 50 // finished being defined. |
| 50 _globalDeclarer = new Declarer(); | 51 _globalDeclarer = new Declarer(); |
| 51 scheduleMicrotask(() async { | 52 scheduleMicrotask(() async { |
| 52 var suite = | 53 var suite = |
| 53 new Suite(_globalDeclarer.tests, | 54 new Suite(_globalDeclarer.tests, |
| 54 path: p.prettyUri(Uri.base), | 55 path: p.prettyUri(Uri.base), |
| 55 platform: "VM") | 56 platform: "VM") |
| 56 .forPlatform(TestPlatform.vm, os: currentOSGuess); | 57 .forPlatform(TestPlatform.vm, os: currentOSGuess); |
| 57 | 58 |
| 58 var success = await new ExpandedReporter([suite], color: true).run(); | 59 var engine = new Engine(); |
| 60 engine.suiteSink.add(suite); |
| 61 engine.suiteSink.close(); |
| 62 ExpandedReporter.watch(engine, |
| 63 color: true, printPath: false, printPlatform: false); |
| 64 |
| 65 var success = await engine.run(); |
| 59 // TODO(nweiz): Set the exit code on the VM when issue 6943 is fixed. | 66 // TODO(nweiz): Set the exit code on the VM when issue 6943 is fixed. |
| 60 // TODO(nweiz): Just "return;" when issue 23200 is fixed. | 67 if (success) return; |
| 61 if (success) return null; | |
| 62 print(''); | 68 print(''); |
| 63 new Future.error("Dummy exception to set exit code."); | 69 new Future.error("Dummy exception to set exit code."); |
| 64 }); | 70 }); |
| 65 return _globalDeclarer; | 71 return _globalDeclarer; |
| 66 } | 72 } |
| 67 | 73 |
| 68 // TODO(nweiz): This and other top-level functions should throw exceptions if | 74 // TODO(nweiz): This and other top-level functions should throw exceptions if |
| 69 // they're called after the declarer has finished declaring. | 75 // they're called after the declarer has finished declaring. |
| 70 /// Creates a new test case with the given description and body. | 76 /// Creates a new test case with the given description and body. |
| 71 /// | 77 /// |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 /// group. [callback] will be run before any tear-down callbacks in parent | 176 /// group. [callback] will be run before any tear-down callbacks in parent |
| 171 /// groups or at the top level. | 177 /// groups or at the top level. |
| 172 void tearDown(callback()) => _declarer.tearDown(callback); | 178 void tearDown(callback()) => _declarer.tearDown(callback); |
| 173 | 179 |
| 174 /// Registers an exception that was caught for the current test. | 180 /// Registers an exception that was caught for the current test. |
| 175 void registerException(error, [StackTrace stackTrace]) { | 181 void registerException(error, [StackTrace stackTrace]) { |
| 176 // This will usually forward directly to [Invoker.current.handleError], but | 182 // This will usually forward directly to [Invoker.current.handleError], but |
| 177 // going through the zone API allows other zones to consistently see errors. | 183 // going through the zone API allows other zones to consistently see errors. |
| 178 Zone.current.handleUncaughtError(error, stackTrace); | 184 Zone.current.handleUncaughtError(error, stackTrace); |
| 179 } | 185 } |
| OLD | NEW |