Chromium Code Reviews

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: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« 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..854839ae21db2f3b29c355b80b64f9778fc775bc 100644
--- a/lib/src/backend/invoker.dart
+++ b/lib/src/backend/invoker.dart
@@ -231,6 +231,26 @@ 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.
kevmoo 2016/07/06 20:30:42 What *does* it do? Worth explaining a bit more, I
nweiz 2016/07/06 21:14:18 Done.
+ 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