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

Side by Side Diff: pkg/scheduled_test/lib/scheduled_server.dart

Issue 62353002: Fix scheduled_server_test to not timeout-fail. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « pkg/pkg.status ('k') | pkg/scheduled_test/lib/src/scheduled_server/safe_http_server.dart » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 scheduled_test.scheduled_server; 5 library scheduled_test.scheduled_server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 /// The request must be received at the point in the schedule at which 71 /// The request must be received at the point in the schedule at which
72 /// [handle] was called, or in the task immediately prior (to allow for 72 /// [handle] was called, or in the task immediately prior (to allow for
73 /// non-deterministic asynchronicity). Otherwise, an error will be thrown. 73 /// non-deterministic asynchronicity). Otherwise, an error will be thrown.
74 void handle(String method, String path, ScheduledHandler fn) { 74 void handle(String method, String path, ScheduledHandler fn) {
75 var handler = new Handler(this, method, path, fn); 75 var handler = new Handler(this, method, path, fn);
76 _handlers.add(handler); 76 _handlers.add(handler);
77 schedule(() { 77 schedule(() {
78 handler.ready = true; 78 handler.ready = true;
79 return handler.result.catchError((e) { 79 return handler.result.catchError((e) {
80 // Close the server so that we don't leave a dangling request. 80 // Close the server so that we don't leave a dangling request.
81 _server.then((s) => s.close()); 81 _server.then((s) => s.close(force: true));
82 throw e; 82 throw e;
83 }); 83 });
84 }, "'$description' waiting for $method $path"); 84 }, "'$description' waiting for $method $path");
85 } 85 }
86 86
87 /// The handler for incoming [HttpRequest]s to this server. This dispatches 87 /// The handler for incoming [HttpRequest]s to this server. This dispatches
88 /// the request to the first handler in the queue. It's that handler's 88 /// the request to the first handler in the queue. It's that handler's
89 /// responsibility to check that the method/path are correct and that it's 89 /// responsibility to check that the method/path are correct and that it's
90 /// being run at the correct time. 90 /// being run at the correct time.
91 void _handleRequest(HttpRequest request) { 91 void _handleRequest(HttpRequest request) {
92 wrapFuture(new Future.sync(() { 92 wrapFuture(new Future.sync(() {
93 if (_handlers.isEmpty) { 93 if (_handlers.isEmpty) {
94 fail("'$description' received ${request.method} ${request.uri.path} " 94 fail("'$description' received ${request.method} ${request.uri.path} "
95 "when no more requests were expected."); 95 "when no more requests were expected.");
96 } 96 }
97 return _handlers.removeFirst().fn(request); 97 return _handlers.removeFirst().fn(request);
98 }).catchError((e) { 98 }).catchError((e) {
99 // Close the server so that we don't leave a dangling request. 99 // Close the server so that we don't leave a dangling request.
100 _server.then((s) => s.close()); 100 _server.then((s) => s.close(force: true));
101 throw e; 101 throw e;
102 }), 'receiving ${request.method} ${request.uri}'); 102 }), 'receiving ${request.method} ${request.uri}');
103 } 103 }
104 } 104 }
OLDNEW
« no previous file with comments | « pkg/pkg.status ('k') | pkg/scheduled_test/lib/src/scheduled_server/safe_http_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698