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

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

Issue 8514003: tools/test.dart: Read test expectations from the status file, and pass them to the test runner. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Import library with PASS, FAIL, CRASH to TestRunnerTest Created 9 years, 1 month 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 43f3077f7165650640805ba68b74c7739ab6ca86..81b26068dc5b5beebbd10ab0e39da5bc8eb990bf 100644
--- a/tools/testing/dart/status_file_parser.dart
+++ b/tools/testing/dart/status_file_parser.dart
@@ -7,8 +7,16 @@
#import("status_expression.dart");
+// Possible outcomes of running a test.
+final CRASH = "Crash";
+final TIMEOUT = "Timeout";
+final FAIL = "Fail";
+final PASS = "Pass";
+// An indication to skip the test. The caller is responsible for skipping it.
+final SKIP = "Skip";
+
final RegExp StripComment = const RegExp("^[^#]*");
-final RegExp HeaderPattern = const RegExp(@"\[([^\]]+)\]");
+final RegExp HeaderPattern = const RegExp(@"^\[([^\]]+)\]");
final RegExp RulePattern = const RegExp(@"\s*([^: ]*)\s*:(.*)");
final RegExp PrefixPattern = const RegExp(@"^\s*prefix\s+([\w\_\.\-\/]+)\s*$");
@@ -16,10 +24,13 @@ final RegExp PrefixPattern = const RegExp(@"^\s*prefix\s+([\w\_\.\-\/]+)\s*$");
// structures for test configuration, including Section.
class Section {
BooleanExpression condition;
- Collection testSettings = const [];
+ List<TestRule> testRules;
+
+ Section.always() : condition = null, testRules = new List<TestRule>();
+ Section(this.condition) : testRules = new List<TestRule>();
- Section.always() : condition = null;
- Section(this.condition);
+ bool isEnabled(environment) =>
+ condition == null || condition.evaluate(environment);
Mads Ager (google) 2011/11/10 16:31:57 Could we make condition just be "true" or somethin
Bill Hesse 2011/11/10 16:44:45 No, constants or a built-in true are not part of t
}
@@ -30,8 +41,22 @@ String getFilename(String path) =>
String getDirname(String path) =>
new Directory(path).existsSync() ? path : '../$path';
-
+TestExpectationsMap ReadTestExpectations(String statusFilePath, environment) {
+ List<Section> sections = new List<Section>();
+ ReadConfigurationInto(statusFilePath, sections);
+
+ TestExpectationsMap map = new TestExpectationsMap();
+ for (Section section in sections) {
+ if (section.isEnabled(environment)) {
+ for (var rule in section.testRules) {
+ map.addTest(rule, environment);
+ }
+ }
+ }
+ return map;
+}
+
void ReadConfigurationInto(path, sections) {
File file = new File(getFilename(path));
if (!file.existsSync()) return; // TODO(whesse): Handle missing file.
@@ -61,12 +86,13 @@ void ReadConfigurationInto(path, sections) {
match = RulePattern.firstMatch(line);
if (match != null) {
- String path = prefix + match[1].trim();
+ String name = match[1].trim();
+ // TODO(whesse): Handle test names ending in a wildcard (*).
String expression_string = match[2].trim();
List<String> tokens = new Tokenizer(expression_string).tokenize();
SetExpression expression =
new ExpressionParser(new Scanner(tokens)).parseSetExpression();
- // TODO(whesse): Save rule in configuration data structure.
+ current.testRules.add(new TestRule(name, expression));
continue;
}
@@ -82,3 +108,37 @@ void ReadConfigurationInto(path, sections) {
file_stream.close();
}
+
+class TestRule {
+ String name;
+ SetExpression expression;
+
+ TestRule(this.name, this.expression);
+}
+
+
+class TestExpectationsMap {
+ Map<String, Set<String>> map;
+
+ TestExpectationsMap() : map = new Map<String, Set<String>>();
+
+ void addTest(testRule, environment) {
+ map[testRule.name] = testRule.expression.evaluate(environment);
+
+ // Debugging code.
Mads Ager (google) 2011/11/10 16:31:57 Remove this before committing?
Bill Hesse 2011/11/10 16:44:45 I'll just remove the comment. The output is quite
Bill Hesse 2011/11/14 10:08:05 Removed the whole thing. On 2011/11/10 16:44:45,
+ String name = testRule.name;
+ String expected = "";
+ map[name].forEach((value) { expected += value + " "; });
+ print("map[$name] = $expected");
+ }
+
+ Set<String> expectations(String filename) {
+ var result = map[filename];
+ return result != null ? result : new Set.from([PASS]);
+ }
+}
+
+
+Collection<String> ExpectationsFromFile(String fileName) {
Mads Ager (google) 2011/11/10 16:31:57 Unused I think? Remove?
Bill Hesse 2011/11/10 16:44:45 Done.
+ return new List<String>();
+}

Powered by Google App Engine
This is Rietveld 408576698