| 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 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 /// [metadata] is the suite-level metadata for the test. | 145 /// [metadata] is the suite-level metadata for the test. |
| 146 Future<RunnerSuite> _loadVmFile(String path, Metadata metadata) async { | 146 Future<RunnerSuite> _loadVmFile(String path, Metadata metadata) async { |
| 147 var receivePort = new ReceivePort(); | 147 var receivePort = new ReceivePort(); |
| 148 | 148 |
| 149 var isolate; | 149 var isolate; |
| 150 try { | 150 try { |
| 151 if (_config.pubServeUrl != null) { | 151 if (_config.pubServeUrl != null) { |
| 152 var url = _config.pubServeUrl.resolveUri( | 152 var url = _config.pubServeUrl.resolveUri( |
| 153 p.toUri(p.relative(path, from: 'test') + '.vm_test.dart')); | 153 p.toUri(p.relative(path, from: 'test') + '.vm_test.dart')); |
| 154 | 154 |
| 155 // TODO(nweiz): Remove new Future.sync() once issue 23498 has been fixed | 155 try { |
| 156 // in two stable versions. | 156 isolate = await Isolate.spawnUri(url, [], { |
| 157 await new Future.sync(() async { | 157 'reply': receivePort.sendPort, |
| 158 try { | 158 'metadata': metadata.serialize() |
| 159 isolate = await dart.spawnUri(url, { | 159 }, checked: true); |
| 160 'reply': receivePort.sendPort, | 160 } on IsolateSpawnException catch (error) { |
| 161 'metadata': metadata.serialize() | 161 if (error.message.contains("OS Error: Connection refused") || |
| 162 }, checked: true); | 162 error.message.contains("The remote computer refused")) { |
| 163 } on IsolateSpawnException catch (error) { | 163 throw new LoadException(path, |
| 164 if (error.message.contains("OS Error: Connection refused") || | 164 "Error getting $url: Connection refused\n" |
| 165 error.message.contains("The remote computer refused")) { | 165 'Make sure "pub serve" is running.'); |
| 166 throw new LoadException(path, | 166 } else if (error.message.contains("404 Not Found")) { |
| 167 "Error getting $url: Connection refused\n" | 167 throw new LoadException(path, |
| 168 'Make sure "pub serve" is running.'); | 168 "Error getting $url: 404 Not Found\n" |
| 169 } else if (error.message.contains("404 Not Found")) { | 169 'Make sure "pub serve" is serving the test/ directory.'); |
| 170 throw new LoadException(path, | 170 } |
| 171 "Error getting $url: 404 Not Found\n" | |
| 172 'Make sure "pub serve" is serving the test/ directory.'); | |
| 173 } | |
| 174 | 171 |
| 175 throw new LoadException(path, error); | 172 throw new LoadException(path, error); |
| 176 } | 173 } |
| 177 }); | |
| 178 } else { | 174 } else { |
| 179 isolate = await dart.runInIsolate(''' | 175 isolate = await dart.runInIsolate(''' |
| 180 import "package:test/src/backend/metadata.dart"; | 176 import "package:test/src/backend/metadata.dart"; |
| 181 import "package:test/src/runner/vm/isolate_listener.dart"; | 177 import "package:test/src/runner/vm/isolate_listener.dart"; |
| 182 | 178 |
| 183 import "${p.toUri(p.absolute(path))}" as test; | 179 import "${p.toUri(p.absolute(path))}" as test; |
| 184 | 180 |
| 185 void main(_, Map message) { | 181 void main(_, Map message) { |
| 186 var sendPort = message['reply']; | 182 var sendPort = message['reply']; |
| 187 var metadata = new Metadata.deserialize(message['metadata']); | 183 var metadata = new Metadata.deserialize(message['metadata']); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 Future close() { | 238 Future close() { |
| 243 return _closeMemo.runOnce(() async { | 239 return _closeMemo.runOnce(() async { |
| 244 await Future.wait(_suites.map((suite) => suite.close())); | 240 await Future.wait(_suites.map((suite) => suite.close())); |
| 245 _suites.clear(); | 241 _suites.clear(); |
| 246 | 242 |
| 247 if (!_browserServerMemo.hasRun) return; | 243 if (!_browserServerMemo.hasRun) return; |
| 248 await (await _browserServer).close(); | 244 await (await _browserServer).close(); |
| 249 }); | 245 }); |
| 250 } | 246 } |
| 251 } | 247 } |
| OLD | NEW |