OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.runner.loader; | 5 library test.runner.loader; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 | 10 |
11 import 'package:analyzer/analyzer.dart'; | 11 import 'package:analyzer/analyzer.dart'; |
12 import 'package:async/async.dart'; | 12 import 'package:async/async.dart'; |
13 import 'package:path/path.dart' as p; | 13 import 'package:path/path.dart' as p; |
14 import 'package:stack_trace/stack_trace.dart'; | 14 import 'package:stack_trace/stack_trace.dart'; |
15 | 15 |
16 import '../backend/invoker.dart'; | 16 import '../backend/invoker.dart'; |
17 import '../backend/metadata.dart'; | 17 import '../backend/metadata.dart'; |
18 import '../backend/test_platform.dart'; | 18 import '../backend/test_platform.dart'; |
19 import '../util/dart.dart' as dart; | 19 import '../util/dart.dart' as dart; |
20 import '../util/io.dart'; | 20 import '../util/io.dart'; |
21 import '../util/remote_exception.dart'; | 21 import '../util/remote_exception.dart'; |
22 import '../utils.dart'; | 22 import '../utils.dart'; |
| 23 import 'browser/server.dart'; |
23 import 'configuration.dart'; | 24 import 'configuration.dart'; |
24 import 'browser/server.dart'; | 25 import 'hack_load_vm_file_hook.dart'; |
25 import 'load_exception.dart'; | 26 import 'load_exception.dart'; |
26 import 'load_suite.dart'; | 27 import 'load_suite.dart'; |
27 import 'parse_metadata.dart'; | 28 import 'parse_metadata.dart'; |
28 import 'runner_suite.dart'; | 29 import 'runner_suite.dart'; |
29 import 'vm/environment.dart'; | 30 import 'vm/environment.dart'; |
30 import 'vm/isolate_test.dart'; | 31 import 'vm/isolate_test.dart'; |
31 | 32 |
32 /// A class for finding test files and loading them into a runnable form. | 33 /// A class for finding test files and loading them into a runnable form. |
33 class Loader { | 34 class Loader { |
34 /// The test runner configuration. | 35 /// The test runner configuration. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 /// | 138 /// |
138 /// [metadata] is the suite-level metadata for the test. | 139 /// [metadata] is the suite-level metadata for the test. |
139 Future<RunnerSuite> _loadBrowserFile(String path, TestPlatform platform, | 140 Future<RunnerSuite> _loadBrowserFile(String path, TestPlatform platform, |
140 Metadata metadata) async => | 141 Metadata metadata) async => |
141 (await _browserServer).loadSuite(path, platform, metadata); | 142 (await _browserServer).loadSuite(path, platform, metadata); |
142 | 143 |
143 /// Load the test suite at [path] in VM isolate. | 144 /// Load the test suite at [path] in VM isolate. |
144 /// | 145 /// |
145 /// [metadata] is the suite-level metadata for the test. | 146 /// [metadata] is the suite-level metadata for the test. |
146 Future<RunnerSuite> _loadVmFile(String path, Metadata metadata) async { | 147 Future<RunnerSuite> _loadVmFile(String path, Metadata metadata) async { |
| 148 if (loadVMFileHook != null) { |
| 149 var suite = await loadVMFileHook(path, metadata, _config); |
| 150 _suites.add(suite); |
| 151 return suite; |
| 152 } |
| 153 |
147 var receivePort = new ReceivePort(); | 154 var receivePort = new ReceivePort(); |
148 | 155 |
149 var isolate; | 156 var isolate; |
150 try { | 157 try { |
151 if (_config.pubServeUrl != null) { | 158 if (_config.pubServeUrl != null) { |
152 var url = _config.pubServeUrl.resolveUri( | 159 var url = _config.pubServeUrl.resolveUri( |
153 p.toUri(p.relative(path, from: 'test') + '.vm_test.dart')); | 160 p.toUri(p.relative(path, from: 'test') + '.vm_test.dart')); |
154 | 161 |
155 try { | 162 try { |
156 isolate = await Isolate.spawnUri(url, [], { | 163 isolate = await Isolate.spawnUri(url, [], { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 Future close() { | 245 Future close() { |
239 return _closeMemo.runOnce(() async { | 246 return _closeMemo.runOnce(() async { |
240 await Future.wait(_suites.map((suite) => suite.close())); | 247 await Future.wait(_suites.map((suite) => suite.close())); |
241 _suites.clear(); | 248 _suites.clear(); |
242 | 249 |
243 if (!_browserServerMemo.hasRun) return; | 250 if (!_browserServerMemo.hasRun) return; |
244 await (await _browserServer).close(); | 251 await (await _browserServer).close(); |
245 }); | 252 }); |
246 } | 253 } |
247 } | 254 } |
OLD | NEW |