OLD | NEW |
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 | 8 |
9 import 'package:http/http.dart' as http; | 9 import 'package:http/http.dart' as http; |
10 import 'package:scheduled_test/scheduled_process.dart'; | 10 import 'package:scheduled_test/scheduled_process.dart'; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 return _pubServer.nextLine().then((line) { | 79 return _pubServer.nextLine().then((line) { |
80 if (line.contains("successfully")) return; | 80 if (line.contains("successfully")) return; |
81 | 81 |
82 // This line wasn't it, so ignore it and keep trying. | 82 // This line wasn't it, so ignore it and keep trying. |
83 return nextLine(); | 83 return nextLine(); |
84 }); | 84 }); |
85 } | 85 } |
86 | 86 |
87 schedule(nextLine); | 87 schedule(nextLine); |
88 } | 88 } |
89 | |
90 /// Returns a [Future] that completes after pumping the event queue [times] | |
91 /// times. By default, this should pump the event queue enough times to allow | |
92 /// any code to run, as long as it's not waiting on some external event. | |
93 Future _pumpEventQueue([int times=20]) { | |
94 if (times == 0) return new Future.value(); | |
95 // We use a delayed future to allow runAsync events to finish. The | |
96 // Future.value or Future() constructors use runAsync themselves and would | |
97 // therefore not wait for runAsync callbacks that are scheduled after invoking | |
98 // this method. | |
99 return new Future.delayed(Duration.ZERO, () => _pumpEventQueue(times - 1)); | |
100 } | |
OLD | NEW |