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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/frontend/expect.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/backend/invoker.dart
diff --git a/lib/src/backend/invoker.dart b/lib/src/backend/invoker.dart
index 68b1966abac375b3eba21e13668bf625018f4e18..9d2205e9ba80402b7ff7ea7f2031c587e96ec9c5 100644
--- a/lib/src/backend/invoker.dart
+++ b/lib/src/backend/invoker.dart
@@ -231,6 +231,27 @@ class Invoker {
});
}
+ /// Marks the current test as skipped.
+ ///
+ /// If passed, [message] is emitted as a skip message.
+ ///
+ /// Note that this *does not* mark the test as complete. That is, it sets
+ /// the result to [Result.skipped], but doesn't change the state.
+ void skip([String message]) {
+ if (liveTest.state.shouldBeDone) {
+ // Set the state explicitly so we don't get an extra error about the test
+ // failing after being complete.
+ _controller.setState(const State(Status.complete, Result.error));
+ throw "This test was marked as skipped after it had already completed. "
+ "Make sure to use\n"
+ "[expectAsync] or the [completes] matcher when testing async code.";
+ }
+
+ if (message != null) _controller.message(new Message.skip(message));
+ // TODO: error if the test is already complete.
+ _controller.setState(const State(Status.pending, Result.skipped));
+ }
+
/// Notifies the invoker of an asynchronous error.
void _handleError(error, [StackTrace stackTrace]) {
if (stackTrace == null) stackTrace = new Chain.current();
« 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