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

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

Issue 2123353002: Add a skip parameter to expect(). (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 5 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 | « CHANGELOG.md ('k') | lib/src/frontend/expect.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) 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:stack_trace/stack_trace.dart'; 7 import 'package:stack_trace/stack_trace.dart';
8 8
9 import '../frontend/expect.dart'; 9 import '../frontend/expect.dart';
10 import '../runner/load_suite.dart'; 10 import '../runner/load_suite.dart';
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 _timeoutTimer = _invokerZone.createTimer(timeout, () { 224 _timeoutTimer = _invokerZone.createTimer(timeout, () {
225 _outstandingCallbackZones.last.run(() { 225 _outstandingCallbackZones.last.run(() {
226 if (liveTest.isComplete) return; 226 if (liveTest.isComplete) return;
227 _handleError( 227 _handleError(
228 new TimeoutException( 228 new TimeoutException(
229 "Test timed out after ${niceDuration(timeout)}.", timeout)); 229 "Test timed out after ${niceDuration(timeout)}.", timeout));
230 }); 230 });
231 }); 231 });
232 } 232 }
233 233
234 /// Marks the current test as skipped.
235 ///
236 /// If passed, [message] is emitted as a skip message.
237 ///
238 /// Note that this *does not* mark the test as complete. That is, it sets
239 /// the result to [Result.skipped], but doesn't change the state.
240 void skip([String message]) {
241 if (liveTest.state.shouldBeDone) {
242 // Set the state explicitly so we don't get an extra error about the test
243 // failing after being complete.
244 _controller.setState(const State(Status.complete, Result.error));
245 throw "This test was marked as skipped after it had already completed. "
246 "Make sure to use\n"
247 "[expectAsync] or the [completes] matcher when testing async code.";
248 }
249
250 if (message != null) _controller.message(new Message.skip(message));
251 // TODO: error if the test is already complete.
252 _controller.setState(const State(Status.pending, Result.skipped));
253 }
254
234 /// Notifies the invoker of an asynchronous error. 255 /// Notifies the invoker of an asynchronous error.
235 void _handleError(error, [StackTrace stackTrace]) { 256 void _handleError(error, [StackTrace stackTrace]) {
236 if (stackTrace == null) stackTrace = new Chain.current(); 257 if (stackTrace == null) stackTrace = new Chain.current();
237 258
238 // Store this here because it'll change when we set the state below. 259 // Store this here because it'll change when we set the state below.
239 var shouldBeDone = liveTest.state.shouldBeDone; 260 var shouldBeDone = liveTest.state.shouldBeDone;
240 261
241 if (error is! TestFailure) { 262 if (error is! TestFailure) {
242 _controller.setState(const State(Status.complete, Result.error)); 263 _controller.setState(const State(Status.complete, Result.error));
243 } else if (liveTest.state.result != Result.error) { 264 } else if (liveTest.state.result != Result.error) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 _counterKey: outstandingCallbacksForBody, 323 _counterKey: outstandingCallbacksForBody,
303 _closableKey: true 324 _closableKey: true
304 }, 325 },
305 zoneSpecification: new ZoneSpecification( 326 zoneSpecification: new ZoneSpecification(
306 print: (self, parent, zone, line) => 327 print: (self, parent, zone, line) =>
307 _controller.message(new Message.print(line))), 328 _controller.message(new Message.print(line))),
308 onError: _handleError); 329 onError: _handleError);
309 }); 330 });
310 } 331 }
311 } 332 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/frontend/expect.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698