Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: lib/src/runner/browser/server.dart

Issue 1179193003: Fix a bug with Control+C and browsers. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 var hostUrl = (_pubServeUrl == null ? url : _pubServeUrl) 424 var hostUrl = (_pubServeUrl == null ? url : _pubServeUrl)
425 .resolve('packages/test/src/runner/browser/static/index.html'); 425 .resolve('packages/test/src/runner/browser/static/index.html');
426 426
427 var browser = _newBrowser(hostUrl.replace(queryParameters: { 427 var browser = _newBrowser(hostUrl.replace(queryParameters: {
428 'managerUrl': webSocketUrl.toString() 428 'managerUrl': webSocketUrl.toString()
429 }), platform); 429 }), platform);
430 _browsers[platform] = browser; 430 _browsers[platform] = browser;
431 431
432 // TODO(nweiz): Gracefully handle the browser being killed before the 432 // TODO(nweiz): Gracefully handle the browser being killed before the
433 // tests complete. 433 // tests complete.
434 browser.onExit.catchError((error, stackTrace) { 434 browser.onExit.then((_) {
435 if (completer.isCompleted) return;
436 if (!_closed) return;
437 completer.complete(null);
438 }).catchError((error, stackTrace) {
435 if (completer.isCompleted) return; 439 if (completer.isCompleted) return;
436 completer.completeError(error, stackTrace); 440 completer.completeError(error, stackTrace);
437 }); 441 });
438 442
439 return completer.future.timeout(new Duration(seconds: 7), onTimeout: () { 443 return completer.future.timeout(new Duration(seconds: 7), onTimeout: () {
440 throw new ApplicationException( 444 throw new ApplicationException(
441 "Timed out waiting for ${platform.name} to connect."); 445 "Timed out waiting for ${platform.name} to connect.");
442 }); 446 });
443 } 447 }
444 448
(...skipping 11 matching lines...) Expand all
456 throw new ArgumentError("$browser is not a browser."); 460 throw new ArgumentError("$browser is not a browser.");
457 } 461 }
458 } 462 }
459 463
460 /// Closes the server and releases all its resources. 464 /// Closes the server and releases all its resources.
461 /// 465 ///
462 /// Returns a [Future] that completes once the server is closed and its 466 /// Returns a [Future] that completes once the server is closed and its
463 /// resources have been fully released. 467 /// resources have been fully released.
464 Future close() { 468 Future close() {
465 return _closeThunk.run(() async { 469 return _closeThunk.run(() async {
466 var futures = _browserManagers.keys.map((platform) async { 470 var futures = _browsers.values.map((browser) => browser.close()).toList();
467 await _browserManagers[platform];
468 await _browsers[platform].close();
469 }).toList();
470 471
471 futures.add(_server.close()); 472 futures.add(_server.close());
472 futures.add(_compilers.close()); 473 futures.add(_compilers.close());
473 474
474 await Future.wait(futures); 475 await Future.wait(futures);
475 476
476 if (_pubServeUrl == null) { 477 if (_pubServeUrl == null) {
477 new Directory(_compiledDir).deleteSync(recursive: true); 478 new Directory(_compiledDir).deleteSync(recursive: true);
478 } else { 479 } else {
479 _http.close(); 480 _http.close();
480 } 481 }
481 }); 482 });
482 } 483 }
483 } 484 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698