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

Side by Side Diff: sdk/lib/_internal/pub/test/serve/utils.dart

Issue 316623005: Fix a race condition in pub serve's exitOnClose test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.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 pub_tests; 5 library pub_tests;
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:http/http.dart' as http; 11 import 'package:http/http.dart' as http;
12 import 'package:scheduled_test/scheduled_process.dart'; 12 import 'package:scheduled_test/scheduled_process.dart';
13 import 'package:scheduled_test/scheduled_stream.dart'; 13 import 'package:scheduled_test/scheduled_stream.dart';
14 import 'package:scheduled_test/scheduled_test.dart'; 14 import 'package:scheduled_test/scheduled_test.dart';
15 import 'package:stack_trace/stack_trace.dart';
15 16
16 import '../../lib/src/utils.dart'; 17 import '../../lib/src/utils.dart';
17 import '../descriptor.dart' as d; 18 import '../descriptor.dart' as d;
18 import '../test_pub.dart'; 19 import '../test_pub.dart';
19 20
20 /// The pub process running "pub serve". 21 /// The pub process running "pub serve".
21 ScheduledProcess _pubServer; 22 ScheduledProcess _pubServer;
22 23
23 /// The ephemeral port assign to the running admin server. 24 /// The ephemeral port assign to the running admin server.
24 int _adminPort; 25 int _adminPort;
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 Future<Map> _jsonRpcRequest(String method, [Map params]) { 437 Future<Map> _jsonRpcRequest(String method, [Map params]) {
437 var id = _rpcId++; 438 var id = _rpcId++;
438 var message = { 439 var message = {
439 "jsonrpc": "2.0", 440 "jsonrpc": "2.0",
440 "method": method, 441 "method": method,
441 "id": id 442 "id": id
442 }; 443 };
443 if (params != null) message["params"] = params; 444 if (params != null) message["params"] = params;
444 _webSocket.add(JSON.encode(message)); 445 _webSocket.add(JSON.encode(message));
445 446
446 return _webSocketBroadcastStream 447 return Chain.track(_webSocketBroadcastStream
447 .firstWhere((response) => response["id"] == id).then((value) { 448 .firstWhere((response) => response["id"] == id)).then((value) {
448 currentSchedule.addDebugInfo( 449 currentSchedule.addDebugInfo(
449 "Web Socket request $method with params $params\n" 450 "Web Socket request $method with params $params\n"
450 "Result: $value"); 451 "Result: $value");
451 452
452 expect(value["id"], equals(id)); 453 expect(value["id"], equals(id));
453 return value; 454 return value;
454 }); 455 });
455 } 456 }
456 457
457 /// Returns a [Future] that completes to a URL string for the server serving 458 /// Returns a [Future] that completes to a URL string for the server serving
(...skipping 19 matching lines...) Expand all
477 /// included. Unlike [getServerUrl], this should only be called after the ports 478 /// included. Unlike [getServerUrl], this should only be called after the ports
478 /// are known. 479 /// are known.
479 String _getServerUrlSync([String root, String path]) { 480 String _getServerUrlSync([String root, String path]) {
480 if (root == null) root = 'web'; 481 if (root == null) root = 'web';
481 expect(_ports, contains(root)); 482 expect(_ports, contains(root));
482 var url = "http://127.0.0.1:${_ports[root]}"; 483 var url = "http://127.0.0.1:${_ports[root]}";
483 if (path != null) url = "$url/$path"; 484 if (path != null) url = "$url/$path";
484 return url; 485 return url;
485 } 486 }
486 487
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698