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

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

Issue 9479034: Update test.dart for detection output of machine formatted errors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updates the multitest logic. Created 8 years, 9 months 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 5 /**
6 * Classes and methods for enumerating and preparing tests. 6 * Classes and methods for enumerating and preparing tests.
7 * 7 *
8 * This library includes: 8 * This library includes:
9 * 9 *
10 * - Creating tests by listing all the Dart files in certain directories, 10 * - Creating tests by listing all the Dart files in certain directories,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 void completeHandler(TestCase testCase) { 169 void completeHandler(TestCase testCase) {
170 } 170 }
171 } 171 }
172 172
173 173
174 class TestInformation { 174 class TestInformation {
175 String filename; 175 String filename;
176 Map optionsFromFile; 176 Map optionsFromFile;
177 bool isNegative; 177 bool isNegative;
178 bool isStaticClean;
179 bool hasStaticTypeAnnotations;
180 bool hasCompileTimeAnnotations;
178 bool isNegativeIfChecked; 181 bool isNegativeIfChecked;
179 bool hasFatalTypeErrors; 182 bool hasFatalTypeErrors;
180 bool hasRuntimeErrors; 183 bool hasRuntimeErrors;
184 // expected outcome from multi-test "static type error", "compile-time error" , etc
185 String multitestOutcome;
181 186
182 TestInformation(this.filename, this.optionsFromFile, this.isNegative, 187 TestInformation(this.filename, this.optionsFromFile, this.isNegative,
183 this.isNegativeIfChecked, this.hasFatalTypeErrors, 188 this.isNegativeIfChecked, this.hasFatalTypeErrors,
184 this.hasRuntimeErrors); 189 this.hasRuntimeErrors, this.multitestOutcome);
185 } 190 }
186 191
187 192
193 class AnnotatedError {
194 String type; // "runtime", "static type", or "compile-time"
195
196 }
197
188 /** 198 /**
189 * A standard [TestSuite] implementation that searches for tests in a 199 * A standard [TestSuite] implementation that searches for tests in a
190 * directory, and creates [TestCase]s that compile and/or run them. 200 * directory, and creates [TestCase]s that compile and/or run them.
191 */ 201 */
192 class StandardTestSuite implements TestSuite { 202 class StandardTestSuite implements TestSuite {
193 Map configuration; 203 Map configuration;
194 String suiteName; 204 String suiteName;
195 String directoryPath; 205 String directoryPath;
196 List<String> statusFilePaths; 206 List<String> statusFilePaths;
197 Function doTest; 207 Function doTest;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 directoryListingDone(false); 282 directoryListingDone(false);
273 } else { 283 } else {
274 dir.fileHandler = processFile; 284 dir.fileHandler = processFile;
275 dir.doneHandler = directoryListingDone; 285 dir.doneHandler = directoryListingDone;
276 dir.list(recursive: listRecursively()); 286 dir.list(recursive: listRecursively());
277 } 287 }
278 }; 288 };
279 dir.exists(); 289 dir.exists();
280 } 290 }
281 291
292
282 void enqueueTestCaseFromTestInformation(TestInformation info) { 293 void enqueueTestCaseFromTestInformation(TestInformation info) {
283 var filename = info.filename; 294 var filename = info.filename;
284 var optionsFromFile = info.optionsFromFile; 295 var optionsFromFile = info.optionsFromFile;
285 var isNegative = info.isNegative; 296 var isNegative = info.isNegative;
286 297
287 // Look up expectations in status files using a modified file path. 298 // Look up expectations in status files using a modified file path.
288 String testName; 299 String testName;
289 filename = filename.replaceAll('\\', '/'); 300 filename = filename.replaceAll('\\', '/');
290 301
291 // See if there's a 'src' directory inside the 'tests' one. 302 // See if there's a 'src' directory inside the 'tests' one.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 case 'dartium': 342 case 'dartium':
332 case 'chromium': 343 case 'chromium':
333 case 'frogium': 344 case 'frogium':
334 case 'webdriver': 345 case 'webdriver':
335 enqueueBrowserTest(filename, testName, optionsFromFile, 346 enqueueBrowserTest(filename, testName, optionsFromFile,
336 expectations, isNegative); 347 expectations, isNegative);
337 break; 348 break;
338 default: 349 default:
339 isNegative = isNegative || 350 isNegative = isNegative ||
340 (configuration['checked'] && info.isNegativeIfChecked); 351 (configuration['checked'] && info.isNegativeIfChecked);
341 bool enableFatalTypeErrors = false;
342 352
343 if (configuration['component'] == 'dartc') { 353 if (configuration['component'] == 'dartc') {
344 // Only dartc supports fatal type errors. Enable fatal type 354 // dartc can detect static type errors by the
345 // errors with a flag and treat tests that have fatal type 355 // format of the rror line
346 // errors as negative.
347 // Also, tests that have runtime errors are not negative
348 // tests for dartc because dartc does not execute the test.
349 if (info.hasFatalTypeErrors) { 356 if (info.hasFatalTypeErrors) {
350 enableFatalTypeErrors = true;
351 isNegative = true; 357 isNegative = true;
352 } else if (info.hasRuntimeErrors) { 358 } else if (info.hasRuntimeErrors) {
353 isNegative = false; 359 isNegative = false;
354 } 360 }
355 } 361 }
356 362
357 var argumentLists = argumentListsFromFile(filename, 363 var argumentLists = argumentListsFromFile(filename,
358 optionsFromFile, 364 optionsFromFile);
359 enableFatalTypeErrors);
360 365
361 for (var args in argumentLists) { 366 for (var args in argumentLists) {
362 doTest(new TestCase('$suiteName/$testName', 367 doTest(new TestCase('$suiteName/$testName',
363 [new Command(shellPath(), args)], 368 [new Command(shellPath(), args)],
364 configuration, 369 configuration,
365 completeHandler, 370 completeHandler,
366 expectations, 371 expectations,
367 isNegative)); 372 isNegative,
373 info));
368 } 374 }
369 } 375 }
370 } 376 }
371 377
372 Function makeTestCaseCreator(Map optionsFromFile) { 378 Function makeTestCaseCreator(Map optionsFromFile) {
373 return (String filename, 379 return (String filename,
374 bool isNegative, 380 bool isNegative,
375 [bool isNegativeIfChecked = false, 381 [bool isNegativeIfChecked = false,
376 bool hasFatalTypeErrors = false, 382 bool hasFatalTypeErrors = false,
377 bool hasRuntimeErrors = false]) { 383 bool hasRuntimeErrors = false,
384 String multitestOutcome = null]) {
378 // Cache the test information for each test case. 385 // Cache the test information for each test case.
379 var info = new TestInformation(filename, 386 var info = new TestInformation(filename,
380 optionsFromFile, 387 optionsFromFile,
381 isNegative, 388 isNegative,
382 isNegativeIfChecked, 389 isNegativeIfChecked,
383 hasFatalTypeErrors, 390 hasFatalTypeErrors,
384 hasRuntimeErrors); 391 hasRuntimeErrors,
392 multitestOutcome);
385 cachedTests.add(info); 393 cachedTests.add(info);
386 enqueueTestCaseFromTestInformation(info); 394 enqueueTestCaseFromTestInformation(info);
387 }; 395 };
388 } 396 }
389 397
390 void processFile(String filename) { 398 void processFile(String filename) {
391 if (!isTestFile(filename)) return; 399 if (!isTestFile(filename)) return;
392 400
393 // Only run the tests that match the pattern. 401 // Only run the tests that match the pattern.
394 RegExp pattern = configuration['selectors'][suiteName]; 402 RegExp pattern = configuration['selectors'][suiteName];
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 listingDone = true; 734 listingDone = true;
727 if (activeTestGenerators == 0) { 735 if (activeTestGenerators == 0) {
728 doDone(); 736 doDone();
729 } 737 }
730 } 738 }
731 739
732 void completeHandler(TestCase testCase) { 740 void completeHandler(TestCase testCase) {
733 } 741 }
734 742
735 List<List<String>> argumentListsFromFile(String filename, 743 List<List<String>> argumentListsFromFile(String filename,
736 Map optionsFromFile, 744 Map optionsFromFile) {
737 bool enableFatalTypeErrors) {
738 List args = TestUtils.standardOptions(configuration); 745 List args = TestUtils.standardOptions(configuration);
739 args.addAll(additionalOptions(filename)); 746 args.addAll(additionalOptions(filename));
740 if (enableFatalTypeErrors && configuration['component'] == 'dartc') { 747 if (configuration['component'] == 'dartc') {
741 args.add('--fatal-type-errors'); 748 args.add('--error_format');
749 args.add('machine');
742 } 750 }
743 751
744 bool isMultitest = optionsFromFile["isMultitest"]; 752 bool isMultitest = optionsFromFile["isMultitest"];
745 List<String> dartOptions = optionsFromFile["dartOptions"]; 753 List<String> dartOptions = optionsFromFile["dartOptions"];
746 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"]; 754 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"];
747 Expect.isTrue(!isMultitest || dartOptions == null); 755 Expect.isTrue(!isMultitest || dartOptions == null);
748 if (dartOptions == null) { 756 if (dartOptions == null) {
749 args.add(filename); 757 args.add(filename);
750 } else { 758 } else {
751 var executable_name = dartOptions[0]; 759 var executable_name = dartOptions[0];
(...skipping 16 matching lines...) Expand all
768 } 776 }
769 777
770 return result; 778 return result;
771 } 779 }
772 780
773 Map readOptionsFromFile(String filename) { 781 Map readOptionsFromFile(String filename) {
774 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); 782 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)");
775 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); 783 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)");
776 RegExp otherScriptsRegExp = const RegExp(@"// OtherScripts=(.*)"); 784 RegExp otherScriptsRegExp = const RegExp(@"// OtherScripts=(.*)");
777 RegExp multiTestRegExp = const RegExp(@"/// [0-9][0-9]:(.*)"); 785 RegExp multiTestRegExp = const RegExp(@"/// [0-9][0-9]:(.*)");
786 RegExp staticTypeRegExp = const RegExp(@"/// ([0-9][0-9]:){0,1}\s*static typ e error");
787 RegExp compileTimeRegExp = const RegExp(@"/// ([0-9][0-9]:){0,1}\s*compile-t ime error");
778 RegExp leadingHashRegExp = const RegExp(@"^#", multiLine: true); 788 RegExp leadingHashRegExp = const RegExp(@"^#", multiLine: true);
779 RegExp isolateStubsRegExp = const RegExp(@"// IsolateStubs=(.*)"); 789 RegExp isolateStubsRegExp = const RegExp(@"// IsolateStubs=(.*)");
780 RegExp domImportRegExp = 790 RegExp domImportRegExp =
781 const RegExp(@"^#import.*(dart:(dom|html)|html\.dart).*\)", 791 const RegExp(@"^#import.*(dart:(dom|html)|html\.dart).*\)",
782 multiLine: true); 792 multiLine: true);
783 RegExp libraryDefinitionRegExp = 793 RegExp libraryDefinitionRegExp =
784 const RegExp(@"^#library\(", multiLine: true); 794 const RegExp(@"^#library\(", multiLine: true);
785 RegExp sourceOrImportRegExp = 795 RegExp sourceOrImportRegExp =
786 const RegExp(@"^#(source|import)\(", multiLine: true); 796 const RegExp(@"^#(source|import)\(", multiLine: true);
787 797
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 List<String> otherScripts = new List<String>(); 831 List<String> otherScripts = new List<String>();
822 matches = otherScriptsRegExp.allMatches(contents); 832 matches = otherScriptsRegExp.allMatches(contents);
823 for (var match in matches) { 833 for (var match in matches) {
824 otherScripts.addAll(match[1].split(' ').filter((e) => e != '')); 834 otherScripts.addAll(match[1].split(' ').filter((e) => e != ''));
825 } 835 }
826 836
827 if (contents.contains("@compile-error") || 837 if (contents.contains("@compile-error") ||
828 contents.contains("@runtime-error")) { 838 contents.contains("@runtime-error")) {
829 isNegative = true; 839 isNegative = true;
830 } 840 }
841 if (contents.contains("@static-clean")) {
842 isStaticClean = true;
843 }
831 844
832 bool isMultitest = multiTestRegExp.hasMatch(contents); 845 bool isMultitest = multiTestRegExp.hasMatch(contents);
833 bool containsLeadingHash = leadingHashRegExp.hasMatch(contents); 846 bool containsLeadingHash = leadingHashRegExp.hasMatch(contents);
834 Match isolateMatch = isolateStubsRegExp.firstMatch(contents); 847 Match isolateMatch = isolateStubsRegExp.firstMatch(contents);
835 String isolateStubs = isolateMatch != null ? isolateMatch[1] : ''; 848 String isolateStubs = isolateMatch != null ? isolateMatch[1] : '';
836 bool containsDomImport = domImportRegExp.hasMatch(contents); 849 bool containsDomImport = domImportRegExp.hasMatch(contents);
837 bool isLibraryDefinition = libraryDefinitionRegExp.hasMatch(contents); 850 bool isLibraryDefinition = libraryDefinitionRegExp.hasMatch(contents);
838 bool containsSourceOrImport = sourceOrImportRegExp.hasMatch(contents); 851 bool containsSourceOrImport = sourceOrImportRegExp.hasMatch(contents);
839 852 int numStaticTypeAnnotations = 0;
853 for (var i in staticTypeRegExp.allMatches(contents)) {
854 numStaticTypeAnnotations++;
855 }
856 int numCompileTimeAnnotations = 0;
857 for (var i in compileTimeRegExp.allMatches(contents)) {
858 numCompileTimeAnnotations++;
859 }
840 860
841 return { "vmOptions": result, 861 return { "vmOptions": result,
842 "dartOptions": dartOptions, 862 "dartOptions": dartOptions,
843 "isNegative": isNegative, 863 "isNegative": isNegative,
844 "otherScripts": otherScripts, 864 "otherScripts": otherScripts,
845 "isMultitest": isMultitest, 865 "isMultitest": isMultitest,
846 "containsLeadingHash" : containsLeadingHash, 866 "containsLeadingHash": containsLeadingHash,
847 "isolateStubs" : isolateStubs, 867 "isolateStubs": isolateStubs,
848 "containsDomImport": containsDomImport, 868 "containsDomImport": containsDomImport,
849 "isLibraryDefinition": isLibraryDefinition, 869 "isLibraryDefinition": isLibraryDefinition,
850 "containsSourceOrImport": containsSourceOrImport }; 870 "containsSourceOrImport": containsSourceOrImport,
871 "numStaticTypeAnnotations": numStaticTypeAnnotations,
872 "numCompileTimeAnnotations": numCompileTimeAnnotations};
851 } 873 }
852 } 874 }
853 875
854 876
855 class DartcCompilationTestSuite extends StandardTestSuite { 877 class DartcCompilationTestSuite extends StandardTestSuite {
856 List<String> _testDirs; 878 List<String> _testDirs;
857 int activityCount = 0; 879 int activityCount = 0;
858 880
859 DartcCompilationTestSuite(Map configuration, 881 DartcCompilationTestSuite(Map configuration,
860 String suiteName, 882 String suiteName,
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 * $noCrash tests are expected to be flaky but not crash 1193 * $noCrash tests are expected to be flaky but not crash
1172 * $pass tests are expected to pass 1194 * $pass tests are expected to pass
1173 * $failOk tests are expected to fail that we won't fix 1195 * $failOk tests are expected to fail that we won't fix
1174 * $fail tests are expected to fail that we should fix 1196 * $fail tests are expected to fail that we should fix
1175 * $crash tests are expected to crash that we should fix 1197 * $crash tests are expected to crash that we should fix
1176 * $timeout tests are allowed to timeout 1198 * $timeout tests are allowed to timeout
1177 """; 1199 """;
1178 print(report); 1200 print(report);
1179 } 1201 }
1180 } 1202 }
OLDNEW
« tools/testing/dart/test_runner.dart ('K') | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698