| OLD | NEW |
| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 221 } |
| 222 | 222 |
| 223 void enqueueTestCaseFromTestInformation(TestInformation info) { | 223 void enqueueTestCaseFromTestInformation(TestInformation info) { |
| 224 var filename = info.filename; | 224 var filename = info.filename; |
| 225 var optionsFromFile = info.optionsFromFile; | 225 var optionsFromFile = info.optionsFromFile; |
| 226 var isNegative = info.isNegative; | 226 var isNegative = info.isNegative; |
| 227 | 227 |
| 228 // Look up expectations in status files using a modified file path. | 228 // Look up expectations in status files using a modified file path. |
| 229 String testName; | 229 String testName; |
| 230 filename = filename.replaceAll('\\', '/'); | 230 filename = filename.replaceAll('\\', '/'); |
| 231 |
| 232 // See if there's a 'src' directory inside the 'tests' one. |
| 233 int testsStart = filename.lastIndexOf('tests/'); |
| 231 int start = filename.lastIndexOf('src/'); | 234 int start = filename.lastIndexOf('src/'); |
| 232 if (start != -1) { | 235 if (start > testsStart) { |
| 233 testName = filename.substring(start + 4, filename.length - 5); | 236 testName = filename.substring(start + 4, filename.length - 5); |
| 234 } else if (optionsFromFile['isMultitest']) { | 237 } else if (optionsFromFile['isMultitest']) { |
| 235 start = filename.lastIndexOf('/'); | 238 start = filename.lastIndexOf('/'); |
| 236 int middle = filename.lastIndexOf('_'); | 239 int middle = filename.lastIndexOf('_'); |
| 237 testName = filename.substring(start + 1, middle) + '/' + | 240 testName = filename.substring(start + 1, middle) + '/' + |
| 238 filename.substring(middle + 1, filename.length - 5); | 241 filename.substring(middle + 1, filename.length - 5); |
| 239 } else { | 242 } else { |
| 240 // This case is hit by the dartc client compilation | 243 // This case is hit by the dartc client compilation |
| 241 // tests. These tests are pretty broken compared to the | 244 // tests. These tests are pretty broken compared to the |
| 242 // rest. They use the .dart suffix in the status files. They | 245 // rest. They use the .dart suffix in the status files. They |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 testGeneratorStarted(); | 331 testGeneratorStarted(); |
| 329 DoMultitest(filename, | 332 DoMultitest(filename, |
| 330 TestUtils.outputDir(configuration), | 333 TestUtils.outputDir(configuration), |
| 331 directoryPath, | 334 directoryPath, |
| 332 createTestCase, | 335 createTestCase, |
| 333 testGeneratorDone); | 336 testGeneratorDone); |
| 334 } else { | 337 } else { |
| 335 createTestCase(filename, optionsFromFile['isNegative']); | 338 createTestCase(filename, optionsFromFile['isNegative']); |
| 336 } | 339 } |
| 337 } | 340 } |
| 338 | 341 |
| 339 void enqueueBrowserTest(String filename, | 342 void enqueueBrowserTest(String filename, |
| 340 String testName, | 343 String testName, |
| 341 Map optionsFromFile, | 344 Map optionsFromFile, |
| 342 Set<String> expectations, | 345 Set<String> expectations, |
| 343 bool isNegative) { | 346 bool isNegative) { |
| 344 if (optionsFromFile['isMultitest']) return; | 347 if (optionsFromFile['isMultitest']) return; |
| 345 bool isWebTest = optionsFromFile['containsDomImport']; | 348 bool isWebTest = optionsFromFile['containsDomImport']; |
| 346 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; | 349 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; |
| 347 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { | 350 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { |
| 348 print('Warning for $filename: Browser tests require #library ' + | 351 print('Warning for $filename: Browser tests require #library ' + |
| 349 'in any file that uses #import or #source'); | 352 'in any file that uses #import or #source'); |
| 350 } | 353 } |
| 351 | 354 |
| 352 final String component = configuration['component']; | 355 final String component = configuration['component']; |
| 353 final String testPath = new File(filename).fullPathSync(); | 356 final String testPath = new File(filename).fullPathSync(); |
| 354 String dartDir = new File('.').fullPathSync(); | 357 String dartDir = new File('.').fullPathSync(); |
| 355 if (!testPath.startsWith(dartDir) || | 358 if (!testPath.startsWith(dartDir) || |
| 356 dartDir.endsWith('/frog')) { | 359 dartDir.endsWith('/frog')) { |
| 357 dartDir = new File('..').fullPathSync(); | 360 dartDir = new File('..').fullPathSync(); |
| 358 if (!testPath.startsWith(dartDir)) { | 361 if (!testPath.startsWith(dartDir)) { |
| 359 print('Run test.dart from the dart directory or' + | 362 print('Run test.dart from the dart directory or' + |
| 360 ' an immediate subdirectory only.'); | 363 ' an immediate subdirectory only.'); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 389 // or indirectly through test_as_library.dart, if it is not. | 392 // or indirectly through test_as_library.dart, if it is not. |
| 390 String dartLibraryFilename; | 393 String dartLibraryFilename; |
| 391 if (isLibraryDefinition) { | 394 if (isLibraryDefinition) { |
| 392 dartLibraryFilename = testPath; | 395 dartLibraryFilename = testPath; |
| 393 } else { | 396 } else { |
| 394 dartLibraryFilename = 'test_as_library.dart'; | 397 dartLibraryFilename = 'test_as_library.dart'; |
| 395 File file = new File('${tempDir.path}/$dartLibraryFilename'); | 398 File file = new File('${tempDir.path}/$dartLibraryFilename'); |
| 396 RandomAccessFile dartLibrary = file.openSync(FileMode.WRITE); | 399 RandomAccessFile dartLibrary = file.openSync(FileMode.WRITE); |
| 397 dartLibrary.writeStringSync(WrapDartTestInLibrary(testPath)); | 400 dartLibrary.writeStringSync(WrapDartTestInLibrary(testPath)); |
| 398 dartLibrary.closeSync(); | 401 dartLibrary.closeSync(); |
| 399 } | 402 } |
| 400 | 403 |
| 401 File file = new File(dartWrapperFilename); | 404 File file = new File(dartWrapperFilename); |
| 402 RandomAccessFile dartWrapper = file.openSync(FileMode.WRITE); | 405 RandomAccessFile dartWrapper = file.openSync(FileMode.WRITE); |
| 403 dartWrapper.writeStringSync(DartTestWrapper( | 406 dartWrapper.writeStringSync(DartTestWrapper( |
| 404 domLibraryImport, | 407 domLibraryImport, |
| 405 '$dartDir/tests/isolate/src/TestFramework.dart', | 408 '$dartDir/tests/isolate/src/TestFramework.dart', |
| 406 dartLibraryFilename)); | 409 dartLibraryFilename)); |
| 407 dartWrapper.closeSync(); | 410 dartWrapper.closeSync(); |
| 408 } else { | 411 } else { |
| 409 dartWrapperFilename = testPath; | 412 dartWrapperFilename = testPath; |
| 410 // TODO(whesse): Once test.py is retired, adjust the relative path in | 413 // TODO(whesse): Once test.py is retired, adjust the relative path in |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 case 'internet-explorer': | 476 case 'internet-explorer': |
| 474 browserFlag = 'ie'; | 477 browserFlag = 'ie'; |
| 475 break; | 478 break; |
| 476 case 'safari': | 479 case 'safari': |
| 477 browserFlag = 'safari'; | 480 browserFlag = 'safari'; |
| 478 break; | 481 break; |
| 479 } | 482 } |
| 480 } | 483 } |
| 481 } | 484 } |
| 482 args = ['--out', htmlPath, '--browser', browserFlag]; | 485 args = ['--out', htmlPath, '--browser', browserFlag]; |
| 483 | 486 |
| 484 } else { | 487 } else { |
| 485 args = ['--no-timeout']; | 488 args = ['--no-timeout']; |
| 486 if (component == 'dartium') { | 489 if (component == 'dartium') { |
| 487 var dartFlags = ['--enable_asserts', | 490 var dartFlags = ['--enable_asserts', |
| 488 '--enable_type_checks', | 491 '--enable_type_checks', |
| 489 '--ignore-unrecognized-flags']; | 492 '--ignore-unrecognized-flags']; |
| 490 dartFlags.addAll(vmOptions); | 493 dartFlags.addAll(vmOptions); |
| 491 args.add('--dart-flags=${Strings.join(dartFlags, " ")}'); | 494 args.add('--dart-flags=${Strings.join(dartFlags, " ")}'); |
| 492 } | 495 } |
| 493 args.add(htmlPath); | 496 args.add(htmlPath); |
| 494 } | 497 } |
| 495 // Create BrowserTestCase and queue it. | 498 // Create BrowserTestCase and queue it. |
| 496 var testCase = new BrowserTestCase( | 499 var testCase = new BrowserTestCase( |
| 497 testName, | 500 testName, |
| 498 compilerExecutable, | 501 compilerExecutable, |
| 499 compilerArgs, | 502 compilerArgs, |
| 500 executable, | 503 executable, |
| 501 args, | 504 args, |
| 502 configuration, | 505 configuration, |
| 503 completeHandler, | 506 completeHandler, |
| 504 expectations, | 507 expectations, |
| 505 optionsFromFile['isNegative']); | 508 optionsFromFile['isNegative']); |
| 506 doTest(testCase); | 509 doTest(testCase); |
| 507 } | 510 } |
| 508 } | 511 } |
| 509 | 512 |
| 510 /*** | 513 /*** |
| 511 * Create a directory for the generated test. Drop the path to the | 514 * Create a directory for the generated test. Drop the path to the |
| 512 * dart checkout and the final ".dart" from the test path, and replace | 515 * dart checkout and the final ".dart" from the test path, and replace |
| 513 * all path separators with underscores. | 516 * all path separators with underscores. |
| 514 * All variables are block local, except tempDir. | 517 * All variables are block local, except tempDir. |
| 515 */ | 518 */ |
| 516 Directory createTemporaryDirectory(String testPath, | 519 Directory createTemporaryDirectory(String testPath, |
| 517 String dartDir, | 520 String dartDir, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 538 throw new Exception( | 541 throw new Exception( |
| 539 'Non-relative path to build directory in test_suite.dart'); | 542 'Non-relative path to build directory in test_suite.dart'); |
| 540 } | 543 } |
| 541 buildPath.removeRange(0, 1); | 544 buildPath.removeRange(0, 1); |
| 542 if (buildPath.last() == '') buildPath.removeLast(); | 545 if (buildPath.last() == '') buildPath.removeLast(); |
| 543 buildPath.addAll(generatedTestPath); | 546 buildPath.addAll(generatedTestPath); |
| 544 generatedTestPath = buildPath; | 547 generatedTestPath = buildPath; |
| 545 tempDir = new Directory(tempDirPath); | 548 tempDir = new Directory(tempDirPath); |
| 546 if (!tempDir.existsSync()) { | 549 if (!tempDir.existsSync()) { |
| 547 tempDir.createSync(); | 550 tempDir.createSync(); |
| 548 } | 551 } |
| 549 } | 552 } |
| 550 tempDirPath = new File(tempDirPath).fullPathSync(); | 553 tempDirPath = new File(tempDirPath).fullPathSync(); |
| 551 | 554 |
| 552 for (String subdirectory in generatedTestPath) { | 555 for (String subdirectory in generatedTestPath) { |
| 553 tempDirPath = '$tempDirPath/$subdirectory'; | 556 tempDirPath = '$tempDirPath/$subdirectory'; |
| 554 tempDir = new Directory(tempDirPath); | 557 tempDir = new Directory(tempDirPath); |
| 555 if (!tempDir.existsSync()) { | 558 if (!tempDir.existsSync()) { |
| 556 tempDir.createSync(); | 559 tempDir.createSync(); |
| 557 } | 560 } |
| 558 } | 561 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 574 } | 577 } |
| 575 | 578 |
| 576 String getHtmlName(String filename) { | 579 String getHtmlName(String filename) { |
| 577 return filename.replaceAll('/', '_') + configuration['component'] + '.html'; | 580 return filename.replaceAll('/', '_') + configuration['component'] + '.html'; |
| 578 } | 581 } |
| 579 | 582 |
| 580 String get dumpRenderTreeFilename() { | 583 String get dumpRenderTreeFilename() { |
| 581 if (new Platform().operatingSystem() == 'macos') { | 584 if (new Platform().operatingSystem() == 'macos') { |
| 582 return 'client/tests/drt/DumpRenderTree.app/Contents/' + | 585 return 'client/tests/drt/DumpRenderTree.app/Contents/' + |
| 583 'MacOS/DumpRenderTree'; | 586 'MacOS/DumpRenderTree'; |
| 584 } | 587 } |
| 585 return 'client/tests/drt/DumpRenderTree'; | 588 return 'client/tests/drt/DumpRenderTree'; |
| 586 } | 589 } |
| 587 | 590 |
| 588 void testGeneratorStarted() { | 591 void testGeneratorStarted() { |
| 589 ++activeTestGenerators; | 592 ++activeTestGenerators; |
| 590 } | 593 } |
| 591 | 594 |
| 592 void testGeneratorDone() { | 595 void testGeneratorDone() { |
| 593 --activeTestGenerators; | 596 --activeTestGenerators; |
| 594 if (activeTestGenerators == 0 && listingDone) { | 597 if (activeTestGenerators == 0 && listingDone) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 RegExp multiTestRegExp = const RegExp(@"/// [0-9][0-9]:(.*)"); | 653 RegExp multiTestRegExp = const RegExp(@"/// [0-9][0-9]:(.*)"); |
| 651 RegExp leadingHashRegExp = const RegExp(@"^#", multiLine: true); | 654 RegExp leadingHashRegExp = const RegExp(@"^#", multiLine: true); |
| 652 RegExp isolateStubsRegExp = const RegExp(@"// IsolateStubs=(.*)"); | 655 RegExp isolateStubsRegExp = const RegExp(@"// IsolateStubs=(.*)"); |
| 653 RegExp domImportRegExp = | 656 RegExp domImportRegExp = |
| 654 const RegExp(@"^#import.*(dart:(dom|html)|html\.dart).*\)", | 657 const RegExp(@"^#import.*(dart:(dom|html)|html\.dart).*\)", |
| 655 multiLine: true); | 658 multiLine: true); |
| 656 RegExp libraryDefinitionRegExp = | 659 RegExp libraryDefinitionRegExp = |
| 657 const RegExp(@"^#library\(", multiLine: true); | 660 const RegExp(@"^#library\(", multiLine: true); |
| 658 RegExp sourceOrImportRegExp = | 661 RegExp sourceOrImportRegExp = |
| 659 const RegExp(@"^#(source|import)\(", multiLine: true); | 662 const RegExp(@"^#(source|import)\(", multiLine: true); |
| 660 | 663 |
| 661 // Read the entire file into a byte buffer and transform it to a | 664 // Read the entire file into a byte buffer and transform it to a |
| 662 // String. This will treat the file as ascii but the only parts | 665 // String. This will treat the file as ascii but the only parts |
| 663 // we are interested in will be ascii in any case. | 666 // we are interested in will be ascii in any case. |
| 664 RandomAccessFile file = new File(filename).openSync(); | 667 RandomAccessFile file = new File(filename).openSync(); |
| 665 List chars = new List(file.lengthSync()); | 668 List chars = new List(file.lengthSync()); |
| 666 var offset = 0; | 669 var offset = 0; |
| 667 while (offset != chars.length) { | 670 while (offset != chars.length) { |
| 668 offset += file.readListSync(chars, offset, chars.length - offset); | 671 offset += file.readListSync(chars, offset, chars.length - offset); |
| 669 } | 672 } |
| 670 file.closeSync(); | 673 file.closeSync(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 | 799 |
| 797 bool isTestFile(String filename) => filename.endsWith("Tests.java") && | 800 bool isTestFile(String filename) => filename.endsWith("Tests.java") && |
| 798 !filename.contains('com/google/dart/compiler/vm') && | 801 !filename.contains('com/google/dart/compiler/vm') && |
| 799 !filename.contains('com/google/dart/corelib/SharedTests.java'); | 802 !filename.contains('com/google/dart/corelib/SharedTests.java'); |
| 800 | 803 |
| 801 void forEachTest(Function onTest, | 804 void forEachTest(Function onTest, |
| 802 Map testCacheIgnored, | 805 Map testCacheIgnored, |
| 803 [Function onDone = null]) { | 806 [Function onDone = null]) { |
| 804 doTest = onTest; | 807 doTest = onTest; |
| 805 doDone = (onDone != null) ? onDone : (() => null); | 808 doDone = (onDone != null) ? onDone : (() => null); |
| 806 | 809 |
| 807 if (configuration['component'] != 'dartc') { | 810 if (configuration['component'] != 'dartc') { |
| 808 // Do nothing. Asynchronously report that the suite is enqueued. | 811 // Do nothing. Asynchronously report that the suite is enqueued. |
| 809 new Timer((timerUnused){ doDone(); }, 0); | 812 new Timer((timerUnused){ doDone(); }, 0); |
| 810 return; | 813 return; |
| 811 } | 814 } |
| 812 RegExp pattern = configuration['selectors']['dartc']; | 815 RegExp pattern = configuration['selectors']['dartc']; |
| 813 if (!pattern.hasMatch('junit_tests')) { | 816 if (!pattern.hasMatch('junit_tests')) { |
| 814 new Timer((timerUnused){ doDone(); }, 0); | 817 new Timer((timerUnused){ doDone(); }, 0); |
| 815 return; | 818 return; |
| 816 } | 819 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 841 | 844 |
| 842 int index = filename.indexOf('compiler/javatests/com/google/dart'); | 845 int index = filename.indexOf('compiler/javatests/com/google/dart'); |
| 843 if (index != -1) { | 846 if (index != -1) { |
| 844 String testRelativePath = | 847 String testRelativePath = |
| 845 filename.substring(index + 'compiler/javatests/'.length, | 848 filename.substring(index + 'compiler/javatests/'.length, |
| 846 filename.length - '.java'.length); | 849 filename.length - '.java'.length); |
| 847 String testClass = testRelativePath.replaceAll('/', '.'); | 850 String testClass = testRelativePath.replaceAll('/', '.'); |
| 848 testClasses.add(testClass); | 851 testClasses.add(testClass); |
| 849 } | 852 } |
| 850 } | 853 } |
| 851 | 854 |
| 852 void createTest(successIgnored) { | 855 void createTest(successIgnored) { |
| 853 String d8 = '$dartDir/$buildDir/d8${TestUtils.executableSuffix}'; | 856 String d8 = '$dartDir/$buildDir/d8${TestUtils.executableSuffix}'; |
| 854 List<String> args = <String>[ | 857 List<String> args = <String>[ |
| 855 '-ea', | 858 '-ea', |
| 856 '-classpath', classPath, | 859 '-classpath', classPath, |
| 857 '-Dcom.google.dart.runner.d8=$d8', | 860 '-Dcom.google.dart.runner.d8=$d8', |
| 858 '-Dcom.google.dart.corelib.SharedTests.test_py=$dartDir/tools/test.py', | 861 '-Dcom.google.dart.corelib.SharedTests.test_py=$dartDir/tools/test.py', |
| 859 'org.junit.runner.JUnitCore']; | 862 'org.junit.runner.JUnitCore']; |
| 860 args.addAll(testClasses); | 863 args.addAll(testClasses); |
| 861 | 864 |
| 862 doTest(new TestCase(suiteName, | 865 doTest(new TestCase(suiteName, |
| 863 'java', | 866 'java', |
| 864 args, | 867 args, |
| 865 configuration, | 868 configuration, |
| 866 completeHandler, | 869 completeHandler, |
| 867 new Set<String>.from([PASS]))); | 870 new Set<String>.from([PASS]))); |
| 868 doDone(); | 871 doDone(); |
| 869 } | 872 } |
| 870 | 873 |
| 871 void completeHandler(TestCase testCase) { | 874 void completeHandler(TestCase testCase) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 887 'third_party/hamcrest/v1_3/hamcrest-integration-1.3.0RC2.jar', | 890 'third_party/hamcrest/v1_3/hamcrest-integration-1.3.0RC2.jar', |
| 888 'third_party/hamcrest/v1_3/hamcrest-library-1.3.0RC2.jar', | 891 'third_party/hamcrest/v1_3/hamcrest-library-1.3.0RC2.jar', |
| 889 'third_party/junit/v4_8_2/junit.jar'], | 892 'third_party/junit/v4_8_2/junit.jar'], |
| 890 ':'); // Path separator. | 893 ':'); // Path separator. |
| 891 } | 894 } |
| 892 } | 895 } |
| 893 | 896 |
| 894 | 897 |
| 895 class TestUtils { | 898 class TestUtils { |
| 896 static String get executableSuffix() => | 899 static String get executableSuffix() => |
| 897 (new Platform().operatingSystem() == 'windows') ? '.exe' : ''; | 900 (new Platform().operatingSystem() == 'windows') ? '.exe' : ''; |
| 898 | 901 |
| 899 static String executableName(Map configuration) { | 902 static String executableName(Map configuration) { |
| 900 String postfix = executableSuffix; | 903 String postfix = executableSuffix; |
| 901 switch (configuration['component']) { | 904 switch (configuration['component']) { |
| 902 case 'vm': | 905 case 'vm': |
| 903 return 'dart$postfix'; | 906 return 'dart$postfix'; |
| 904 case 'dartc': | 907 case 'dartc': |
| 905 return 'compiler/bin/dartc_test$postfix'; | 908 return 'compiler/bin/dartc_test$postfix'; |
| 906 case 'frog': | 909 case 'frog': |
| 907 case 'leg': | 910 case 'leg': |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 * $noCrash tests are expected to be flaky but not crash | 1032 * $noCrash tests are expected to be flaky but not crash |
| 1030 * $pass tests are expected to pass | 1033 * $pass tests are expected to pass |
| 1031 * $failOk tests are expected to fail that we won't fix | 1034 * $failOk tests are expected to fail that we won't fix |
| 1032 * $fail tests are expected to fail that we should fix | 1035 * $fail tests are expected to fail that we should fix |
| 1033 * $crash tests are expected to crash that we should fix | 1036 * $crash tests are expected to crash that we should fix |
| 1034 * $timeout tests are allowed to timeout\ | 1037 * $timeout tests are allowed to timeout\ |
| 1035 """; | 1038 """; |
| 1036 print(report); | 1039 print(report); |
| 1037 } | 1040 } |
| 1038 } | 1041 } |
| OLD | NEW |