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

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

Issue 1098703003: Add timeouts for browser connections. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 8 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 | « lib/src/runner/browser/browser_manager.dart ('k') | 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
11 import 'package:path/path.dart' as p; 11 import 'package:path/path.dart' as p;
12 import 'package:pool/pool.dart'; 12 import 'package:pool/pool.dart';
13 import 'package:shelf/shelf.dart' as shelf; 13 import 'package:shelf/shelf.dart' as shelf;
14 import 'package:shelf/shelf_io.dart' as shelf_io; 14 import 'package:shelf/shelf_io.dart' as shelf_io;
15 import 'package:shelf_static/shelf_static.dart'; 15 import 'package:shelf_static/shelf_static.dart';
16 import 'package:shelf_web_socket/shelf_web_socket.dart'; 16 import 'package:shelf_web_socket/shelf_web_socket.dart';
17 17
18 import '../../backend/metadata.dart'; 18 import '../../backend/metadata.dart';
19 import '../../backend/suite.dart'; 19 import '../../backend/suite.dart';
20 import '../../backend/test_platform.dart'; 20 import '../../backend/test_platform.dart';
21 import '../../util/io.dart'; 21 import '../../util/io.dart';
22 import '../../util/path_handler.dart'; 22 import '../../util/path_handler.dart';
23 import '../../util/one_off_handler.dart'; 23 import '../../util/one_off_handler.dart';
24 import '../../utils.dart'; 24 import '../../utils.dart';
25 import '../application_exception.dart';
25 import '../load_exception.dart'; 26 import '../load_exception.dart';
26 import 'browser.dart'; 27 import 'browser.dart';
27 import 'browser_manager.dart'; 28 import 'browser_manager.dart';
28 import 'compiler_pool.dart'; 29 import 'compiler_pool.dart';
29 import 'chrome.dart'; 30 import 'chrome.dart';
30 import 'dartium.dart'; 31 import 'dartium.dart';
31 import 'content_shell.dart'; 32 import 'content_shell.dart';
32 import 'firefox.dart'; 33 import 'firefox.dart';
33 import 'phantom_js.dart'; 34 import 'phantom_js.dart';
34 import 'safari.dart'; 35 import 'safari.dart';
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 }), platform); 351 }), platform);
351 _browsers[platform] = browser; 352 _browsers[platform] = browser;
352 353
353 // TODO(nweiz): Gracefully handle the browser being killed before the 354 // TODO(nweiz): Gracefully handle the browser being killed before the
354 // tests complete. 355 // tests complete.
355 browser.onExit.catchError((error, stackTrace) { 356 browser.onExit.catchError((error, stackTrace) {
356 if (completer.isCompleted) return; 357 if (completer.isCompleted) return;
357 completer.completeError(error, stackTrace); 358 completer.completeError(error, stackTrace);
358 }); 359 });
359 360
360 return completer.future; 361 return completer.future.timeout(new Duration(seconds: 7), onTimeout: () {
362 throw new ApplicationException(
363 "Timed out waiting for ${platform.name} to connect.");
364 });
361 } 365 }
362 366
363 /// Starts the browser identified by [browser] and has it load [url]. 367 /// Starts the browser identified by [browser] and has it load [url].
364 Browser _newBrowser(Uri url, TestPlatform browser) { 368 Browser _newBrowser(Uri url, TestPlatform browser) {
365 switch (browser) { 369 switch (browser) {
366 case TestPlatform.dartium: return new Dartium(url); 370 case TestPlatform.dartium: return new Dartium(url);
367 case TestPlatform.contentShell: return new ContentShell(url); 371 case TestPlatform.contentShell: return new ContentShell(url);
368 case TestPlatform.chrome: return new Chrome(url); 372 case TestPlatform.chrome: return new Chrome(url);
369 case TestPlatform.phantomJS: return new PhantomJS(url); 373 case TestPlatform.phantomJS: return new PhantomJS(url);
370 case TestPlatform.firefox: return new Firefox(url); 374 case TestPlatform.firefox: return new Firefox(url);
(...skipping 24 matching lines...) Expand all
395 if (_pubServeUrl == null) { 399 if (_pubServeUrl == null) {
396 new Directory(_compiledDir).deleteSync(recursive: true); 400 new Directory(_compiledDir).deleteSync(recursive: true);
397 } else { 401 } else {
398 _http.close(); 402 _http.close();
399 } 403 }
400 404
401 _closeCompleter.complete(); 405 _closeCompleter.complete();
402 }).catchError(_closeCompleter.completeError); 406 }).catchError(_closeCompleter.completeError);
403 } 407 }
404 } 408 }
OLDNEW
« no previous file with comments | « lib/src/runner/browser/browser_manager.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698