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

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

Issue 8885032: Improve the event handling for string input stream (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebased Created 9 years 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 | « tests/stub-generator/test_config.dart ('k') | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 38afda6fbe2979e3e53933548a05c61d3cc86d75..c29f9f584a4ff8f45f4330a9b52479ada8d1cbd6 100644
--- a/tools/testing/dart/status_file_parser.dart
+++ b/tools/testing/dart/status_file_parser.dart
@@ -45,20 +45,25 @@ String getDirname(String path) =>
void ReadTestExpectationsInto(TestExpectations expectations,
String statusFilePath,
- environment) {
+ environment,
+ onDone) {
List<Section> sections = new List<Section>();
- ReadConfigurationInto(statusFilePath, sections);
- for (Section section in sections) {
- if (section.isEnabled(environment)) {
- for (var rule in section.testRules) {
- expectations.addRule(rule, environment);
+ void sectionsRead() {
+ for (Section section in sections) {
+ if (section.isEnabled(environment)) {
+ for (var rule in section.testRules) {
+ expectations.addRule(rule, environment);
+ }
}
}
+ onDone();
}
+
+ ReadConfigurationInto(statusFilePath, sections, sectionsRead);
}
-void ReadConfigurationInto(path, sections) {
+void ReadConfigurationInto(path, sections, onDone) {
File file = new File(getFilename(path));
if (!file.existsSync()) return; // TODO(whesse): Handle missing file.
FileInputStream file_stream = file.openInputStream();
@@ -68,45 +73,50 @@ void ReadConfigurationInto(path, sections) {
sections.add(current);
String prefix = "";
- String line;
- while ((line = lines.readLine()) != null) {
- Match match = StripComment.firstMatch(line);
- line = (match == null) ? "" : match[0];
- line = line.trim();
- if (line.isEmpty()) continue;
-
- match = HeaderPattern.firstMatch(line);
- if (match != null) {
- String condition_string = match[1].trim();
- List<String> tokens = new Tokenizer(condition_string).tokenize();
- ExpressionParser parser = new ExpressionParser(new Scanner(tokens));
- current = new Section(parser.parseBooleanExpression());
- sections.add(current);
- continue;
- }
+ lines.lineHandler = () {
+ String line;
+ while ((line = lines.readLine()) != null) {
+ Match match = StripComment.firstMatch(line);
+ line = (match == null) ? "" : match[0];
+ line = line.trim();
+ if (line.isEmpty()) continue;
+
+ match = HeaderPattern.firstMatch(line);
+ if (match != null) {
+ String condition_string = match[1].trim();
+ List<String> tokens = new Tokenizer(condition_string).tokenize();
+ ExpressionParser parser = new ExpressionParser(new Scanner(tokens));
+ current = new Section(parser.parseBooleanExpression());
+ sections.add(current);
+ continue;
+ }
- match = RulePattern.firstMatch(line);
- if (match != null) {
- 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();
- current.testRules.add(new TestRule(name, expression));
- continue;
- }
+ match = RulePattern.firstMatch(line);
+ if (match != null) {
+ 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();
+ current.testRules.add(new TestRule(name, expression));
+ continue;
+ }
- match = PrefixPattern.firstMatch(line);
- if (match != null) {
- prefix = match[1];
- continue;
- }
+ match = PrefixPattern.firstMatch(line);
+ if (match != null) {
+ prefix = match[1];
+ continue;
+ }
- print("unmatched line: $line");
- }
+ print("unmatched line: $line");
+ }
+ };
- file_stream.close();
+ lines.closeHandler = () {
+ file_stream.close();
+ onDone();
+ };
}
« no previous file with comments | « tests/stub-generator/test_config.dart ('k') | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698