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, |
| 11 * and creating [TestCase]s for those files that meet the relevant criteria. | 11 * and creating [TestCase]s for those files that meet the relevant criteria. |
| 12 * - Preparing tests, including copying files and frameworks to temporary | 12 * - Preparing tests, including copying files and frameworks to temporary |
| 13 * directories, and computing the command line and arguments to be run. | 13 * directories, and computing the command line and arguments to be run. |
| 14 */ | 14 */ |
| 15 library test_suite; | 15 library test_suite; |
| 16 | 16 |
| 17 import "dart:async"; | 17 import "dart:async"; |
| 18 import "dart:io"; | 18 import "dart:io"; |
| 19 import "drt_updater.dart"; | 19 import "drt_updater.dart"; |
| 20 import "multitest.dart"; | 20 import "multitest.dart"; |
| 21 import "status_file_parser.dart"; | 21 import "status_file_parser.dart"; |
| 22 import "test_runner.dart"; | 22 import "test_runner.dart"; |
| 23 import "utils.dart"; | 23 import "utils.dart"; |
| 24 import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR; | 24 import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR; |
| 25 | 25 |
| 26 import "compiler_configuration.dart" show | |
| 27 CommandArtifact, | |
| 28 CompilerConfiguration; | |
| 29 | |
| 30 import "runtime_configuration.dart" show | |
| 31 RuntimeConfiguration; | |
| 32 | |
| 26 part "browser_test.dart"; | 33 part "browser_test.dart"; |
| 27 | 34 |
| 28 | 35 |
| 29 /** | 36 /** |
| 30 * A simple function that tests [arg] and returns `true` or `false`. | 37 * A simple function that tests [arg] and returns `true` or `false`. |
| 31 */ | 38 */ |
| 32 typedef bool Predicate<T>(T arg); | 39 typedef bool Predicate<T>(T arg); |
| 33 | 40 |
| 34 typedef void CreateTest(Path filePath, | 41 typedef void CreateTest(Path filePath, |
| 35 bool hasCompileError, | 42 bool hasCompileError, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 'DART_CONFIGURATION' : TestUtils.configurationDir(configuration), | 122 'DART_CONFIGURATION' : TestUtils.configurationDir(configuration), |
| 116 }; | 123 }; |
| 117 } | 124 } |
| 118 | 125 |
| 119 /** | 126 /** |
| 120 * Whether or not binaries should be found in the root build directory or | 127 * Whether or not binaries should be found in the root build directory or |
| 121 * in the built SDK. | 128 * in the built SDK. |
| 122 */ | 129 */ |
| 123 bool get useSdk { | 130 bool get useSdk { |
| 124 // The pub suite always uses the SDK. | 131 // The pub suite always uses the SDK. |
| 125 // TODO(rnystrom): Eventually, all test suites should run out of the SDK | 132 // TODO(rnystrom): Eventually, all test suites should run out of the SDK |
|
ricow1
2014/03/03 07:47:08
where and why was this introduced - as stated belo
Bob Nystrom
2014/03/03 21:45:51
This was added a long time ago when I first starte
ahe
2014/03/04 07:46:39
Thank you, Bob. It's awesome that you noticed this
| |
| 126 // and this check should go away. | 133 // and this check should go away. |
| 134 // TODO(ahe): This check is broken for several reasons: | |
| 135 // First, it is not true that all tests should be running out of the | |
| 136 // SDK. It is absolutely critical to VM development that you can test the | |
| 137 // VM without building the SDK. | |
| 138 // Second, it is convenient for dart2js developers to run tests without | |
| 139 // rebuilding the SDK, and similarly, it should be convenient for pub | |
| 140 // developers. | |
|
Bob Nystrom
2014/03/03 21:45:51
Agreed. I'm not sure what I meant by that comment.
| |
| 141 // Third, even if pub can only run from the SDK directory, this is the | |
|
Bob Nystrom
2014/03/03 21:45:51
The pub binary runs fine from <repo>/sdk/bin/pub,
ahe
2014/03/04 07:46:39
OK. So I wonder if we should fix this. It would se
| |
| 142 // wrong place to work around that problem. Instead, test_options.dart | |
| 143 // should have been modified so that configuration['use_sdk'] is always | |
| 144 // true when testing pub. Attempting to override the value here is brittle | |
| 145 // because we read configuration['use_sdk'] directly in many places without | |
| 146 // using this getter. | |
| 127 if (suiteName == 'pub') return true; | 147 if (suiteName == 'pub') return true; |
| 128 | 148 |
| 129 return configuration['use_sdk']; | 149 return configuration['use_sdk']; |
| 130 } | 150 } |
| 131 | 151 |
| 132 /** | 152 /** |
| 133 * The output directory for this suite's configuration. | 153 * The output directory for this suite's configuration. |
| 134 */ | 154 */ |
| 135 String get buildDir => TestUtils.buildDir(configuration); | 155 String get buildDir => TestUtils.buildDir(configuration); |
| 136 | 156 |
| 137 /** | 157 /** |
| 138 * The path to the compiler for this suite's configuration. Returns `null` if | 158 * The path to the compiler for this suite's configuration. Returns `null` if |
| 139 * no compiler should be used. | 159 * no compiler should be used. |
| 140 */ | 160 */ |
| 141 String get compilerPath { | 161 String get compilerPath { |
| 142 if (configuration['compiler'] == 'none') { | 162 var compilerConfiguration = new CompilerConfiguration(configuration); |
| 143 return null; // No separate compiler for dartium tests. | 163 if (!compilerConfiguration.hasCompiler) return null; |
| 144 } | 164 String name = compilerConfiguration.computeCompilerPath(buildDir); |
| 145 var name; | 165 // TODO(ahe): Only validate this once, in test_options.dart. |
| 146 switch (configuration['compiler']) { | 166 TestUtils.ensureExists(name, configuration); |
| 147 case 'dartanalyzer': | |
| 148 case 'dart2analyzer': | |
| 149 name = executablePath; | |
| 150 break; | |
| 151 case 'dart2js': | |
| 152 case 'dart2dart': | |
| 153 var prefix = 'sdk/bin/'; | |
| 154 String suffix = getExecutableSuffix(configuration['compiler']); | |
| 155 if (configuration['host_checked']) { | |
| 156 // The script dart2js_developer is not included in the | |
| 157 // shipped SDK, that is the script is not installed in | |
| 158 // "$buildDir/dart-sdk/bin/" | |
| 159 name = '$prefix/dart2js_developer$suffix'; | |
| 160 } else { | |
| 161 if (configuration['use_sdk']) { | |
| 162 prefix = '$buildDir/dart-sdk/bin/'; | |
| 163 } | |
| 164 name = '${prefix}dart2js$suffix'; | |
| 165 } | |
| 166 break; | |
| 167 default: | |
| 168 throw "Unknown compiler for: ${configuration['compiler']}"; | |
| 169 } | |
| 170 if (!(new File(name)).existsSync() && !configuration['list']) { | |
| 171 throw "Executable '$name' does not exist"; | |
| 172 } | |
| 173 return name; | 167 return name; |
| 174 } | 168 } |
| 175 | 169 |
| 176 String get pubPath { | 170 String get pubPath { |
| 177 var prefix = 'sdk/bin/'; | 171 var prefix = 'sdk/bin/'; |
| 178 if (configuration['use_sdk']) { | 172 if (configuration['use_sdk']) { |
| 179 prefix = '$buildDir/dart-sdk/bin/'; | 173 prefix = '$buildDir/dart-sdk/bin/'; |
| 180 } | 174 } |
| 181 String suffix = getExecutableSuffix('pub'); | 175 String suffix = getExecutableSuffix('pub'); |
| 182 var name = '${prefix}pub$suffix'; | 176 var name = '${prefix}pub$suffix'; |
| 183 if (!(new File(name)).existsSync() && !configuration['list']) { | |
| 184 throw "Executable '$name' does not exist"; | |
| 185 } | |
| 186 return name; | |
| 187 } | |
| 188 | |
| 189 String get dartPath { | |
| 190 var prefix = 'sdk/bin/'; | |
| 191 if (configuration['use_sdk']) { | |
| 192 prefix = '$buildDir/dart-sdk/bin/'; | |
| 193 } | |
| 194 String suffix = getExecutableSuffix('vm'); | |
| 195 var name = '${prefix}dart$suffix'; | |
| 196 if (!(new File(name)).existsSync() && !configuration['list']) { | |
| 197 throw "Executable '$name' does not exist"; | |
| 198 } | |
| 199 return name; | |
| 200 } | |
| 201 | |
| 202 /** | |
| 203 * The path to the executable used to run this suite's tests. | |
| 204 */ | |
| 205 String get executablePath { | |
| 206 var suffix = getExecutableSuffix(configuration['compiler']); | |
| 207 switch (configuration['compiler']) { | |
| 208 case 'none': | |
| 209 if (useSdk) { | |
| 210 return '$buildDir/dart-sdk/bin/dart$suffix'; | |
| 211 } | |
| 212 return '$buildDir/dart$suffix'; | |
| 213 case 'dartanalyzer': | |
| 214 return 'sdk/bin/dartanalyzer_developer$suffix'; | |
| 215 case 'dart2analyzer': | |
| 216 return 'editor/tools/analyzer'; | |
| 217 default: | |
| 218 throw "Unknown executable for: ${configuration['compiler']}"; | |
| 219 } | |
| 220 } | |
| 221 | |
| 222 String get dartShellFileName { | |
| 223 var name = configuration['dart']; | |
| 224 if (name == '') { | |
| 225 name = executablePath; | |
| 226 } | |
| 227 | |
| 228 TestUtils.ensureExists(name, configuration); | 177 TestUtils.ensureExists(name, configuration); |
| 229 return name; | 178 return name; |
| 230 } | 179 } |
| 231 | 180 |
| 181 /// Returns the name of the Dart VM executable. | |
| 182 String get dartVmBinaryFileName { | |
| 183 // Controlled by user with the option "--dart". | |
| 184 String dartExecutable = configuration['dart']; | |
| 185 | |
| 186 if (dartExecutable == '') { | |
| 187 String suffix = executableBinarySuffix; | |
| 188 dartExecutable = useSdk | |
| 189 ? '$buildDir/dart-sdk/bin/dart$suffix' | |
| 190 : '$buildDir/dart$suffix'; | |
| 191 } | |
| 192 | |
| 193 TestUtils.ensureExists(dartExecutable, configuration); | |
| 194 return dartExecutable; | |
| 195 } | |
| 196 | |
| 232 String get d8FileName { | 197 String get d8FileName { |
| 233 var suffix = getExecutableSuffix('d8'); | 198 var suffix = getExecutableSuffix('d8'); |
| 234 var d8Dir = TestUtils.dartDir().append('third_party/d8'); | 199 var d8Dir = TestUtils.dartDir().append('third_party/d8'); |
| 235 var d8Path = d8Dir.append('${Platform.operatingSystem}/d8$suffix'); | 200 var d8Path = d8Dir.append('${Platform.operatingSystem}/d8$suffix'); |
| 236 var d8 = d8Path.toNativePath(); | 201 var d8 = d8Path.toNativePath(); |
| 237 TestUtils.ensureExists(d8, configuration); | 202 TestUtils.ensureExists(d8, configuration); |
| 238 return d8; | 203 return d8; |
| 239 } | 204 } |
| 240 | 205 |
| 241 String get jsShellFileName { | 206 String get jsShellFileName { |
| 242 var executableSuffix = getExecutableSuffix('jsshell'); | 207 var executableSuffix = getExecutableSuffix('jsshell'); |
| 243 var executable = 'jsshell$executableSuffix'; | 208 var executable = 'jsshell$executableSuffix'; |
| 244 var jsshellDir = '${TestUtils.dartDir()}/tools/testing/bin'; | 209 var jsshellDir = '${TestUtils.dartDir()}/tools/testing/bin'; |
| 245 return '$jsshellDir/$executable'; | 210 return '$jsshellDir/$executable'; |
| 246 } | 211 } |
| 247 | 212 |
| 248 /** | 213 /** |
| 249 * The file name of the Dart VM executable. | |
| 250 */ | |
| 251 String get vmFileName { | |
| 252 var suffix = getExecutableSuffix('vm'); | |
| 253 var vm = '$buildDir/dart$suffix'; | |
| 254 TestUtils.ensureExists(vm, configuration); | |
| 255 return vm; | |
| 256 } | |
| 257 | |
| 258 /** | |
| 259 * The file extension (if any) that should be added to the given executable | 214 * The file extension (if any) that should be added to the given executable |
| 260 * name for the current platform. | 215 * name for the current platform. |
| 261 */ | 216 */ |
| 217 // TODO(ahe): Get rid of this. Use executableBinarySuffix instead. | |
| 262 String getExecutableSuffix(String executable) { | 218 String getExecutableSuffix(String executable) { |
| 263 if (Platform.operatingSystem == 'windows') { | 219 if (Platform.operatingSystem == 'windows') { |
| 264 if (executable == 'd8' || executable == 'vm' || executable == 'none') { | 220 if (executable == 'd8' || executable == 'vm' || executable == 'none') { |
| 265 return '.exe'; | 221 return '.exe'; |
| 266 } else { | 222 } else { |
| 267 return '.bat'; | 223 return '.bat'; |
| 268 } | 224 } |
| 269 } | 225 } |
| 270 return ''; | 226 return ''; |
| 271 } | 227 } |
| 272 | 228 |
| 229 String get executableBinarySuffix => Platform.isWindows ? '.exe' : ''; | |
| 230 | |
| 273 /** | 231 /** |
| 274 * Call the callback function onTest with a [TestCase] argument for each | 232 * Call the callback function onTest with a [TestCase] argument for each |
| 275 * test in the suite. When all tests have been processed, call [onDone]. | 233 * test in the suite. When all tests have been processed, call [onDone]. |
| 276 * | 234 * |
| 277 * The [testCache] argument provides a persistent store that can be used to | 235 * The [testCache] argument provides a persistent store that can be used to |
| 278 * cache information about the test suite, so that directories do not need | 236 * cache information about the test suite, so that directories do not need |
| 279 * to be listed each time. | 237 * to be listed each time. |
| 280 */ | 238 */ |
| 281 void forEachTest(TestCaseEvent onTest, Map testCache, [VoidFunction onDone]); | 239 void forEachTest(TestCaseEvent onTest, Map testCache, [VoidFunction onDone]); |
| 282 | 240 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 310 if (!pattern.hasMatch(testCase.displayName)) { | 268 if (!pattern.hasMatch(testCase.displayName)) { |
| 311 return; | 269 return; |
| 312 } | 270 } |
| 313 | 271 |
| 314 // Update Summary report | 272 // Update Summary report |
| 315 if (configuration['report']) { | 273 if (configuration['report']) { |
| 316 SummaryReport.add(expectations); | 274 SummaryReport.add(expectations); |
| 317 if (testCase.info != null && | 275 if (testCase.info != null && |
| 318 testCase.info.hasCompileError && | 276 testCase.info.hasCompileError && |
| 319 TestUtils.isBrowserRuntime(configuration['runtime']) && | 277 TestUtils.isBrowserRuntime(configuration['runtime']) && |
| 320 configuration['compiler'] != 'none') { | 278 new CompilerConfiguration(configuration).hasCompiler) { |
| 321 SummaryReport.addCompileErrorSkipTest(); | 279 SummaryReport.addCompileErrorSkipTest(); |
| 322 return; | 280 return; |
| 323 } | 281 } |
| 324 } | 282 } |
| 325 | 283 |
| 326 // Handle skipped tests | 284 // Handle skipped tests |
| 327 if (expectations.contains(Expectation.SKIP) || | 285 if (expectations.contains(Expectation.SKIP) || |
| 328 expectations.contains(Expectation.SKIP_BY_DESIGN)) { | 286 expectations.contains(Expectation.SKIP_BY_DESIGN)) { |
| 329 return; | 287 return; |
| 330 } | 288 } |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 923 if (optionsFromFile['packageRoot'] == null || | 881 if (optionsFromFile['packageRoot'] == null || |
| 924 optionsFromFile['packageRoot'] == "") { | 882 optionsFromFile['packageRoot'] == "") { |
| 925 optionsFromFile['packageRoot'] = packageRoot.toNativePath(); | 883 optionsFromFile['packageRoot'] = packageRoot.toNativePath(); |
| 926 } | 884 } |
| 927 } | 885 } |
| 928 } | 886 } |
| 929 String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath, | 887 String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath, |
| 930 multitestName: optionsFromFile['isMultitest'] ? info.multitestKey : ""); | 888 multitestName: optionsFromFile['isMultitest'] ? info.multitestKey : ""); |
| 931 | 889 |
| 932 Set<Expectation> expectations = testExpectations.expectations(testName); | 890 Set<Expectation> expectations = testExpectations.expectations(testName); |
| 933 if (configuration['compiler'] != 'none' && info.hasCompileError) { | 891 if (new CompilerConfiguration(configuration).hasCompiler && |
| 892 info.hasCompileError) { | |
| 934 // If a compile-time error is expected, and we're testing a | 893 // If a compile-time error is expected, and we're testing a |
| 935 // compiler, we never need to attempt to run the program (in a | 894 // compiler, we never need to attempt to run the program (in a |
| 936 // browser or otherwise). | 895 // browser or otherwise). |
| 937 enqueueStandardTest(baseCommands, info, testName, expectations); | 896 enqueueStandardTest(baseCommands, info, testName, expectations); |
| 938 } else if (TestUtils.isBrowserRuntime(configuration['runtime'])) { | 897 } else if (TestUtils.isBrowserRuntime(configuration['runtime'])) { |
| 939 if (info.optionsFromFile['isMultiHtmlTest']) { | 898 if (info.optionsFromFile['isMultiHtmlTest']) { |
| 940 // A browser multi-test has multiple expectations for one test file. | 899 // A browser multi-test has multiple expectations for one test file. |
| 941 // Find all the different sub-test expecations for one entire test file. | 900 // Find all the different sub-test expecations for one entire test file. |
| 942 List<String> subtestNames = info.optionsFromFile['subtestNames']; | 901 List<String> subtestNames = info.optionsFromFile['subtestNames']; |
| 943 Map<String, Set<Expectation>> multiHtmlTestExpectations = {}; | 902 Map<String, Set<Expectation>> multiHtmlTestExpectations = {}; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 989 bool isNegative(TestInformation info) { | 948 bool isNegative(TestInformation info) { |
| 990 bool negative = info.hasCompileError || | 949 bool negative = info.hasCompileError || |
| 991 (configuration['checked'] && info.isNegativeIfChecked); | 950 (configuration['checked'] && info.isNegativeIfChecked); |
| 992 if (info.hasRuntimeError && hasRuntime) { | 951 if (info.hasRuntimeError && hasRuntime) { |
| 993 negative = true; | 952 negative = true; |
| 994 } | 953 } |
| 995 return negative; | 954 return negative; |
| 996 } | 955 } |
| 997 | 956 |
| 998 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { | 957 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { |
| 999 var compiler = configuration['compiler']; | 958 List<Command> commands = <Command>[]; |
| 959 CompilerConfiguration compilerConfiguration = | |
| 960 new CompilerConfiguration(configuration); | |
| 1000 List<String> sharedOptions = info.optionsFromFile['sharedOptions']; | 961 List<String> sharedOptions = info.optionsFromFile['sharedOptions']; |
| 1001 switch (compiler) { | |
| 1002 case 'dart2js': | |
| 1003 args = new List.from(args); | |
| 1004 String tempDir = createCompilationOutputDirectory(info.filePath); | |
| 1005 args.addAll(sharedOptions); | |
| 1006 args.add('--out=$tempDir/out.js'); | |
| 1007 | 962 |
| 1008 var command = CommandBuilder.instance.getCompilationCommand( | 963 List<String> compileTimeArguments = <String>[]; |
| 1009 compiler, "$tempDir/out.js", !useSdk, | 964 String tempDir; |
|
ricow1
2014/03/03 07:47:08
wouldn't a better name be outputDir here?
| |
| 1010 dart2JsBootstrapDependencies, compilerPath, args, | 965 if (compilerConfiguration.hasCompiler) { |
| 1011 environmentOverrides); | 966 compileTimeArguments |
| 967 ..addAll(args) | |
| 968 ..addAll(sharedOptions); | |
| 969 // Avoid doing this for analyzer. | |
| 970 tempDir = createCompilationOutputDirectory(info.filePath); | |
| 971 } | |
| 1012 | 972 |
| 1013 var javascriptFile = '$tempDir/out.js'; | 973 CommandArtifact compilationArtifact = |
| 1014 if (configuration['csp']) { | 974 compilerConfiguration.computeCompilationArtifact( |
| 1015 javascriptFile = '$tempDir/out.precompiled.js'; | 975 buildDir, |
| 1016 } | 976 tempDir, |
| 977 CommandBuilder.instance, | |
| 978 compileTimeArguments, | |
| 979 environmentOverrides); | |
| 980 commands.addAll(compilationArtifact.commands); | |
| 1017 | 981 |
| 1018 List<Command> commands = <Command>[command]; | 982 if (info.hasCompileError && compilerConfiguration.hasCompiler) { |
| 1019 if (info.hasCompileError) { | 983 // Do not attempt to run the compiled result. A compilation |
| 1020 // Do not attempt to run the compiled result. A compilation | 984 // error should be reported by the compilation command. |
| 1021 // error should be reported by the compilation command. | |
| 1022 } else if (configuration['runtime'] == 'd8') { | |
| 1023 commands.add(CommandBuilder.instance.getJSCommandlineCommand( | |
| 1024 "d8", d8FileName, [javascriptFile], environmentOverrides)); | |
| 1025 } else if (configuration['runtime'] == 'jsshell') { | |
| 1026 commands.add(CommandBuilder.instance.getJSCommandlineCommand( | |
| 1027 "jsshell", jsShellFileName, [javascriptFile], | |
| 1028 environmentOverrides)); | |
| 1029 } | |
| 1030 return commands; | 985 return commands; |
| 1031 case 'dart2dart': | 986 } |
| 1032 args = new List.from(args); | |
| 1033 args.addAll(sharedOptions); | |
| 1034 args.add('--output-type=dart'); | |
| 1035 String tempDir = createCompilationOutputDirectory(info.filePath); | |
| 1036 args.add('--out=$tempDir/out.dart'); | |
| 1037 | 987 |
| 1038 List<Command> commands = | 988 RuntimeConfiguration runtimeConfiguration = |
| 1039 <Command>[CommandBuilder.instance.getCompilationCommand( | 989 new RuntimeConfiguration(configuration); |
| 1040 compiler, "$tempDir/out.dart", !useSdk, | 990 List<String> runtimeArguments = |
| 1041 dart2JsBootstrapDependencies, compilerPath, args, | 991 compilerConfiguration.computeRuntimeArguments( |
| 1042 environmentOverrides)]; | 992 runtimeConfiguration, |
| 1043 if (info.hasCompileError) { | 993 info, |
| 1044 // Do not attempt to run the compiled result. A compilation | 994 vmOptions, sharedOptions, args, |
| 1045 // error should be reported by the compilation command. | 995 compilationArtifact); |
| 1046 } else if (configuration['runtime'] == 'vm') { | |
| 1047 // TODO(antonm): support checked. | |
| 1048 var vmArguments = new List.from(vmOptions); | |
| 1049 vmArguments.addAll([ | |
| 1050 '--ignore-unrecognized-flags', '$tempDir/out.dart']); | |
| 1051 commands.add(CommandBuilder.instance.getVmCommand( | |
| 1052 vmFileName, vmArguments, environmentOverrides)); | |
| 1053 } else { | |
| 1054 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; | |
| 1055 } | |
| 1056 return commands; | |
| 1057 | 996 |
| 1058 case 'none': | 997 return commands |
|
ricow1
2014/03/03 07:47:08
I would not do a method cascade here, but call the
| |
| 1059 var arguments = new List.from(vmOptions); | 998 ..addAll( |
| 1060 arguments.addAll(sharedOptions); | 999 runtimeConfiguration.computeRuntimeCommands( |
| 1061 arguments.addAll(args); | 1000 this, |
| 1062 return <Command>[CommandBuilder.instance.getVmCommand( | 1001 CommandBuilder.instance, |
| 1063 dartShellFileName, arguments, environmentOverrides)]; | 1002 compilationArtifact, |
| 1064 | 1003 runtimeArguments, |
| 1065 case 'dartanalyzer': | 1004 environmentOverrides)); |
| 1066 case 'dart2analyzer': | |
| 1067 return <Command>[makeAnalysisCommand(info, args)]; | |
| 1068 | |
| 1069 default: | |
| 1070 throw 'Unknown compiler ${configuration["compiler"]}'; | |
| 1071 } | |
| 1072 } | |
| 1073 | |
| 1074 AnalysisCommand makeAnalysisCommand(TestInformation info, | |
| 1075 List<String> arguments) { | |
| 1076 return CommandBuilder.instance.getAnalysisCommand( | |
| 1077 configuration['compiler'], dartShellFileName, arguments, | |
| 1078 environmentOverrides, | |
| 1079 flavor: configuration['compiler']); | |
| 1080 } | 1005 } |
| 1081 | 1006 |
| 1082 CreateTest makeTestCaseCreator(Map optionsFromFile) { | 1007 CreateTest makeTestCaseCreator(Map optionsFromFile) { |
| 1083 return (Path filePath, | 1008 return (Path filePath, |
| 1084 bool hasCompileError, | 1009 bool hasCompileError, |
| 1085 bool hasRuntimeError, | 1010 bool hasRuntimeError, |
| 1086 {bool isNegativeIfChecked: false, | 1011 {bool isNegativeIfChecked: false, |
| 1087 bool hasStaticWarning: false, | 1012 bool hasStaticWarning: false, |
| 1088 Set<String> multitestOutcome: null, | 1013 Set<String> multitestOutcome: null, |
| 1089 String multitestKey, | 1014 String multitestKey, |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1390 packageRootArgument(optionsFromFile['packageRoot']); | 1315 packageRootArgument(optionsFromFile['packageRoot']); |
| 1391 if (packageRoot != null) { | 1316 if (packageRoot != null) { |
| 1392 args.add(packageRoot); | 1317 args.add(packageRoot); |
| 1393 } | 1318 } |
| 1394 args.add('--out=$outputFile'); | 1319 args.add('--out=$outputFile'); |
| 1395 args.add(inputFile); | 1320 args.add(inputFile); |
| 1396 args.addAll(optionsFromFile['sharedOptions']); | 1321 args.addAll(optionsFromFile['sharedOptions']); |
| 1397 if (executable.endsWith('.dart')) { | 1322 if (executable.endsWith('.dart')) { |
| 1398 // Run the compiler script via the Dart VM. | 1323 // Run the compiler script via the Dart VM. |
| 1399 args.insert(0, executable); | 1324 args.insert(0, executable); |
| 1400 executable = dartShellFileName; | 1325 executable = dartVmBinaryFileName; |
| 1401 } | 1326 } |
| 1402 return CommandBuilder.instance.getCompilationCommand( | 1327 return CommandBuilder.instance.getCompilationCommand( |
| 1403 compiler, outputFile, !useSdk, | 1328 compiler, outputFile, !useSdk, |
| 1404 dart2JsBootstrapDependencies, compilerPath, args, environmentOverrides); | 1329 dart2JsBootstrapDependencies, compilerPath, args, environmentOverrides); |
| 1405 } | 1330 } |
| 1406 | 1331 |
| 1407 /** Helper to create a Polymer deploy command for a single HTML file. */ | 1332 /** Helper to create a Polymer deploy command for a single HTML file. */ |
| 1408 Command _polymerDeployCommand(String inputFile, String outputDir, | 1333 Command _polymerDeployCommand(String inputFile, String outputDir, |
| 1409 optionsFromFile) { | 1334 optionsFromFile) { |
| 1410 List<String> args = []; | 1335 List<String> args = []; |
| 1411 String packageRoot = packageRootArgument(optionsFromFile['packageRoot']); | 1336 String packageRoot = packageRootArgument(optionsFromFile['packageRoot']); |
| 1412 if (packageRoot != null) args.add(packageRoot); | 1337 if (packageRoot != null) args.add(packageRoot); |
| 1413 args..add('package:polymer/deploy.dart') | 1338 args..add('package:polymer/deploy.dart') |
| 1414 ..add('--test')..add(inputFile) | 1339 ..add('--test')..add(inputFile) |
| 1415 ..add('--out')..add(outputDir); | 1340 ..add('--out')..add(outputDir); |
| 1416 if (configuration['csp']) args.add('--csp'); | 1341 if (configuration['csp']) args.add('--csp'); |
| 1417 | 1342 |
| 1418 return CommandBuilder.instance.getProcessCommand( | 1343 return CommandBuilder.instance.getProcessCommand( |
| 1419 'polymer_deploy', vmFileName, args, environmentOverrides); | 1344 'polymer_deploy', dartVmBinaryFileName, args, environmentOverrides); |
| 1420 } | 1345 } |
| 1421 | 1346 |
| 1422 String createGeneratedTestDirectoryHelper( | 1347 String createGeneratedTestDirectoryHelper( |
| 1423 String name, String dirname, Path testPath, String optionsName) { | 1348 String name, String dirname, Path testPath, String optionsName) { |
| 1424 Path relative = testPath.relativeTo(TestUtils.dartDir()); | 1349 Path relative = testPath.relativeTo(TestUtils.dartDir()); |
| 1425 relative = relative.directoryPath.append(relative.filenameWithoutExtension); | 1350 relative = relative.directoryPath.append(relative.filenameWithoutExtension); |
| 1426 String testUniqueName = relative.toString().replaceAll('/', '_'); | 1351 String testUniqueName = relative.toString().replaceAll('/', '_'); |
| 1427 if (!optionsName.isEmpty) { | 1352 if (!optionsName.isEmpty) { |
| 1428 testUniqueName = '$testUniqueName-$optionsName'; | 1353 testUniqueName = '$testUniqueName-$optionsName'; |
| 1429 } | 1354 } |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1807 } | 1732 } |
| 1808 | 1733 |
| 1809 bool isTestFile(String filename) { | 1734 bool isTestFile(String filename) { |
| 1810 var sep = Platform.pathSeparator; | 1735 var sep = Platform.pathSeparator; |
| 1811 // NOTE: We exclude tests and patch files for now. | 1736 // NOTE: We exclude tests and patch files for now. |
| 1812 return filename.endsWith(".dart") && | 1737 return filename.endsWith(".dart") && |
| 1813 !filename.endsWith("_test.dart") && | 1738 !filename.endsWith("_test.dart") && |
| 1814 !filename.contains("_internal/lib"); | 1739 !filename.contains("_internal/lib"); |
| 1815 } | 1740 } |
| 1816 | 1741 |
| 1817 AnalysisCommand makeAnalysisCommand(TestInformation info, | |
| 1818 List<String> arguments) { | |
| 1819 return CommandBuilder.instance.getAnalysisCommand( | |
| 1820 configuration['compiler'], dartShellFileName, arguments, | |
| 1821 environmentOverrides, flavor: configuration['compiler']); | |
| 1822 } | |
| 1823 | |
| 1824 bool get listRecursively => true; | 1742 bool get listRecursively => true; |
| 1825 } | 1743 } |
| 1826 | 1744 |
| 1827 class PkgBuildTestSuite extends TestSuite { | 1745 class PkgBuildTestSuite extends TestSuite { |
| 1828 final String statusFilePath; | 1746 final String statusFilePath; |
| 1829 | 1747 |
| 1830 PkgBuildTestSuite(Map configuration, String suiteName, this.statusFilePath) | 1748 PkgBuildTestSuite(Map configuration, String suiteName, this.statusFilePath) |
| 1831 : super(configuration, suiteName) { | 1749 : super(configuration, suiteName) { |
| 1832 assert(configuration['use_sdk']);; | 1750 assert(configuration['use_sdk']);; |
| 1833 } | 1751 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1878 CommandBuilder.instance.getCopyCommand(directory, checkoutDir)); | 1796 CommandBuilder.instance.getCopyCommand(directory, checkoutDir)); |
| 1879 commands.add(CommandBuilder.instance.getModifyPubspecCommand( | 1797 commands.add(CommandBuilder.instance.getModifyPubspecCommand( |
| 1880 pubspecYamlFile, dependencyOverrides)); | 1798 pubspecYamlFile, dependencyOverrides)); |
| 1881 commands.add(CommandBuilder.instance.getPubCommand( | 1799 commands.add(CommandBuilder.instance.getPubCommand( |
| 1882 "get", pubPath, checkoutDir, cacheDir)); | 1800 "get", pubPath, checkoutDir, cacheDir)); |
| 1883 | 1801 |
| 1884 bool containsWebDirectory = dirExists(directoryPath.append('web')); | 1802 bool containsWebDirectory = dirExists(directoryPath.append('web')); |
| 1885 bool containsBuildDartFile = | 1803 bool containsBuildDartFile = |
| 1886 fileExists(directoryPath.append('build.dart')); | 1804 fileExists(directoryPath.append('build.dart')); |
| 1887 if (containsBuildDartFile) { | 1805 if (containsBuildDartFile) { |
| 1888 var dartBinary = new File(dartPath).absolute.path; | 1806 var dartBinary = new File(dartVmBinaryFileName).absolute.path; |
| 1889 | 1807 |
| 1890 commands.add(CommandBuilder.instance.getProcessCommand( | 1808 commands.add(CommandBuilder.instance.getProcessCommand( |
| 1891 "custom_build", dartBinary, ['build.dart'], null, | 1809 "custom_build", dartBinary, ['build.dart'], null, |
| 1892 checkoutDir)); | 1810 checkoutDir)); |
| 1893 | 1811 |
| 1894 // We only try to deploy the application if it's a webapp. | 1812 // We only try to deploy the application if it's a webapp. |
| 1895 if (containsWebDirectory) { | 1813 if (containsWebDirectory) { |
| 1896 commands.add(CommandBuilder.instance.getProcessCommand( | 1814 commands.add(CommandBuilder.instance.getProcessCommand( |
| 1897 "custom_deploy", dartBinary, ['build.dart', '--deploy'], null, | 1815 "custom_deploy", dartBinary, ['build.dart', '--deploy'], null, |
| 1898 checkoutDir)); | 1816 checkoutDir)); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2053 return ".flaky.log"; | 1971 return ".flaky.log"; |
| 2054 } | 1972 } |
| 2055 | 1973 |
| 2056 static String testOutcomeFileName() { | 1974 static String testOutcomeFileName() { |
| 2057 // If test.py was invoked with '--write-test-outcome-log it will write | 1975 // If test.py was invoked with '--write-test-outcome-log it will write |
| 2058 // test outcomes to this file. | 1976 // test outcomes to this file. |
| 2059 return ".test-outcome.log"; | 1977 return ".test-outcome.log"; |
| 2060 } | 1978 } |
| 2061 | 1979 |
| 2062 static void ensureExists(String filename, Map configuration) { | 1980 static void ensureExists(String filename, Map configuration) { |
| 2063 if (!configuration['list'] && !(new File(filename).existsSync())) { | 1981 if (!configuration['list'] && !existsCache.doesFileExist(filename)) { |
| 2064 throw "Executable '$filename' does not exist"; | 1982 throw "'$filename' does not exist"; |
| 2065 } | 1983 } |
| 2066 } | 1984 } |
| 2067 | 1985 |
| 2068 static Path absolutePath(Path path) { | 1986 static Path absolutePath(Path path) { |
| 2069 if (!path.isAbsolute) { | 1987 if (!path.isAbsolute) { |
| 2070 return currentWorkingDirectory.join(path); | 1988 return currentWorkingDirectory.join(path); |
| 2071 } | 1989 } |
| 2072 return path; | 1990 return path; |
| 2073 } | 1991 } |
| 2074 | 1992 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2264 * $pass tests are expected to pass | 2182 * $pass tests are expected to pass |
| 2265 * $failOk tests are expected to fail that we won't fix | 2183 * $failOk tests are expected to fail that we won't fix |
| 2266 * $fail tests are expected to fail that we should fix | 2184 * $fail tests are expected to fail that we should fix |
| 2267 * $crash tests are expected to crash that we should fix | 2185 * $crash tests are expected to crash that we should fix |
| 2268 * $timeout tests are allowed to timeout | 2186 * $timeout tests are allowed to timeout |
| 2269 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 2187 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 2270 """; | 2188 """; |
| 2271 print(report); | 2189 print(report); |
| 2272 } | 2190 } |
| 2273 } | 2191 } |
| OLD | NEW |