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

Side by Side Diff: pkg/scheduled_test/test/utils.dart

Issue 68493003: Ensure that errors have stack traces attached. (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/scheduled_test/lib/src/utils.dart ('k') | sdk/lib/_internal/pub/lib/src/barback.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 test_utils; 5 library test_utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:scheduled_test/scheduled_test.dart'; 9 import 'package:scheduled_test/scheduled_test.dart';
10 import 'package:scheduled_test/src/utils.dart'; 10 import 'package:scheduled_test/src/utils.dart';
(...skipping 13 matching lines...) Expand all
24 /// [input]. 24 /// [input].
25 Future timeout(Future input, int milliseconds, onTimeout()) { 25 Future timeout(Future input, int milliseconds, onTimeout()) {
26 var completer = new Completer(); 26 var completer = new Completer();
27 var timer = new Timer(new Duration(milliseconds: milliseconds), () { 27 var timer = new Timer(new Duration(milliseconds: milliseconds), () {
28 chainToCompleter(new Future.sync(onTimeout), completer); 28 chainToCompleter(new Future.sync(onTimeout), completer);
29 }); 29 });
30 input.then((value) { 30 input.then((value) {
31 if (completer.isCompleted) return; 31 if (completer.isCompleted) return;
32 timer.cancel(); 32 timer.cancel();
33 completer.complete(value); 33 completer.complete(value);
34 }).catchError((error) { 34 }).catchError((error, stackTrace) {
35 if (completer.isCompleted) return; 35 if (completer.isCompleted) return;
36 timer.cancel(); 36 timer.cancel();
37 completer.completeError(error); 37 completer.completeError(error, stackTrace);
38 }); 38 });
39 return completer.future; 39 return completer.future;
40 } 40 }
41 41
42 /// Returns a [Future] that will complete in [milliseconds]. 42 /// Returns a [Future] that will complete in [milliseconds].
43 Future sleep(int milliseconds) { 43 Future sleep(int milliseconds) {
44 var completer = new Completer(); 44 var completer = new Completer();
45 mock_clock.newTimer(new Duration(milliseconds: milliseconds), () { 45 mock_clock.newTimer(new Duration(milliseconds: milliseconds), () {
46 completer.complete(); 46 completer.complete();
47 }); 47 });
48 return completer.future; 48 return completer.future;
49 } 49 }
50 50
51 /// Sets up a timeout for every metatest in this file. 51 /// Sets up a timeout for every metatest in this file.
52 void setUpTimeout() { 52 void setUpTimeout() {
53 metaSetUp(() { 53 metaSetUp(() {
54 // TODO(nweiz): We used to only increase the timeout to 10s for the Windows 54 // TODO(nweiz): We used to only increase the timeout to 10s for the Windows
55 // bots, but the Linux and Mac bots have started taking upwards of 5s when 55 // bots, but the Linux and Mac bots have started taking upwards of 5s when
56 // running pumpEventQueue, so we're increasing the timeout across the board 56 // running pumpEventQueue, so we're increasing the timeout across the board
57 // (see issue 9248). 57 // (see issue 9248).
58 currentSchedule.timeout = new Duration(seconds: 10); 58 currentSchedule.timeout = new Duration(seconds: 10);
59 }); 59 });
60 } 60 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/src/utils.dart ('k') | sdk/lib/_internal/pub/lib/src/barback.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698