Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 * The path to the compiler for this suite's configuration. Returns `null` if | 135 * The path to the compiler for this suite's configuration. Returns `null` if |
| 136 * no compiler should be used. | 136 * no compiler should be used. |
| 137 */ | 137 */ |
| 138 String get compilerPath { | 138 String get compilerPath { |
| 139 if (configuration['compiler'] == 'none') { | 139 if (configuration['compiler'] == 'none') { |
| 140 return null; // No separate compiler for dartium tests. | 140 return null; // No separate compiler for dartium tests. |
| 141 } | 141 } |
| 142 var name; | 142 var name; |
| 143 switch (configuration['compiler']) { | 143 switch (configuration['compiler']) { |
| 144 case 'dartc': | 144 case 'dartc': |
| 145 case 'new_analyzer': | |
| 145 name = executablePath; | 146 name = executablePath; |
| 146 case 'dart2js': | 147 case 'dart2js': |
| 147 case 'dart2dart': | 148 case 'dart2dart': |
| 148 var prefix = 'sdk/bin/'; | 149 var prefix = 'sdk/bin/'; |
| 149 String suffix = getExecutableSuffix(configuration['compiler']); | 150 String suffix = getExecutableSuffix(configuration['compiler']); |
| 150 if (configuration['host_checked']) { | 151 if (configuration['host_checked']) { |
| 151 // The script dart2js_developer is not included in the | 152 // The script dart2js_developer is not included in the |
| 152 // shipped SDK, that is the script is not installed in | 153 // shipped SDK, that is the script is not installed in |
| 153 // "$buildDir/dart-sdk/bin/" | 154 // "$buildDir/dart-sdk/bin/" |
| 154 name = '$prefix/dart2js_developer$suffix'; | 155 name = '$prefix/dart2js_developer$suffix'; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 174 String get executablePath { | 175 String get executablePath { |
| 175 var suffix = getExecutableSuffix(configuration['compiler']); | 176 var suffix = getExecutableSuffix(configuration['compiler']); |
| 176 switch (configuration['compiler']) { | 177 switch (configuration['compiler']) { |
| 177 case 'none': | 178 case 'none': |
| 178 if (useSdk) { | 179 if (useSdk) { |
| 179 return '$buildDir/dart-sdk/bin/dart$suffix'; | 180 return '$buildDir/dart-sdk/bin/dart$suffix'; |
| 180 } | 181 } |
| 181 return '$buildDir/dart$suffix'; | 182 return '$buildDir/dart$suffix'; |
| 182 case 'dartc': | 183 case 'dartc': |
| 183 return '$buildDir/analyzer/bin/dart_analyzer$suffix'; | 184 return '$buildDir/analyzer/bin/dart_analyzer$suffix'; |
| 185 case 'new_analyzer': | |
| 186 var prefix = 'sdk/bin/'; | |
| 187 return '$prefix/analyzer$suffix'; | |
|
kustermann
2013/03/12 17:55:23
'$suffix' will probably be '.exe' on windows (and
ricow1
2013/03/12 18:06:06
No it will actually be .bat if the file is not exp
| |
| 184 default: | 188 default: |
| 185 throw "Unknown executable for: ${configuration['compiler']}"; | 189 throw "Unknown executable for: ${configuration['compiler']}"; |
| 186 } | 190 } |
| 187 } | 191 } |
| 188 | 192 |
| 189 /** | 193 /** |
| 190 * The file name of the d8 executable. | 194 * The file name of the d8 executable. |
| 191 */ | 195 */ |
| 192 String get d8FileName { | 196 String get d8FileName { |
| 193 var suffix = getExecutableSuffix('d8'); | 197 var suffix = getExecutableSuffix('d8'); |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 692 | 696 |
| 693 void enqueueStandardTest(TestInformation info, | 697 void enqueueStandardTest(TestInformation info, |
| 694 String testName, | 698 String testName, |
| 695 Set<String> expectations) { | 699 Set<String> expectations) { |
| 696 bool isNegative = info.hasCompileError || | 700 bool isNegative = info.hasCompileError || |
| 697 (configuration['checked'] && info.isNegativeIfChecked); | 701 (configuration['checked'] && info.isNegativeIfChecked); |
| 698 if (info.hasRuntimeError && hasRuntime) { | 702 if (info.hasRuntimeError && hasRuntime) { |
| 699 isNegative = true; | 703 isNegative = true; |
| 700 } | 704 } |
| 701 | 705 |
| 702 if (configuration['compiler'] == 'dartc') { | 706 if (configuration['analyzer']) { |
| 703 // dartc can detect static type warnings by the | 707 // An analyzer can detect static type warnings by the |
| 704 // format of the error line | 708 // format of the error line |
| 705 if (info.hasFatalTypeErrors) { | 709 if (info.hasFatalTypeErrors) { |
| 706 isNegative = true; | 710 isNegative = true; |
| 707 } | 711 } |
| 708 } | 712 } |
| 709 | 713 |
| 710 var commonArguments = commonArgumentsFromFile(info.filePath, | 714 var commonArguments = commonArgumentsFromFile(info.filePath, |
| 711 info.optionsFromFile); | 715 info.optionsFromFile); |
| 712 | 716 |
| 713 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); | 717 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 768 vmArguments.addAll([ | 772 vmArguments.addAll([ |
| 769 '--ignore-unrecognized-flags', '$tempDir/out.dart']); | 773 '--ignore-unrecognized-flags', '$tempDir/out.dart']); |
| 770 commands.add(new Command(vmFileName, vmArguments)); | 774 commands.add(new Command(vmFileName, vmArguments)); |
| 771 } else { | 775 } else { |
| 772 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; | 776 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; |
| 773 } | 777 } |
| 774 return commands; | 778 return commands; |
| 775 | 779 |
| 776 case 'none': | 780 case 'none': |
| 777 case 'dartc': | 781 case 'dartc': |
| 782 case 'new_analyzer': | |
| 778 var arguments = new List.from(vmOptions); | 783 var arguments = new List.from(vmOptions); |
| 779 arguments.addAll(args); | 784 arguments.addAll(args); |
| 780 return <Command>[new Command(dartShellFileName, arguments)]; | 785 return <Command>[new Command(dartShellFileName, arguments)]; |
| 781 | 786 |
| 782 default: | 787 default: |
| 783 throw 'Unknown compiler ${configuration["compiler"]}'; | 788 throw 'Unknown compiler ${configuration["compiler"]}'; |
| 784 } | 789 } |
| 785 } | 790 } |
| 786 | 791 |
| 787 CreateTest makeTestCaseCreator(Map optionsFromFile) { | 792 CreateTest makeTestCaseCreator(Map optionsFromFile) { |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1156 return new File.fromPath(generatedTestPath).fullPathSync() | 1161 return new File.fromPath(generatedTestPath).fullPathSync() |
| 1157 .replaceAll('\\', '/'); | 1162 .replaceAll('\\', '/'); |
| 1158 } | 1163 } |
| 1159 | 1164 |
| 1160 String get scriptType { | 1165 String get scriptType { |
| 1161 switch (configuration['compiler']) { | 1166 switch (configuration['compiler']) { |
| 1162 case 'none': | 1167 case 'none': |
| 1163 case 'dart2dart': | 1168 case 'dart2dart': |
| 1164 return 'application/dart'; | 1169 return 'application/dart'; |
| 1165 case 'dart2js': | 1170 case 'dart2js': |
| 1171 case 'new_analyzer': | |
| 1166 case 'dartc': | 1172 case 'dartc': |
| 1167 return 'text/javascript'; | 1173 return 'text/javascript'; |
| 1168 default: | 1174 default: |
| 1169 Expect.fail('Non-web runtime, so no scriptType for: ' | 1175 Expect.fail('Non-web runtime, so no scriptType for: ' |
| 1170 '${configuration["compiler"]}'); | 1176 '${configuration["compiler"]}'); |
| 1171 return null; | 1177 return null; |
| 1172 } | 1178 } |
| 1173 } | 1179 } |
| 1174 | 1180 |
| 1175 bool get hasRuntime { | 1181 bool get hasRuntime { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1216 } | 1222 } |
| 1217 | 1223 |
| 1218 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { | 1224 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { |
| 1219 List args = TestUtils.standardOptions(configuration); | 1225 List args = TestUtils.standardOptions(configuration); |
| 1220 | 1226 |
| 1221 String packageRoot = packageRootArgument(optionsFromFile['packageRoot']); | 1227 String packageRoot = packageRootArgument(optionsFromFile['packageRoot']); |
| 1222 if (packageRoot != null) { | 1228 if (packageRoot != null) { |
| 1223 args.add(packageRoot); | 1229 args.add(packageRoot); |
| 1224 } | 1230 } |
| 1225 args.addAll(additionalOptions(filePath)); | 1231 args.addAll(additionalOptions(filePath)); |
| 1226 if (configuration['compiler'] == 'dartc') { | 1232 if (configuration['analyzer']) { |
| 1227 args.add('--error_format'); | 1233 args.add('--error_format'); |
|
kustermann
2013/03/12 17:55:23
Does the new analyzer accept the same arguments as
ricow1
2013/03/12 18:06:06
Yes
| |
| 1228 args.add('machine'); | 1234 args.add('machine'); |
| 1229 } | 1235 } |
| 1230 | 1236 |
| 1231 bool isMultitest = optionsFromFile["isMultitest"]; | 1237 bool isMultitest = optionsFromFile["isMultitest"]; |
| 1232 List<String> dartOptions = optionsFromFile["dartOptions"]; | 1238 List<String> dartOptions = optionsFromFile["dartOptions"]; |
| 1233 List<List<String>> vmOptionsList = getVmOptions(optionsFromFile); | 1239 List<List<String>> vmOptionsList = getVmOptions(optionsFromFile); |
| 1234 Expect.isTrue(!isMultitest || dartOptions == null); | 1240 Expect.isTrue(!isMultitest || dartOptions == null); |
| 1235 if (dartOptions == null) { | 1241 if (dartOptions == null) { |
| 1236 args.add(filePath.toNativePath()); | 1242 args.add(filePath.toNativePath()); |
| 1237 } else { | 1243 } else { |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1592 bool isTestFile(String filename) => filename.endsWith("Tests.java") && | 1598 bool isTestFile(String filename) => filename.endsWith("Tests.java") && |
| 1593 !filename.contains('com/google/dart/compiler/vm') && | 1599 !filename.contains('com/google/dart/compiler/vm') && |
| 1594 !filename.contains('com/google/dart/corelib/SharedTests.java'); | 1600 !filename.contains('com/google/dart/corelib/SharedTests.java'); |
| 1595 | 1601 |
| 1596 void forEachTest(TestCaseEvent onTest, | 1602 void forEachTest(TestCaseEvent onTest, |
| 1597 Map testCacheIgnored, | 1603 Map testCacheIgnored, |
| 1598 [VoidFunction onDone]) { | 1604 [VoidFunction onDone]) { |
| 1599 doTest = onTest; | 1605 doTest = onTest; |
| 1600 doDone = onDone; | 1606 doDone = onDone; |
| 1601 | 1607 |
| 1602 if (configuration['compiler'] != 'dartc') { | 1608 if (!configuration['analyzer']) { |
| 1603 // Do nothing. Asynchronously report that the suite is enqueued. | 1609 // Do nothing. Asynchronously report that the suite is enqueued. |
| 1604 asynchronously(doDone); | 1610 asynchronously(doDone); |
| 1605 return; | 1611 return; |
| 1606 } | 1612 } |
| 1607 RegExp pattern = configuration['selectors']['dartc']; | 1613 RegExp pattern = configuration['selectors']['dartc']; |
| 1608 if (!pattern.hasMatch('junit_tests')) { | 1614 if (!pattern.hasMatch('junit_tests')) { |
| 1609 asynchronously(doDone); | 1615 asynchronously(doDone); |
| 1610 return; | 1616 return; |
| 1611 } | 1617 } |
| 1612 | 1618 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1846 ]; | 1852 ]; |
| 1847 return BROWSERS.contains(runtime); | 1853 return BROWSERS.contains(runtime); |
| 1848 } | 1854 } |
| 1849 | 1855 |
| 1850 static bool isBrowserRuntime(String runtime) => | 1856 static bool isBrowserRuntime(String runtime) => |
| 1851 runtime == 'drt' || TestUtils.usesWebDriver(runtime); | 1857 runtime == 'drt' || TestUtils.usesWebDriver(runtime); |
| 1852 | 1858 |
| 1853 static bool isJsCommandLineRuntime(String runtime) => | 1859 static bool isJsCommandLineRuntime(String runtime) => |
| 1854 const ['d8', 'jsshell'].contains(runtime); | 1860 const ['d8', 'jsshell'].contains(runtime); |
| 1855 | 1861 |
| 1862 static bool isCommandLineAnalyzer(String compiler) => | |
| 1863 compiler == 'dartc' || compiler == 'new_analyzer'; | |
| 1864 | |
| 1856 static String buildDir(Map configuration) { | 1865 static String buildDir(Map configuration) { |
| 1857 // FIXME(kustermann,ricow): Our code assumes that the returned 'buildDir' | 1866 // FIXME(kustermann,ricow): Our code assumes that the returned 'buildDir' |
| 1858 // is relative to the current working directory. | 1867 // is relative to the current working directory. |
| 1859 // Thus, if we pass in an absolute path (e.g. '--build-directory=/tmp/out') | 1868 // Thus, if we pass in an absolute path (e.g. '--build-directory=/tmp/out') |
| 1860 // we get into trouble. | 1869 // we get into trouble. |
| 1861 if (configuration['build_directory'] != '') { | 1870 if (configuration['build_directory'] != '') { |
| 1862 return configuration['build_directory']; | 1871 return configuration['build_directory']; |
| 1863 } | 1872 } |
| 1864 var outputDir = ''; | 1873 var outputDir = ''; |
| 1865 var system = configuration['system']; | 1874 var system = configuration['system']; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1952 * $pass tests are expected to pass | 1961 * $pass tests are expected to pass |
| 1953 * $failOk tests are expected to fail that we won't fix | 1962 * $failOk tests are expected to fail that we won't fix |
| 1954 * $fail tests are expected to fail that we should fix | 1963 * $fail tests are expected to fail that we should fix |
| 1955 * $crash tests are expected to crash that we should fix | 1964 * $crash tests are expected to crash that we should fix |
| 1956 * $timeout tests are allowed to timeout | 1965 * $timeout tests are allowed to timeout |
| 1957 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 1966 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 1958 """; | 1967 """; |
| 1959 print(report); | 1968 print(report); |
| 1960 } | 1969 } |
| 1961 } | 1970 } |
| OLD | NEW |