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

Unified Diff: tools/testing/dart/status_file_parser.dart

Issue 23702055: test.py: Support for CompileTimeError,RuntimeError,MissingRuntimeError,MissingCompiletimeError mark… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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
Index: tools/testing/dart/status_file_parser.dart
diff --git a/tools/testing/dart/status_file_parser.dart b/tools/testing/dart/status_file_parser.dart
index b505799402cc174f08e1f0339d6f9c59714b9cbe..6292cbd904fefd9024ec120ec4bcc342681d983d 100644
--- a/tools/testing/dart/status_file_parser.dart
+++ b/tools/testing/dart/status_file_parser.dart
@@ -9,22 +9,91 @@ import "dart:convert" show LineSplitter, UTF8;
import "dart:io";
import "status_expression.dart";
-/** Possible outcomes of running a test. */
-const CRASH = "crash";
-const TIMEOUT = "timeout";
-const FAIL = "fail";
-const PASS = "pass";
-/**
- * An indication to skip the test. The caller is responsible for skipping it.
- */
-const SKIP = "skip";
-const SKIP_BY_DESIGN = "skipbydesign";
-const OK = "ok";
-/**
- * An indication that a test is slow and we should allow extra time for
- * completion.
- */
-const SLOW = "slow";
+class Expectation {
+ // Possible outcomes of running a test.
+ static Expectation PASS = byName('Pass');
+ static Expectation CRASH = byName('Crash');
+ static Expectation TIMEOUT = byName('Timeout');
+ static Expectation FAIL = byName('Fail');
+
+ // Special 'FAIL' cases
+ static Expectation RUNTIME_ERROR = byName('RuntimeError');
+ static Expectation COMPILETIME_ERROR = byName('CompileTimeError');
ricow1 2013/09/23 12:07:32 nit, but there seems to be some difference in how
kustermann 2013/09/23 15:31:34 Changed it to *CompileTime*
+ static Expectation MISSING_RUNTIME_ERROR = byName('MissingRuntimeError');
+ static Expectation MISSING_COMPILETIME_ERROR =
+ byName('MissingCompiletimeError');
+
+ // "meta expectations"
+ static Expectation OK = byName('Ok');
+ static Expectation SLOW = byName('Slow');
+ static Expectation SKIP = byName('Skip');
+ static Expectation SKIP_BY_DESIGN = byName('SkipByDesign');
+
+ static Expectation byName(String name) {
+ _initialize();
+ name = name.toLowerCase();
+ if (!_AllExpectations.containsKey(name)) {
+ throw new Exception("Expectation.byName(name='$name'): Invalid name.");
+ }
+ return _AllExpectations[name];
+ }
+
+ // Keep a map of all possible Expectation objects, initialized lazily.
+ static bool _initialized = false;
+ static final _AllExpectations = new Map<String, Expectation>();
ricow1 2013/09/23 12:07:32 just let this be null and branch on that in _initi
kustermann 2013/09/23 15:31:34 Done.
+ static void _initialize() {
+ if (!_initialized) {
+ _initialized = true;
+
+ Expectation build(prettyName, {group: null, isMetaExpectation: false}) {
+ var expectation = new Expectation._(prettyName,
+ group: group, isMetaExpectation: isMetaExpectation);
+ assert(!_AllExpectations.containsKey(expectation.name));
+ return _AllExpectations[expectation.name] = expectation;
+ }
+
+ var fail = build("Fail");
+ build("Pass");
+ build("Crash");
+ build("Timeout");
+
+ build("MissingCompiletimeError", group: fail);
+ build("MissingRuntimeError", group: fail);
+ build("CompiletimeError", group: fail);
+ build("RuntimeError", group: fail);
+
+ build("Skip", isMetaExpectation: true);
+ build("SkipByDesign", isMetaExpectation: true);
+ build("Ok", isMetaExpectation: true);
+ build("Slow", isMetaExpectation: true);
+ }
+ }
+
+ final String prettyName;
+ final String name;
+ final Expectation group;
+ // Indicates whether this expectation can actually be the outcome of a test.
ricow1 2013/09/23 12:07:32 well it actually indicates the opposite
kustermann 2013/09/23 15:31:34 I clarified it a bit.
+ final bool isMetaExpectation;
+
+ Expectation._(prettyName,
+ {Expectation this.group: null,
+ bool this.isMetaExpectation: false})
+ : prettyName = prettyName, name = prettyName.toLowerCase();
+
+ bool canBeOutcomeOf(Expectation expectation) {
+ Expectation outcome = this;
+ while (outcome != null) {
+ if (outcome == expectation) {
+ return true;
+ }
+ outcome = outcome.group;
+ }
+ return false;
+ }
+
+ String toString() => prettyName;
+}
+
final RegExp SplitComment = new RegExp("^([^#]*)(#.*)?\$");
final RegExp HeaderPattern = new RegExp(r"^\[([^\]]+)\]");
@@ -162,8 +231,9 @@ class TestExpectations {
if (_preprocessed) {
throw "TestExpectations.addRule: cannot add more rules";
}
- var values = testRule.expression.evaluate(environment);
- _map.putIfAbsent(testRule.name, () => new Set()).addAll(values);
+ var names = testRule.expression.evaluate(environment);
+ var expectations = names.map((name) => Expectation.byName(name));
+ _map.putIfAbsent(testRule.name, () => new Set()).addAll(expectations);
}
/**
@@ -177,7 +247,7 @@ class TestExpectations {
* components and checks that the anchored regular expression
* "^$keyComponent\$" matches the corresponding filename component.
*/
- Set<String> expectations(String filename) {
+ Set<Expectation> expectations(String filename) {
var result = new Set();
var splitFilename = filename.split('/');
@@ -198,7 +268,7 @@ class TestExpectations {
// If no expectations were found the expectation is that the test
// passes.
if (result.isEmpty) {
- result.add(PASS);
+ result.add(Expectation.PASS);
}
return result;
}

Powered by Google App Engine
This is Rietveld 408576698