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

Unified Diff: pkg/testing/lib/src/chain.dart

Issue 2627753005: Implement multitest failure expectations. (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/testing/lib/src/chain.dart
diff --git a/pkg/testing/lib/src/chain.dart b/pkg/testing/lib/src/chain.dart
index 4d7063cc2079805f9aa670db1b4c9d05db0f0ceb..1dcd538b4c665fd38a4c4cfb4fee80a561bdb434 100644
--- a/pkg/testing/lib/src/chain.dart
+++ b/pkg/testing/lib/src/chain.dart
@@ -196,7 +196,8 @@ abstract class ChainContext {
}
if (description.multitestExpectations != null) {
if (isError(description.multitestExpectations)) {
- result = result.toNegativeTestResult();
+ result = toNegativeTestResult(
+ result, description.multitestExpectations);
}
} else if (lastStep == lastStepRun &&
description.shortName.endsWith("negative_test")) {
@@ -205,7 +206,7 @@ abstract class ChainContext {
} else if (result.outcome == Expectation.FAIL) {
result.addLog("Negative test reported an error as expeceted.\n");
}
- result = result.toNegativeTestResult();
+ result = toNegativeTestResult(result);
}
if (!expectedOutcomes.contains(result.outcome)) {
result.addLog("$sb");
@@ -316,13 +317,7 @@ class Result<O> {
logs.add(log);
}
- Result<O> toNegativeTestResult() {
- Expectation outcome = this.outcome;
- if (outcome == Expectation.PASS) {
- outcome = Expectation.FAIL;
- } else if (outcome == Expectation.FAIL) {
- outcome = Expectation.PASS;
- }
+ Result<O> copyWithOutcome(Expectation outcome) {
return new Result<O>(output, outcome, error, trace)
..logs.addAll(logs);
}
@@ -339,3 +334,22 @@ Future<Null> runChain(
return context.run(suite, selectors);
});
}
+
+Result toNegativeTestResult(Result result, [Set<String> expectations]) {
+ Expectation outcome = result.outcome;
+ if (outcome == Expectation.PASS) {
+ if (expectations == null) {
+ outcome = Expectation.FAIL;
+ } else if (expectations.contains("compile-time error")) {
+ outcome = Expectation.MISSING_COMPILETIME_ERROR;
+ } else if (expectations.contains("runtime error") ||
+ expectations.contains("dynamic type error")) {
+ outcome = Expectation.MISSING_RUNTIME_ERROR;
+ } else {
+ outcome = Expectation.FAIL;
+ }
+ } else if (outcome == Expectation.FAIL) {
+ outcome = Expectation.PASS;
+ }
+ return result.copyWithOutcome(outcome);
+}
« 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