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/test_platform.dart'; | 12 import 'src/backend/test_platform.dart'; |
13 import 'src/frontend/timeout.dart'; | 13 import 'src/frontend/timeout.dart'; |
14 import 'src/runner/engine.dart'; | 14 import 'src/runner/engine.dart'; |
15 import 'src/runner/reporter/expanded.dart'; | 15 import 'src/runner/reporter/expanded.dart'; |
16 import 'src/runner/runner_suite.dart'; | 16 import 'src/runner/runner_suite.dart'; |
| 17 import 'src/runner/vm/environment.dart'; |
17 import 'src/utils.dart'; | 18 import 'src/utils.dart'; |
18 | 19 |
19 export 'package:matcher/matcher.dart'; | 20 export 'package:matcher/matcher.dart'; |
20 | 21 |
21 export 'src/frontend/expect.dart'; | 22 export 'src/frontend/expect.dart'; |
22 export 'src/frontend/expect_async.dart'; | 23 export 'src/frontend/expect_async.dart'; |
23 export 'src/frontend/future_matchers.dart'; | 24 export 'src/frontend/future_matchers.dart'; |
24 export 'src/frontend/on_platform.dart'; | 25 export 'src/frontend/on_platform.dart'; |
25 export 'src/frontend/prints_matcher.dart'; | 26 export 'src/frontend/prints_matcher.dart'; |
26 export 'src/frontend/skip.dart'; | 27 export 'src/frontend/skip.dart'; |
(...skipping 17 matching lines...) Expand all Loading... |
44 if (declarer != null) return declarer; | 45 if (declarer != null) return declarer; |
45 if (_globalDeclarer != null) return _globalDeclarer; | 46 if (_globalDeclarer != null) return _globalDeclarer; |
46 | 47 |
47 // Since there's no Zone-scoped declarer, the test file is being run directly. | 48 // Since there's no Zone-scoped declarer, the test file is being run directly. |
48 // In order to run the tests, we set up our own Declarer via | 49 // 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 | 50 // [_globalDeclarer], and schedule a microtask to run the tests once they're |
50 // finished being defined. | 51 // finished being defined. |
51 _globalDeclarer = new Declarer(); | 52 _globalDeclarer = new Declarer(); |
52 scheduleMicrotask(() async { | 53 scheduleMicrotask(() async { |
53 var suite = new RunnerSuite( | 54 var suite = new RunnerSuite( |
| 55 // TODO(nweiz): Use a different environment if VM environment starts |
| 56 // import dart:io before cross-platform libraries exist. |
| 57 const VMEnvironment(), |
54 _globalDeclarer.tests, | 58 _globalDeclarer.tests, |
55 path: p.prettyUri(Uri.base), | 59 path: p.prettyUri(Uri.base), |
56 platform: TestPlatform.vm, | 60 platform: TestPlatform.vm, |
57 os: currentOSGuess); | 61 os: currentOSGuess); |
58 | 62 |
59 var engine = new Engine(); | 63 var engine = new Engine(); |
60 engine.suiteSink.add(suite); | 64 engine.suiteSink.add(suite); |
61 engine.suiteSink.close(); | 65 engine.suiteSink.close(); |
62 ExpandedReporter.watch(engine, | 66 ExpandedReporter.watch(engine, |
63 color: true, printPath: false, printPlatform: false); | 67 color: true, printPath: false, printPlatform: false); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 /// group. [callback] will be run before any tear-down callbacks in parent | 180 /// group. [callback] will be run before any tear-down callbacks in parent |
177 /// groups or at the top level. | 181 /// groups or at the top level. |
178 void tearDown(callback()) => _declarer.tearDown(callback); | 182 void tearDown(callback()) => _declarer.tearDown(callback); |
179 | 183 |
180 /// Registers an exception that was caught for the current test. | 184 /// Registers an exception that was caught for the current test. |
181 void registerException(error, [StackTrace stackTrace]) { | 185 void registerException(error, [StackTrace stackTrace]) { |
182 // This will usually forward directly to [Invoker.current.handleError], but | 186 // This will usually forward directly to [Invoker.current.handleError], but |
183 // going through the zone API allows other zones to consistently see errors. | 187 // going through the zone API allows other zones to consistently see errors. |
184 Zone.current.handleUncaughtError(error, stackTrace); | 188 Zone.current.handleUncaughtError(error, stackTrace); |
185 } | 189 } |
OLD | NEW |