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

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

Issue 8817017: Support actual stub generation in the dart test scripts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. 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 | « tests/stub-generator/test_config.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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 125
126 126
127 class StandardTestSuite implements TestSuite { 127 class StandardTestSuite implements TestSuite {
128 Map configuration; 128 Map configuration;
129 String suiteName; 129 String suiteName;
130 String directoryPath; 130 String directoryPath;
131 List<String> statusFilePaths; 131 List<String> statusFilePaths;
132 Function doTest; 132 Function doTest;
133 Function doDone; 133 Function doDone;
134 int activeMultitests = 0; 134 int activeTestGenerators = 0;
135 bool listingDone = false; 135 bool listingDone = false;
136 TestExpectations testExpectations; 136 TestExpectations testExpectations;
137 137
138 StandardTestSuite(Map this.configuration, 138 StandardTestSuite(Map this.configuration,
139 String this.suiteName, 139 String this.suiteName,
140 String this.directoryPath, 140 String this.directoryPath,
141 List<String> this.statusFilePaths); 141 List<String> this.statusFilePaths);
142 142
143 void isTestFile(String filename) => filename.endsWith("Test.dart"); 143 void isTestFile(String filename) => filename.endsWith("Test.dart");
144 144
(...skipping 25 matching lines...) Expand all
170 directoryPath = getDirname(directoryPath); 170 directoryPath = getDirname(directoryPath);
171 Directory dir = new Directory(directoryPath); 171 Directory dir = new Directory(directoryPath);
172 dir.errorHandler = (s) { 172 dir.errorHandler = (s) {
173 throw s; 173 throw s;
174 }; 174 };
175 dir.fileHandler = processFile; 175 dir.fileHandler = processFile;
176 dir.doneHandler = directoryListingDone; 176 dir.doneHandler = directoryListingDone;
177 dir.list(recursive: listRecursively()); 177 dir.list(recursive: listRecursively());
178 } 178 }
179 179
180 void processFile(String filename) { 180 Function makeTestCaseCreator(Map optionsFromFile, int timeout) {
181 if (!isTestFile(filename)) return; 181 return (String filename,
182 182 bool isNegative,
183 // Only run the tests that match the pattern. 183 [bool isNegativeIfChecked = false,
184 RegExp pattern = configuration['selectors'][suiteName]; 184 bool enableFatalTypeErrors = false]) {
185 if (!pattern.hasMatch(filename)) return;
186
187 var timeout = configuration['timeout'];
188 var optionsFromFile = optionsFromFile(filename);
189
190 Function createTestCase(String filename,
191 bool isNegative,
192 [bool isNegativeIfChecked = false,
193 bool enableFatalTypeErrors = false]) {
194 // Look up expectations in status files using a modified file path. 185 // Look up expectations in status files using a modified file path.
195 String pathSeparator = new Platform().pathSeparator(); 186 String pathSeparator = new Platform().pathSeparator();
196 String testName; 187 String testName;
197 int start = filename.lastIndexOf('src' + pathSeparator); 188 int start = filename.lastIndexOf('src' + pathSeparator);
198 if (start != -1) { 189 if (start != -1) {
199 testName = filename.substring(start + 4, filename.length - 5); 190 testName = filename.substring(start + 4, filename.length - 5);
200 } else if (optionsFromFile['isMultitest']) { 191 } else if (optionsFromFile['isMultitest']) {
201 start = filename.lastIndexOf(pathSeparator); 192 start = filename.lastIndexOf(pathSeparator);
202 int middle = filename.lastIndexOf('_'); 193 int middle = filename.lastIndexOf('_');
203 testName = filename.substring(start + 1, middle) + pathSeparator + 194 testName = filename.substring(start + 1, middle) + pathSeparator +
(...skipping 24 matching lines...) Expand all
228 enableFatalTypeErrors); 219 enableFatalTypeErrors);
229 for (var args in argumentLists) { 220 for (var args in argumentLists) {
230 doTest(new TestCase(testName, 221 doTest(new TestCase(testName,
231 shellPath(), 222 shellPath(),
232 args, 223 args,
233 timeout, 224 timeout,
234 completeHandler, 225 completeHandler,
235 expectations, 226 expectations,
236 isNegative)); 227 isNegative));
237 } 228 }
238 } 229 };
230 }
231
232 void processFile(String filename) {
233 if (!isTestFile(filename)) return;
234
235 // Only run the tests that match the pattern.
236 RegExp pattern = configuration['selectors'][suiteName];
237 if (!pattern.hasMatch(filename)) return;
238
239 var optionsFromFile = optionsFromFile(filename);
240 var timeout = configuration['timeout'];
241 Function createTestCase = makeTestCaseCreator(optionsFromFile, timeout);
239 242
240 if (optionsFromFile['isMultitest']) { 243 if (optionsFromFile['isMultitest']) {
241 bool supportsFatalTypeErrors = (configuration['component'] == 'dartc'); 244 bool supportsFatalTypeErrors = (configuration['component'] == 'dartc');
242 ++activeMultitests; 245 testGeneratorStarted();
243 DoMultitest(filename, 246 DoMultitest(filename,
244 TestUtils.buildDir(configuration), 247 TestUtils.buildDir(configuration),
245 directoryPath, 248 directoryPath,
246 supportsFatalTypeErrors, 249 supportsFatalTypeErrors,
247 createTestCase, 250 createTestCase,
248 multitestDone); 251 testGeneratorDone);
249 } else { 252 } else {
250 createTestCase(filename, optionsFromFile['isNegative']); 253 createTestCase(filename, optionsFromFile['isNegative']);
251 } 254 }
252 } 255 }
253 256
254 void multitestDone() { 257 void testGeneratorStarted() {
255 --activeMultitests; 258 ++activeTestGenerators;
256 if (activeMultitests == 0 && listingDone) { 259 }
260
261 void testGeneratorDone() {
262 --activeTestGenerators;
263 if (activeTestGenerators == 0 && listingDone) {
257 doDone(); 264 doDone();
258 } 265 }
259 } 266 }
260 267
261 void directoryListingDone(ignore) { 268 void directoryListingDone(ignore) {
262 listingDone = true; 269 listingDone = true;
263 if (activeMultitests == 0) { 270 if (activeTestGenerators == 0) {
264 doDone(); 271 doDone();
265 } 272 }
266 } 273 }
267 274
268 void completeHandler(TestCase testCase) { 275 void completeHandler(TestCase testCase) {
269 } 276 }
270 277
271 List<List<String>> argumentListsFromFile(String filename, 278 List<List<String>> argumentListsFromFile(String filename,
272 Map optionsFromFile, 279 Map optionsFromFile,
273 bool enableFatalTypeErrors) { 280 bool enableFatalTypeErrors) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 } 312 }
306 313
307 return result; 314 return result;
308 } 315 }
309 316
310 Map optionsFromFile(String filename) { 317 Map optionsFromFile(String filename) {
311 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); 318 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)");
312 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); 319 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)");
313 RegExp multiTestRegExp = const RegExp(@"/// [0-9][0-9]:(.*)"); 320 RegExp multiTestRegExp = const RegExp(@"/// [0-9][0-9]:(.*)");
314 RegExp leadingHashRegExp = const RegExp(@"^#", multiLine: true); 321 RegExp leadingHashRegExp = const RegExp(@"^#", multiLine: true);
322 RegExp isolateStubsRegExp = const RegExp(@"// IsolateStubs=(.*)");
315 323
316 // Read the entire file into a byte buffer and transform it to a 324 // Read the entire file into a byte buffer and transform it to a
317 // String. This will treat the file as ascii but the only parts 325 // String. This will treat the file as ascii but the only parts
318 // we are interested in will be ascii in any case. 326 // we are interested in will be ascii in any case.
319 File file = new File(filename); 327 File file = new File(filename);
320 file.openSync(); 328 file.openSync();
321 List chars = new List(file.lengthSync()); 329 List chars = new List(file.lengthSync());
322 var offset = 0; 330 var offset = 0;
323 while (offset != chars.length) { 331 while (offset != chars.length) {
324 offset += file.readListSync(chars, offset, chars.length - offset); 332 offset += file.readListSync(chars, offset, chars.length - offset);
(...skipping 25 matching lines...) Expand all
350 if (contents.contains("@compile-error") || 358 if (contents.contains("@compile-error") ||
351 contents.contains("@runtime-error")) { 359 contents.contains("@runtime-error")) {
352 isNegative = true; 360 isNegative = true;
353 } else if (contents.contains("@dynamic-type-error") && 361 } else if (contents.contains("@dynamic-type-error") &&
354 configuration['checked']) { 362 configuration['checked']) {
355 isNegative = true; 363 isNegative = true;
356 } 364 }
357 365
358 bool isMultitest = multiTestRegExp.hasMatch(contents); 366 bool isMultitest = multiTestRegExp.hasMatch(contents);
359 bool containsLeadingHash = leadingHashRegExp.hasMatch(contents); 367 bool containsLeadingHash = leadingHashRegExp.hasMatch(contents);
368 Match isolateMatch = isolateStubsRegExp.firstMatch(contents);
369 String isolateStubs = isolateMatch != null ? isolateMatch[1] : '';
360 370
361 return { "vmOptions": result, 371 return { "vmOptions": result,
362 "dartOptions": dartOptions, 372 "dartOptions": dartOptions,
363 "isNegative": isNegative, 373 "isNegative": isNegative,
364 "isMultitest": isMultitest, 374 "isMultitest": isMultitest,
365 "containsLeadingHash" : containsLeadingHash }; 375 "containsLeadingHash" : containsLeadingHash,
376 "isolateStubs" : isolateStubs };
366 } 377 }
367 } 378 }
368 379
369 380
370 class DartcCompilationTestSuite extends StandardTestSuite { 381 class DartcCompilationTestSuite extends StandardTestSuite {
371 List<String> _testDirs; 382 List<String> _testDirs;
372 int activityCount = 0; 383 int activityCount = 0;
373 384
374 DartcCompilationTestSuite(Map configuration, 385 DartcCompilationTestSuite(Map configuration,
375 String suiteName, 386 String suiteName,
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 * $noCrash tests are expected to be flaky but not crash 543 * $noCrash tests are expected to be flaky but not crash
533 * $pass tests are expected to pass 544 * $pass tests are expected to pass
534 * $failOk tests are expected to fail that we won't fix 545 * $failOk tests are expected to fail that we won't fix
535 * $fail tests are expected to fail that we should fix 546 * $fail tests are expected to fail that we should fix
536 * $crash tests are expected to crash that we should fix 547 * $crash tests are expected to crash that we should fix
537 * $timeout tests are allowed to timeout\ 548 * $timeout tests are allowed to timeout\
538 """; 549 """;
539 print(report); 550 print(report);
540 } 551 }
541 } 552 }
OLDNEW
« no previous file with comments | « tests/stub-generator/test_config.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698