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

Side by Side Diff: lib/src/backend/invoker.dart

Issue 1152083003: Make Invoker.removeAllOutstandingCallbacks public. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.backend.invoker; 5 library test.backend.invoker;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:stack_trace/stack_trace.dart'; 9 import 'package:stack_trace/stack_trace.dart';
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 void addOutstandingCallback() { 113 void addOutstandingCallback() {
114 if (closed) throw new ClosedException(); 114 if (closed) throw new ClosedException();
115 _outstandingCallbacks.addOutstandingCallback(); 115 _outstandingCallbacks.addOutstandingCallback();
116 } 116 }
117 117
118 /// Tells the invoker that a callback declared with [addOutstandingCallback] 118 /// Tells the invoker that a callback declared with [addOutstandingCallback]
119 /// is no longer running. 119 /// is no longer running.
120 void removeOutstandingCallback() => 120 void removeOutstandingCallback() =>
121 _outstandingCallbacks.removeOutstandingCallback(); 121 _outstandingCallbacks.removeOutstandingCallback();
122 122
123 /// Removes all outstanding callbacks, for example when an error occurs.
124 ///
125 /// Future calls to [addOutstandingCallback] and [removeOutstandingCallback]
126 /// will be ignored.
127 void removeAllOutstandingCallbacks() =>
128 _outstandingCallbacks.removeAllOutstandingCallbacks();
129
123 /// Runs [fn] and returns once all (registered) outstanding callbacks it 130 /// Runs [fn] and returns once all (registered) outstanding callbacks it
124 /// transitively invokes have completed. 131 /// transitively invokes have completed.
125 /// 132 ///
126 /// If [fn] itself returns a future, this will automatically wait until that 133 /// If [fn] itself returns a future, this will automatically wait until that
127 /// future completes as well. 134 /// future completes as well.
128 /// 135 ///
129 /// Note that outstanding callbacks registered within [fn] will *not* be 136 /// Note that outstanding callbacks registered within [fn] will *not* be
130 /// registered as outstanding callback outside of [fn]. 137 /// registered as outstanding callback outside of [fn].
131 Future waitForOutstandingCallbacks(fn()) { 138 Future waitForOutstandingCallbacks(fn()) {
132 var counter = new OutstandingCallbackCounter(); 139 var counter = new OutstandingCallbackCounter();
(...skipping 20 matching lines...) Expand all
153 var afterSuccess = liveTest.isComplete && 160 var afterSuccess = liveTest.isComplete &&
154 liveTest.state.result == Result.success; 161 liveTest.state.result == Result.success;
155 162
156 if (error is! TestFailure) { 163 if (error is! TestFailure) {
157 _controller.setState(const State(Status.complete, Result.error)); 164 _controller.setState(const State(Status.complete, Result.error));
158 } else if (liveTest.state.result != Result.error) { 165 } else if (liveTest.state.result != Result.error) {
159 _controller.setState(const State(Status.complete, Result.failure)); 166 _controller.setState(const State(Status.complete, Result.failure));
160 } 167 }
161 168
162 _controller.addError(error, stackTrace); 169 _controller.addError(error, stackTrace);
163 _outstandingCallbacks.removeAllOutstandingCallbacks(); 170 removeAllOutstandingCallbacks();
164 171
165 // If a test was marked as success but then had an error, that indicates 172 // If a test was marked as success but then had an error, that indicates
166 // that it was poorly-written and could be flaky. 173 // that it was poorly-written and could be flaky.
167 if (!afterSuccess) return; 174 if (!afterSuccess) return;
168 handleError( 175 handleError(
169 "This test failed after it had already completed. Make sure to use " 176 "This test failed after it had already completed. Make sure to use "
170 "[expectAsync]\n" 177 "[expectAsync]\n"
171 "or the [completes] matcher when testing async code.", 178 "or the [completes] matcher when testing async code.",
172 stackTrace); 179 stackTrace);
173 } 180 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // Use the invoker as a key so that multiple invokers can have different 229 // Use the invoker as a key so that multiple invokers can have different
223 // outstanding callback counters at once. 230 // outstanding callback counters at once.
224 this: outstandingCallbacksForBody 231 this: outstandingCallbacksForBody
225 }, 232 },
226 zoneSpecification: new ZoneSpecification( 233 zoneSpecification: new ZoneSpecification(
227 print: (self, parent, zone, line) => _controller.print(line)), 234 print: (self, parent, zone, line) => _controller.print(line)),
228 onError: handleError); 235 onError: handleError);
229 }); 236 });
230 } 237 }
231 } 238 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698