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

Side by Side Diff: tools/testing/dart/test_suite.dart

Issue 8773004: tools/test.dart: Add synchronization, so the process queue knows when all multitests are done. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « tools/testing/dart/multitest.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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("test_suite"); 5 #library("test_suite");
6 6
7 #import("status_file_parser.dart"); 7 #import("status_file_parser.dart");
8 #import("test_runner.dart"); 8 #import("test_runner.dart");
9 #import("multitest.dart"); 9 #import("multitest.dart");
10 10
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 } 122 }
123 123
124 124
125 class StandardTestSuite implements TestSuite { 125 class StandardTestSuite implements TestSuite {
126 Map configuration; 126 Map configuration;
127 String directoryPath; 127 String directoryPath;
128 List<String> statusFilePaths; 128 List<String> statusFilePaths;
129 Function doTest; 129 Function doTest;
130 Function doDone; 130 Function doDone;
131 int activeMultitests = 0;
132 bool listingDone = false;
131 String shellPath; 133 String shellPath;
132 TestExpectations testExpectations; 134 TestExpectations testExpectations;
133 135
134 StandardTestSuite(Map this.configuration, 136 StandardTestSuite(Map this.configuration,
135 String this.directoryPath, 137 String this.directoryPath,
136 List<String> this.statusFilePaths) { 138 List<String> this.statusFilePaths) {
137 shellPath = TestUtils.dartShellFileName(configuration) ; 139 shellPath = TestUtils.dartShellFileName(configuration) ;
138 } 140 }
139 141
140 142
141 void isTestFile(String filename) => filename.endsWith("Test.dart"); 143 void isTestFile(String filename) => filename.endsWith("Test.dart");
142 144
143 void listRecursively() => false; 145 void listRecursively() => false;
144 146
145 void complexStatusMatching() => false; 147 void complexStatusMatching() => false;
146 148
147 void forEachTest(Function onTest, [Function onDone = null]) { 149 void forEachTest(Function onTest, [Function onDone = null]) {
148 doTest = onTest; 150 doTest = onTest;
149 doDone = (ignore) => (onDone != null) ? onDone() : null; 151 doDone = (onDone != null) ? onDone : (() => null);
150 152
151 // Read test expectations from status files. 153 // Read test expectations from status files.
152 testExpectations = 154 testExpectations =
153 new TestExpectations(complexMatching: complexStatusMatching()); 155 new TestExpectations(complexMatching: complexStatusMatching());
154 for (var statusFilePath in statusFilePaths) { 156 for (var statusFilePath in statusFilePaths) {
155 ReadTestExpectationsInto(testExpectations, 157 ReadTestExpectationsInto(testExpectations,
156 statusFilePath, 158 statusFilePath,
157 configuration); 159 configuration);
158 } 160 }
159 161
160 processDirectory(); 162 processDirectory();
161 } 163 }
162 164
163 void processDirectory() { 165 void processDirectory() {
164 directoryPath = getDirname(directoryPath); 166 directoryPath = getDirname(directoryPath);
165 Directory dir = new Directory(directoryPath); 167 Directory dir = new Directory(directoryPath);
166 dir.errorHandler = (s) { 168 dir.errorHandler = (s) {
167 throw s; 169 throw s;
168 }; 170 };
169 dir.fileHandler = processFile; 171 dir.fileHandler = processFile;
170 dir.doneHandler = doDone; 172 dir.doneHandler = directoryListingDone;
171 dir.list(recursive: listRecursively()); 173 dir.list(recursive: listRecursively());
172 } 174 }
173 175
174 void processFile(String filename) { 176 void processFile(String filename) {
175 if (!isTestFile(filename)) return; 177 if (!isTestFile(filename)) return;
176 178
177 // If patterns are given only list the files that match one of the 179 // If patterns are given only list the files that match one of the
178 // patterns. 180 // patterns.
179 var patterns = configuration['patterns']; 181 var patterns = configuration['patterns'];
180 if (!patterns.isEmpty() && 182 if (!patterns.isEmpty() &&
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 args, 217 args,
216 timeout, 218 timeout,
217 completeHandler, 219 completeHandler,
218 expectations, 220 expectations,
219 isNegative)); 221 isNegative));
220 } 222 }
221 } 223 }
222 224
223 225
224 if (optionsFromFile['isMultitest']) { 226 if (optionsFromFile['isMultitest']) {
227 ++activeMultitests;
225 DoMultitest(filename, 228 DoMultitest(filename,
226 TestUtils.buildDir(configuration), 229 TestUtils.buildDir(configuration),
227 directoryPath, 230 directoryPath,
228 createTestCase); 231 createTestCase,
232 multitestDone);
229 } else { 233 } else {
230 createTestCase(filename, optionsFromFile['isNegative']); 234 createTestCase(filename, optionsFromFile['isNegative']);
231 } 235 }
232 } 236 }
233 237
238 void multitestDone() {
239 --activeMultitests;
240 if (activeMultitests == 0 && listingDone) {
241 doDone();
242 }
243 }
244
245 void directoryListingDone(ignore) {
246 listingDone = true;
247 if (activeMultitests == 0 && listingDone) {
Mads Ager (google) 2011/12/01 11:50:47 You don't need to check for listingDone here.
248 doDone();
249 }
250 }
251
234 void completeHandler(TestCase testCase) { 252 void completeHandler(TestCase testCase) {
235 } 253 }
236 254
237 255
238 List<List<String>> argumentListsFromFile(String filename, 256 List<List<String>> argumentListsFromFile(String filename,
239 Map optionsFromFile) { 257 Map optionsFromFile) {
240 List args = TestUtils.standardOptions(configuration); 258 List args = TestUtils.standardOptions(configuration);
241 259
242 bool isMultitest = optionsFromFile["isMultitest"]; 260 bool isMultitest = optionsFromFile["isMultitest"];
243 List<String> dartOptions = optionsFromFile["dartOptions"]; 261 List<String> dartOptions = optionsFromFile["dartOptions"];
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 args.add("--enable_leg"); 384 args.add("--enable_leg");
367 } 385 }
368 if (configuration["component"] == "dartc") { 386 if (configuration["component"] == "dartc") {
369 if (configuration["mode"] == "release") { 387 if (configuration["mode"] == "release") {
370 args.add("--optimize"); 388 args.add("--optimize");
371 } 389 }
372 } 390 }
373 return args; 391 return args;
374 } 392 }
375 } 393 }
OLDNEW
« no previous file with comments | « tools/testing/dart/multitest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698