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

Unified Diff: lib/src/backend/state.dart

Issue 2099503002: Add a dedicated Result for skipped tests. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/backend/invoker.dart ('k') | lib/src/frontend/expect_async.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/backend/state.dart
diff --git a/lib/src/backend/state.dart b/lib/src/backend/state.dart
index 7ee25603081980e8d09d83679bd41d72736f044c..f846d695ae42c0e971aa723ca548e666fdc3c914 100644
--- a/lib/src/backend/state.dart
+++ b/lib/src/backend/state.dart
@@ -17,6 +17,14 @@ class State {
/// [Result.success] since the test hasn't yet had a chance to fail.
final Result result;
+ /// Whether a test in this state is expected to be done running code.
+ ///
+ /// If [status] is [Status.complete] and [result] doesn't indicate an error, a
+ /// properly-written test case should not be running any more code. However,
+ /// it may have started asynchronous processes without notifying the test
+ /// runner.
+ bool get shouldBeDone => status == Status.complete && result.isPassing;
+
const State(this.status, this.result);
bool operator==(other) => other is State && status == other.status &&
@@ -74,6 +82,12 @@ class Result {
/// Note that this doesn't mean that the test won't fail in the future.
static const success = const Result._("success");
+ /// The test, or some part of it, has been skipped.
+ ///
+ /// This implies that the test hasn't failed *yet*. However, it this doesn't
+ /// mean that the test won't fail in the future.
+ static const skipped = const Result._("skipped");
+
/// The test has failed.
///
/// A failure is specifically caused by a [TestFailure] being thrown; any
@@ -88,9 +102,22 @@ class Result {
/// The name of the result.
final String name;
+ /// Whether this is a passing result.
+ ///
+ /// A test is considered to have passed if it's a success or if it was
+ /// skipped.
+ bool get isPassing => this == success || this == skipped;
+
+ /// Whether this is a failing result.
+ ///
+ /// A test is considered to have failed if it experiences a failure or an
+ /// error.
+ bool get isFailing => !isPassing;
+
factory Result.parse(String name) {
switch (name) {
case "success": return Result.success;
+ case "skipped": return Result.skipped;
case "failure": return Result.failure;
case "error": return Result.error;
default:
« no previous file with comments | « lib/src/backend/invoker.dart ('k') | lib/src/frontend/expect_async.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698