| 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.browser.server; | 5 library test.runner.browser.server; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 return url.resolveUri( | 243 return url.resolveUri( |
| 244 p.toUri(p.relative(path, from: _root) + ".browser_test.html")); | 244 p.toUri(p.relative(path, from: _root) + ".browser_test.html")); |
| 245 }); | 245 }); |
| 246 }).then((suiteUrl) { | 246 }).then((suiteUrl) { |
| 247 if (_closed) return null; | 247 if (_closed) return null; |
| 248 | 248 |
| 249 // TODO(nweiz): Don't start the browser until all the suites are compiled. | 249 // TODO(nweiz): Don't start the browser until all the suites are compiled. |
| 250 return _browserManagerFor(browser).then((browserManager) { | 250 return _browserManagerFor(browser).then((browserManager) { |
| 251 if (_closed) return null; | 251 if (_closed) return null; |
| 252 return browserManager.loadSuite(path, suiteUrl); | 252 return browserManager.loadSuite(path, suiteUrl); |
| 253 }).then((suite) => suite.change(platform: browser.name)); | 253 }).then((suite) { |
| 254 if (_closed) return null; |
| 255 if (suite != null) return suite.change(platform: browser.name); |
| 256 |
| 257 // If the browser manager fails to load a suite and the server isn't |
| 258 // closed, it's probably because the browser failed. We emit the failure |
| 259 // here to ensure that it gets surfaced. |
| 260 return _browsers[browser].onExit; |
| 261 }); |
| 254 }); | 262 }); |
| 255 } | 263 } |
| 256 | 264 |
| 257 /// Loads a test suite at [path] from the `pub serve` URL [jsUrl]. | 265 /// Loads a test suite at [path] from the `pub serve` URL [jsUrl]. |
| 258 /// | 266 /// |
| 259 /// This ensures that only one suite is loaded at a time, and that any errors | 267 /// This ensures that only one suite is loaded at a time, and that any errors |
| 260 /// are exposed as [LoadException]s. | 268 /// are exposed as [LoadException]s. |
| 261 Future _pubServeSuite(String path, Uri jsUrl) { | 269 Future _pubServeSuite(String path, Uri jsUrl) { |
| 262 return _pubServePool.withResource(() { | 270 return _pubServePool.withResource(() { |
| 263 var timer = new Timer(new Duration(seconds: 1), () { | 271 var timer = new Timer(new Duration(seconds: 1), () { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 if (_pubServeUrl == null) { | 388 if (_pubServeUrl == null) { |
| 381 new Directory(_compiledDir).deleteSync(recursive: true); | 389 new Directory(_compiledDir).deleteSync(recursive: true); |
| 382 } else { | 390 } else { |
| 383 _http.close(); | 391 _http.close(); |
| 384 } | 392 } |
| 385 | 393 |
| 386 _closeCompleter.complete(); | 394 _closeCompleter.complete(); |
| 387 }).catchError(_closeCompleter.completeError); | 395 }).catchError(_closeCompleter.completeError); |
| 388 } | 396 } |
| 389 } | 397 } |
| OLD | NEW |