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

Side by Side 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: Updated the Dart test runner to work with the file input stream changes 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library("status_file_parser"); 5 #library("status_file_parser");
6 6
7 7
8 #import("status_expression.dart"); 8 #import("status_expression.dart");
9 9
10 // Possible outcomes of running a test. 10 // Possible outcomes of running a test.
(...skipping 27 matching lines...) Expand all
38 // Helper method to be able to run the test from the runtime 38 // Helper method to be able to run the test from the runtime
39 // directory, or the top directory. 39 // directory, or the top directory.
40 String getFilename(String path) => 40 String getFilename(String path) =>
41 new File(path).existsSync() ? path : '../$path'; 41 new File(path).existsSync() ? path : '../$path';
42 42
43 String getDirname(String path) => 43 String getDirname(String path) =>
44 new Directory(path).existsSync() ? path : '../$path'; 44 new Directory(path).existsSync() ? path : '../$path';
45 45
46 void ReadTestExpectationsInto(TestExpectations expectations, 46 void ReadTestExpectationsInto(TestExpectations expectations,
47 String statusFilePath, 47 String statusFilePath,
48 environment) { 48 environment,
49 onDone) {
49 List<Section> sections = new List<Section>(); 50 List<Section> sections = new List<Section>();
50 ReadConfigurationInto(statusFilePath, sections);
51 51
52 for (Section section in sections) { 52 void sectionsRead() {
53 if (section.isEnabled(environment)) { 53 for (Section section in sections) {
54 for (var rule in section.testRules) { 54 if (section.isEnabled(environment)) {
55 expectations.addRule(rule, environment); 55 for (var rule in section.testRules) {
56 expectations.addRule(rule, environment);
57 }
56 } 58 }
57 } 59 }
60 onDone();
58 } 61 }
62
63 ReadConfigurationInto(statusFilePath, sections, sectionsRead);
59 } 64 }
60 65
61 void ReadConfigurationInto(path, sections) { 66 void ReadConfigurationInto(path, sections, onDone) {
62 File file = new File(getFilename(path)); 67 File file = new File(getFilename(path));
63 if (!file.existsSync()) return; // TODO(whesse): Handle missing file. 68 if (!file.existsSync()) return; // TODO(whesse): Handle missing file.
64 FileInputStream file_stream = file.openInputStream(); 69 FileInputStream file_stream = file.openInputStream();
65 StringInputStream lines = new StringInputStream(file_stream); 70 StringInputStream lines = new StringInputStream(file_stream);
66 71
67 Section current = new Section.always(); 72 Section current = new Section.always();
68 sections.add(current); 73 sections.add(current);
69 String prefix = ""; 74 String prefix = "";
70 75
76 lines.lineHandler = () {
71 String line; 77 String line;
Mads Ager (google) 2011/12/09 13:09:33 Indent line 77 to 113.
Søren Gjesse 2011/12/09 13:36:43 Done.
72 while ((line = lines.readLine()) != null) { 78 while ((line = lines.readLine()) != null) {
73 Match match = StripComment.firstMatch(line); 79 Match match = StripComment.firstMatch(line);
74 line = (match == null) ? "" : match[0]; 80 line = (match == null) ? "" : match[0];
75 line = line.trim(); 81 line = line.trim();
76 if (line.isEmpty()) continue; 82 if (line.isEmpty()) continue;
77 83
78 match = HeaderPattern.firstMatch(line); 84 match = HeaderPattern.firstMatch(line);
79 if (match != null) { 85 if (match != null) {
80 String condition_string = match[1].trim(); 86 String condition_string = match[1].trim();
81 List<String> tokens = new Tokenizer(condition_string).tokenize(); 87 List<String> tokens = new Tokenizer(condition_string).tokenize();
(...skipping 16 matching lines...) Expand all
98 } 104 }
99 105
100 match = PrefixPattern.firstMatch(line); 106 match = PrefixPattern.firstMatch(line);
101 if (match != null) { 107 if (match != null) {
102 prefix = match[1]; 108 prefix = match[1];
103 continue; 109 continue;
104 } 110 }
105 111
106 print("unmatched line: $line"); 112 print("unmatched line: $line");
107 } 113 }
114 };
108 115
109 file_stream.close(); 116 lines.closeHandler = () {
117 file_stream.close();
118 onDone();
119 };
110 } 120 }
111 121
112 122
113 class TestRule { 123 class TestRule {
114 String name; 124 String name;
115 SetExpression expression; 125 SetExpression expression;
116 126
117 TestRule(this.name, this.expression); 127 TestRule(this.name, this.expression);
118 } 128 }
119 129
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 244 }
235 regExps[i] = regExp; 245 regExps[i] = regExp;
236 } 246 }
237 _keyToRegExps[key] = regExps; 247 _keyToRegExps[key] = regExps;
238 }); 248 });
239 249
240 _regExpCache = null; 250 _regExpCache = null;
241 _preprocessed = true; 251 _preprocessed = true;
242 } 252 }
243 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698