| 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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 } | 744 } |
| 745 } | 745 } |
| 746 | 746 |
| 747 String shellPath() => TestUtils.compilerPath(configuration); | 747 String shellPath() => TestUtils.compilerPath(configuration); |
| 748 | 748 |
| 749 List<String> additionalOptions() { | 749 List<String> additionalOptions() { |
| 750 // TODO(ager): potentially register cleanup action to delete the temporary | 750 // TODO(ager): potentially register cleanup action to delete the temporary |
| 751 // directories? | 751 // directories? |
| 752 var tempDir = new Directory(''); | 752 var tempDir = new Directory(''); |
| 753 tempDir.createTempSync(); | 753 tempDir.createTempSync(); |
| 754 return ['-check-only', '-fatal-type-errors', '-Werror', '-out', tempDir.path
]; | 754 return |
| 755 ['-check-only', '-fatal-type-errors', '-Werror', '-out', tempDir.path]; |
| 755 } | 756 } |
| 756 | 757 |
| 757 void processDirectory() { | 758 void processDirectory() { |
| 758 directoryPath = getDirname(directoryPath); | 759 directoryPath = getDirname(directoryPath); |
| 759 // Enqueueing the directory listers is an activity. | 760 // Enqueueing the directory listers is an activity. |
| 760 activityStarted(); | 761 activityStarted(); |
| 761 for (String testDir in _testDirs) { | 762 for (String testDir in _testDirs) { |
| 762 Directory dir = new Directory("$directoryPath/$testDir"); | 763 Directory dir = new Directory("$directoryPath/$testDir"); |
| 763 if (dir.existsSync()) { | 764 if (dir.existsSync()) { |
| 764 activityStarted(); | 765 activityStarted(); |
| 765 dir.errorHandler = (s) { | 766 dir.errorHandler = (s) { |
| 766 throw s; | 767 throw s; |
| 767 }; | 768 }; |
| 768 dir.fileHandler = processFile; | 769 dir.fileHandler = processFile; |
| 769 dir.doneHandler = (ignore) => activityCompleted(); | 770 dir.doneHandler = (ignore) => activityCompleted(); |
| 770 dir.list(recursive: listRecursively()); | 771 dir.list(recursive: listRecursively()); |
| 771 } | 772 } |
| 772 } | 773 } |
| 773 // Completed the enqueueing of listers. | 774 // Completed the enqueueing of listers. |
| 774 activityCompleted(); | 775 activityCompleted(); |
| 775 } | 776 } |
| 776 } | 777 } |
| 777 | 778 |
| 778 | 779 |
| 780 class JUnitTestSuite implements TestSuite { |
| 781 Map configuration; |
| 782 String suiteName; |
| 783 String directoryPath; |
| 784 String statusFilePath; |
| 785 String dartDir; |
| 786 String buildDir; |
| 787 String classPath; |
| 788 List<String> testClasses; |
| 789 Function doTest; |
| 790 Function doDone; |
| 791 TestExpectations testExpectations; |
| 792 |
| 793 JUnitTestSuite(Map this.configuration, |
| 794 String this.suiteName, |
| 795 String this.directoryPath, |
| 796 String this.statusFilePath); |
| 797 |
| 798 void isTestFile(String filename) => filename.endsWith("Tests.java") && |
| 799 !filename.contains('com/google/dart/compiler/vm') && |
| 800 !filename.contains('com/google/dart/corelib/SharedTests.java'); |
| 801 |
| 802 void forEachTest(Function onTest, |
| 803 Map testCacheIgnored, |
| 804 [Function onDone = null]) { |
| 805 doTest = onTest; |
| 806 doDone = (onDone != null) ? onDone : (() => null); |
| 807 |
| 808 if (configuration['component'] != 'dartc') { |
| 809 // Do nothing. Asynchronously report that the suite is enqueued. |
| 810 new Timer((timerUnused){ doDone(); }, 0); |
| 811 return; |
| 812 } |
| 813 RegExp pattern = configuration['selectors']['dartc']; |
| 814 if (!pattern.hasMatch('junit_tests')) { |
| 815 new Timer((timerUnused){ doDone(); }, 0); |
| 816 return; |
| 817 } |
| 818 |
| 819 dartDir = new File('.').fullPathSync(); |
| 820 buildDir = TestUtils.buildDir(configuration); |
| 821 computeClassPath(); |
| 822 testClasses = <String>[]; |
| 823 // Do not read the status file. |
| 824 // All exclusions are hardcoded in this script, as they are in testcfg.py. |
| 825 processDirectory(); |
| 826 } |
| 827 |
| 828 void processDirectory() { |
| 829 directoryPath = getDirname(directoryPath); |
| 830 Directory dir = new Directory(directoryPath); |
| 831 |
| 832 dir.errorHandler = (s) { |
| 833 throw s; |
| 834 }; |
| 835 dir.fileHandler = processFile; |
| 836 dir.doneHandler = createTest; |
| 837 dir.list(recursive: true); |
| 838 } |
| 839 |
| 840 void processFile(String filename) { |
| 841 if (!isTestFile(filename)) return; |
| 842 |
| 843 int index = filename.indexOf('compiler/javatests/com/google/dart'); |
| 844 if (index != -1) { |
| 845 String testRelativePath = |
| 846 filename.substring(index + 'compiler/javatests/'.length, |
| 847 filename.length - '.java'.length); |
| 848 String testClass = testRelativePath.replaceAll('/', '.'); |
| 849 testClasses.add(testClass); |
| 850 } |
| 851 } |
| 852 |
| 853 void createTest(successIgnored) { |
| 854 String d8 = '$dartDir/$buildDir/d8${TestUtils.executableSuffix}'; |
| 855 List<String> args = <String>[ |
| 856 '-ea', |
| 857 '-classpath', classPath, |
| 858 '-Dcom.google.dart.runner.d8=$d8', |
| 859 '-Dcom.google.dart.corelib.SharedTests.test_py=$dartDir/tools/test.py', |
| 860 'org.junit.runner.JUnitCore']; |
| 861 args.addAll(testClasses); |
| 862 |
| 863 doTest(new TestCase(suiteName, |
| 864 'java', |
| 865 args, |
| 866 configuration, |
| 867 (){}, |
| 868 new Set<String>.from([PASS]))); |
| 869 doDone(); |
| 870 } |
| 871 |
| 872 void computeClassPath() { |
| 873 classPath = Strings.join( |
| 874 ['$buildDir/compiler/lib/dartc.jar', |
| 875 '$buildDir/compiler/lib/corelib.jar', |
| 876 '$buildDir/compiler-tests.jar', |
| 877 '$buildDir/closure_out/compiler.jar', |
| 878 // Third party libraries. |
| 879 'third_party/args4j/2.0.12/args4j-2.0.12.jar', |
| 880 'third_party/guava/r09/guava-r09.jar', |
| 881 'third_party/json/r2_20080312/json.jar', |
| 882 'third_party/rhino/1_7R3/js.jar', |
| 883 'third_party/hamcrest/v1_3/hamcrest-core-1.3.0RC2.jar', |
| 884 'third_party/hamcrest/v1_3/hamcrest-generator-1.3.0RC2.jar', |
| 885 'third_party/hamcrest/v1_3/hamcrest-integration-1.3.0RC2.jar', |
| 886 'third_party/hamcrest/v1_3/hamcrest-library-1.3.0RC2.jar', |
| 887 'third_party/junit/v4_8_2/junit.jar'], |
| 888 ':'); // Path separator. |
| 889 } |
| 890 } |
| 891 |
| 892 |
| 779 class TestUtils { | 893 class TestUtils { |
| 894 static String get executableSuffix() => |
| 895 (new Platform().operatingSystem() == 'windows') ? '.exe' : ''; |
| 896 |
| 780 static String executableName(Map configuration) { | 897 static String executableName(Map configuration) { |
| 781 String postfix = | 898 String postfix = executableSuffix; |
| 782 (new Platform().operatingSystem() == 'windows') ? '.exe' : ''; | |
| 783 switch (configuration['component']) { | 899 switch (configuration['component']) { |
| 784 case 'vm': | 900 case 'vm': |
| 785 return 'dart$postfix'; | 901 return 'dart$postfix'; |
| 786 case 'dartc': | 902 case 'dartc': |
| 787 return 'compiler/bin/dartc_test$postfix'; | 903 return 'compiler/bin/dartc_test$postfix'; |
| 788 case 'frog': | 904 case 'frog': |
| 789 case 'leg': | 905 case 'leg': |
| 790 return 'frog/bin/frog$postfix'; | 906 return 'frog/bin/frog$postfix'; |
| 791 case 'frogsh': | 907 case 'frogsh': |
| 792 return 'frog/bin/frogsh$postfix'; | 908 return 'frog/bin/frogsh$postfix'; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 * $noCrash tests are expected to be flaky but not crash | 1023 * $noCrash tests are expected to be flaky but not crash |
| 908 * $pass tests are expected to pass | 1024 * $pass tests are expected to pass |
| 909 * $failOk tests are expected to fail that we won't fix | 1025 * $failOk tests are expected to fail that we won't fix |
| 910 * $fail tests are expected to fail that we should fix | 1026 * $fail tests are expected to fail that we should fix |
| 911 * $crash tests are expected to crash that we should fix | 1027 * $crash tests are expected to crash that we should fix |
| 912 * $timeout tests are allowed to timeout\ | 1028 * $timeout tests are allowed to timeout\ |
| 913 """; | 1029 """; |
| 914 print(report); | 1030 print(report); |
| 915 } | 1031 } |
| 916 } | 1032 } |
| OLD | NEW |