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

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

Issue 12226103: Revert "Add built-in timeouts to scheduled_test." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
« no previous file with comments | « no previous file | pkg/scheduled_test/lib/src/schedule.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 // TODO(nweiz): Add timeouts to scheduled tests.
5 // TODO(nweiz): Add support for calling [schedule] while the schedule is already 6 // TODO(nweiz): Add support for calling [schedule] while the schedule is already
6 // running. 7 // running.
7 // TODO(nweiz): Port the non-Pub-specific scheduled test libraries from Pub. 8 // TODO(nweiz): Port the non-Pub-specific scheduled test libraries from Pub.
8 /// A package for writing readable tests of asynchronous behavior. 9 /// A package for writing readable tests of asynchronous behavior.
9 /// 10 ///
10 /// This package works by building up a queue of asynchronous tasks called a 11 /// This package works by building up a queue of asynchronous tasks called a
11 /// "schedule", then executing those tasks in order. This allows the tests to 12 /// "schedule", then executing those tasks in order. This allows the tests to
12 /// read like synchronous, linear code, despite executing asynchronously. 13 /// read like synchronous, linear code, despite executing asynchronously.
13 /// 14 ///
14 /// The `scheduled_test` package is built on top of `unittest`, and should be 15 /// The `scheduled_test` package is built on top of `unittest`, and should be
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 /// void main() { 132 /// void main() {
132 /// test('sendRequest sends a request', () { 133 /// test('sendRequest sends a request', () {
133 /// startServer(wrapAsync((request) { 134 /// startServer(wrapAsync((request) {
134 /// expect(request.body, equals('payload')); 135 /// expect(request.body, equals('payload'));
135 /// request.response.close(); 136 /// request.response.close();
136 /// })); 137 /// }));
137 /// 138 ///
138 /// schedule(() => sendRequest('payload')); 139 /// schedule(() => sendRequest('payload'));
139 /// }); 140 /// });
140 /// } 141 /// }
141 ///
142 /// ## Timeouts
143 ///
144 /// `scheduled_test` has a built-in timeout of 30 seconds (configurable via
145 /// [Schedule.timeoutMs]). This timeout is aware of the structure of the
146 /// schedule; this means that it will reset for each task in a queue, when
147 /// moving between queues, or almost any other sort of interaction with
148 /// [currentSchedule]. As long as the [Schedule] knows your test is making some
149 /// sort of progress, it won't time out.
150 ///
151 /// If a single task might take a long time, you can also manually tell the
152 /// [Schedule] that it's making progress by calling [Schedule.heartbeat], which
153 /// will reset the timeout whenever it's called.
154 library scheduled_test; 142 library scheduled_test;
155 143
156 import 'dart:async'; 144 import 'dart:async';
157 145
158 import 'package:unittest/unittest.dart' as unittest; 146 import 'package:unittest/unittest.dart' as unittest;
159 147
160 import 'src/schedule.dart'; 148 import 'src/schedule.dart';
161 import 'src/schedule_error.dart'; 149 import 'src/schedule_error.dart';
162 import 'src/utils.dart'; 150 import 'src/utils.dart';
163 151
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 unittest.ensureInitialized(); 283 unittest.ensureInitialized();
296 unittest.wrapAsync = (f) { 284 unittest.wrapAsync = (f) {
297 if (currentSchedule == null) { 285 if (currentSchedule == null) {
298 throw new StateError("Unexpected call to wrapAsync with no current " 286 throw new StateError("Unexpected call to wrapAsync with no current "
299 "schedule."); 287 "schedule.");
300 } 288 }
301 289
302 return currentSchedule.wrapAsync(f); 290 return currentSchedule.wrapAsync(f);
303 }; 291 };
304 } 292 }
OLDNEW
« no previous file with comments | « no previous file | pkg/scheduled_test/lib/src/schedule.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698