| 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 "dart:math"; | 19 import "dart:math"; |
| 20 import "drt_updater.dart"; | 20 import "drt_updater.dart"; |
| 21 import "html_test.dart" as htmlTest; | 21 import "html_test.dart" as htmlTest; |
| 22 import "http_server.dart"; |
| 22 import "path.dart"; | 23 import "path.dart"; |
| 23 import "multitest.dart"; | 24 import "multitest.dart"; |
| 24 import "expectation.dart"; | 25 import "expectation.dart"; |
| 25 import "expectation_set.dart"; | 26 import "expectation_set.dart"; |
| 26 import "summary_report.dart"; | 27 import "summary_report.dart"; |
| 27 import "test_runner.dart"; | 28 import "test_runner.dart"; |
| 28 import "utils.dart"; | 29 import "utils.dart"; |
| 29 import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR; | 30 import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR; |
| 30 | 31 |
| 31 import "compiler_configuration.dart" | 32 import "compiler_configuration.dart" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 54 bool hasStaticWarning, | 55 bool hasStaticWarning, |
| 55 String multitestKey}); | 56 String multitestKey}); |
| 56 | 57 |
| 57 typedef void VoidFunction(); | 58 typedef void VoidFunction(); |
| 58 | 59 |
| 59 /** | 60 /** |
| 60 * Calls [function] asynchronously. Returns a future that completes with the | 61 * Calls [function] asynchronously. Returns a future that completes with the |
| 61 * result of the function. If the function is `null`, returns a future that | 62 * result of the function. If the function is `null`, returns a future that |
| 62 * completes immediately with `null`. | 63 * completes immediately with `null`. |
| 63 */ | 64 */ |
| 64 Future asynchronously(function()) { | 65 Future asynchronously<T>(T function()) { |
| 65 if (function == null) return new Future.value(null); | 66 if (function == null) return new Future<T>.value(null); |
| 66 | 67 |
| 67 var completer = new Completer(); | 68 var completer = new Completer<T>(); |
| 68 Timer.run(() => completer.complete(function())); | 69 Timer.run(() => completer.complete(function())); |
| 69 | 70 |
| 70 return completer.future; | 71 return completer.future; |
| 71 } | 72 } |
| 72 | 73 |
| 73 /** A completer that waits until all added [Future]s complete. */ | 74 /** A completer that waits until all added [Future]s complete. */ |
| 74 // TODO(rnystrom): Copied from web_components. Remove from here when it gets | 75 // TODO(rnystrom): Copied from web_components. Remove from here when it gets |
| 75 // added to dart:core. (See #6626.) | 76 // added to dart:core. (See #6626.) |
| 76 class FutureGroup { | 77 class FutureGroup { |
| 77 static const _FINISHED = -1; | 78 static const _FINISHED = -1; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 final String suiteName; | 124 final String suiteName; |
| 124 // This function is set by subclasses before enqueueing starts. | 125 // This function is set by subclasses before enqueueing starts. |
| 125 Function doTest; | 126 Function doTest; |
| 126 Map<String, String> _environmentOverrides; | 127 Map<String, String> _environmentOverrides; |
| 127 RuntimeConfiguration runtimeConfiguration; | 128 RuntimeConfiguration runtimeConfiguration; |
| 128 | 129 |
| 129 TestSuite(this.configuration, this.suiteName) { | 130 TestSuite(this.configuration, this.suiteName) { |
| 130 TestUtils.buildDir(configuration); // Sets configuration_directory. | 131 TestUtils.buildDir(configuration); // Sets configuration_directory. |
| 131 if (configuration['configuration_directory'] != null) { | 132 if (configuration['configuration_directory'] != null) { |
| 132 _environmentOverrides = { | 133 _environmentOverrides = { |
| 133 'DART_CONFIGURATION': configuration['configuration_directory'] | 134 'DART_CONFIGURATION': configuration['configuration_directory'] as String |
| 134 }; | 135 }; |
| 135 } | 136 } |
| 136 runtimeConfiguration = new RuntimeConfiguration(configuration); | 137 runtimeConfiguration = new RuntimeConfiguration(configuration); |
| 137 } | 138 } |
| 138 | 139 |
| 139 Map<String, String> get environmentOverrides => _environmentOverrides; | 140 Map<String, String> get environmentOverrides => _environmentOverrides; |
| 140 | 141 |
| 141 /** | 142 /** |
| 142 * Whether or not binaries should be found in the root build directory or | 143 * Whether or not binaries should be found in the root build directory or |
| 143 * in the built SDK. | 144 * in the built SDK. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 154 // rebuilding the SDK, and similarly, it should be convenient for pub | 155 // rebuilding the SDK, and similarly, it should be convenient for pub |
| 155 // developers. | 156 // developers. |
| 156 // Third, even if pub can only run from the SDK directory, this is the | 157 // Third, even if pub can only run from the SDK directory, this is the |
| 157 // wrong place to work around that problem. Instead, test_options.dart | 158 // wrong place to work around that problem. Instead, test_options.dart |
| 158 // should have been modified so that configuration['use_sdk'] is always | 159 // should have been modified so that configuration['use_sdk'] is always |
| 159 // true when testing pub. Attempting to override the value here is brittle | 160 // true when testing pub. Attempting to override the value here is brittle |
| 160 // because we read configuration['use_sdk'] directly in many places without | 161 // because we read configuration['use_sdk'] directly in many places without |
| 161 // using this getter. | 162 // using this getter. |
| 162 if (suiteName == 'pub') return true; | 163 if (suiteName == 'pub') return true; |
| 163 | 164 |
| 164 return configuration['use_sdk']; | 165 return configuration['use_sdk'] as bool; |
| 165 } | 166 } |
| 166 | 167 |
| 167 /** | 168 /** |
| 168 * The output directory for this suite's configuration. | 169 * The output directory for this suite's configuration. |
| 169 */ | 170 */ |
| 170 String get buildDir => TestUtils.buildDir(configuration); | 171 String get buildDir => TestUtils.buildDir(configuration); |
| 171 | 172 |
| 172 /** | 173 /** |
| 173 * The path to the compiler for this suite's configuration. Returns `null` if | 174 * The path to the compiler for this suite's configuration. Returns `null` if |
| 174 * no compiler should be used. | 175 * no compiler should be used. |
| 175 */ | 176 */ |
| 176 String get compilerPath { | 177 String get compilerPath { |
| 177 var compilerConfiguration = new CompilerConfiguration(configuration); | 178 var compilerConfiguration = new CompilerConfiguration(configuration); |
| 178 if (!compilerConfiguration.hasCompiler) return null; | 179 if (!compilerConfiguration.hasCompiler) return null; |
| 179 String name = compilerConfiguration.computeCompilerPath(buildDir); | 180 var name = compilerConfiguration.computeCompilerPath(buildDir); |
| 180 // TODO(ahe): Only validate this once, in test_options.dart. | 181 // TODO(ahe): Only validate this once, in test_options.dart. |
| 181 TestUtils.ensureExists(name, configuration); | 182 TestUtils.ensureExists(name, configuration); |
| 182 return name; | 183 return name; |
| 183 } | 184 } |
| 184 | 185 |
| 185 String get pubPath { | 186 String get pubPath { |
| 186 var prefix = 'sdk/bin/'; | 187 var prefix = 'sdk/bin/'; |
| 187 if (configuration['use_sdk']) { | 188 if (configuration['use_sdk'] as bool) { |
| 188 prefix = '$buildDir/dart-sdk/bin/'; | 189 prefix = '$buildDir/dart-sdk/bin/'; |
| 189 } | 190 } |
| 190 String suffix = getExecutableSuffix('pub'); | 191 var suffix = getExecutableSuffix('pub'); |
| 191 var name = '${prefix}pub$suffix'; | 192 var name = '${prefix}pub$suffix'; |
| 192 TestUtils.ensureExists(name, configuration); | 193 TestUtils.ensureExists(name, configuration); |
| 193 return name; | 194 return name; |
| 194 } | 195 } |
| 195 | 196 |
| 196 /// Returns the name of the Dart VM executable. | 197 /// Returns the name of the Dart VM executable. |
| 197 String get dartVmBinaryFileName { | 198 String get dartVmBinaryFileName { |
| 198 // Controlled by user with the option "--dart". | 199 // Controlled by user with the option "--dart". |
| 199 String dartExecutable = configuration['dart']; | 200 var dartExecutable = configuration['dart'] as String; |
| 200 | 201 |
| 201 if (dartExecutable == '') { | 202 if (dartExecutable == '') { |
| 202 String suffix = executableBinarySuffix; | 203 var suffix = executableBinarySuffix; |
| 203 dartExecutable = useSdk | 204 dartExecutable = useSdk |
| 204 ? '$buildDir/dart-sdk/bin/dart$suffix' | 205 ? '$buildDir/dart-sdk/bin/dart$suffix' |
| 205 : '$buildDir/dart$suffix'; | 206 : '$buildDir/dart$suffix'; |
| 206 } | 207 } |
| 207 | 208 |
| 208 TestUtils.ensureExists(dartExecutable, configuration); | 209 TestUtils.ensureExists(dartExecutable, configuration); |
| 209 return dartExecutable; | 210 return dartExecutable; |
| 210 } | 211 } |
| 211 | 212 |
| 212 /// Returns the name of the flutter engine executable. | 213 /// Returns the name of the flutter engine executable. |
| 213 String get flutterEngineBinaryFileName { | 214 String get flutterEngineBinaryFileName { |
| 214 // Controlled by user with the option "--flutter". | 215 // Controlled by user with the option "--flutter". |
| 215 String flutterExecutable = configuration['flutter']; | 216 var flutterExecutable = configuration['flutter'] as String; |
| 216 TestUtils.ensureExists(flutterExecutable, configuration); | 217 TestUtils.ensureExists(flutterExecutable, configuration); |
| 217 return flutterExecutable; | 218 return flutterExecutable; |
| 218 } | 219 } |
| 219 | 220 |
| 220 String get dartPrecompiledBinaryFileName { | 221 String get dartPrecompiledBinaryFileName { |
| 221 // Controlled by user with the option "--dart_precompiled". | 222 // Controlled by user with the option "--dart_precompiled". |
| 222 String dartExecutable = configuration['dart_precompiled']; | 223 var dartExecutable = configuration['dart_precompiled'] as String; |
| 223 | 224 |
| 224 if (dartExecutable == null || dartExecutable == '') { | 225 if (dartExecutable == null || dartExecutable == '') { |
| 225 String suffix = executableBinarySuffix; | 226 var suffix = executableBinarySuffix; |
| 226 dartExecutable = '$buildDir/dart_precompiled_runtime$suffix'; | 227 dartExecutable = '$buildDir/dart_precompiled_runtime$suffix'; |
| 227 } | 228 } |
| 228 | 229 |
| 229 TestUtils.ensureExists(dartExecutable, configuration); | 230 TestUtils.ensureExists(dartExecutable, configuration); |
| 230 return dartExecutable; | 231 return dartExecutable; |
| 231 } | 232 } |
| 232 | 233 |
| 233 String get processTestBinaryFileName { | 234 String get processTestBinaryFileName { |
| 234 String suffix = executableBinarySuffix; | 235 var suffix = executableBinarySuffix; |
| 235 String processTestExecutable = '$buildDir/process_test$suffix'; | 236 var processTestExecutable = '$buildDir/process_test$suffix'; |
| 236 TestUtils.ensureExists(processTestExecutable, configuration); | 237 TestUtils.ensureExists(processTestExecutable, configuration); |
| 237 return processTestExecutable; | 238 return processTestExecutable; |
| 238 } | 239 } |
| 239 | 240 |
| 240 String get d8FileName { | 241 String get d8FileName { |
| 241 var suffix = getExecutableSuffix('d8'); | 242 var suffix = getExecutableSuffix('d8'); |
| 242 var d8Dir = TestUtils.dartDir.append('third_party/d8'); | 243 var d8Dir = TestUtils.dartDir.append('third_party/d8'); |
| 243 var d8Path = d8Dir.append('${Platform.operatingSystem}/d8$suffix'); | 244 var d8Path = d8Dir.append('${Platform.operatingSystem}/d8$suffix'); |
| 244 var d8 = d8Path.toNativePath(); | 245 var d8 = d8Path.toNativePath(); |
| 245 TestUtils.ensureExists(d8, configuration); | 246 TestUtils.ensureExists(d8, configuration); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 272 String get executableBinarySuffix => Platform.isWindows ? '.exe' : ''; | 273 String get executableBinarySuffix => Platform.isWindows ? '.exe' : ''; |
| 273 | 274 |
| 274 /** | 275 /** |
| 275 * Call the callback function onTest with a [TestCase] argument for each | 276 * Call the callback function onTest with a [TestCase] argument for each |
| 276 * test in the suite. When all tests have been processed, call [onDone]. | 277 * test in the suite. When all tests have been processed, call [onDone]. |
| 277 * | 278 * |
| 278 * The [testCache] argument provides a persistent store that can be used to | 279 * The [testCache] argument provides a persistent store that can be used to |
| 279 * cache information about the test suite, so that directories do not need | 280 * cache information about the test suite, so that directories do not need |
| 280 * to be listed each time. | 281 * to be listed each time. |
| 281 */ | 282 */ |
| 282 void forEachTest(TestCaseEvent onTest, Map testCache, [VoidFunction onDone]); | 283 Future forEachTest( |
| 284 TestCaseEvent onTest, Map<String, List<TestInformation>> testCache, |
| 285 [VoidFunction onDone]); |
| 283 | 286 |
| 284 // This function will be called for every TestCase of this test suite. | 287 // This function will be called for every TestCase of this test suite. |
| 285 // It will | 288 // It will |
| 286 // - handle sharding | 289 // - handle sharding |
| 287 // - update SummaryReport | 290 // - update SummaryReport |
| 288 // - handle SKIP/SKIP_BY_DESIGN markers | 291 // - handle SKIP/SKIP_BY_DESIGN markers |
| 289 // - test if the selector matches | 292 // - test if the selector matches |
| 290 // and will enqueue the test (if necessary). | 293 // and will enqueue the test (if necessary). |
| 291 void enqueueNewTestCase(TestCase testCase) { | 294 void enqueueNewTestCase(TestCase testCase) { |
| 292 if (testCase.isNegative && runtimeConfiguration.shouldSkipNegativeTests) { | 295 if (testCase.isNegative && runtimeConfiguration.shouldSkipNegativeTests) { |
| 293 return; | 296 return; |
| 294 } | 297 } |
| 295 var expectations = testCase.expectedOutcomes; | 298 var expectations = testCase.expectedOutcomes; |
| 296 | 299 |
| 297 // Handle sharding based on the original test path (i.e. all multitests | 300 // Handle sharding based on the original test path (i.e. all multitests |
| 298 // of a given original test belong to the same shard) | 301 // of a given original test belong to the same shard) |
| 299 int shards = configuration['shards']; | 302 var shards = configuration['shards'] as int; |
| 300 if (shards > 1 && testCase.hash % shards != configuration['shard'] - 1) { | 303 if (shards > 1 && |
| 304 testCase.hash % shards != (configuration['shard'] as int) - 1) { |
| 301 return; | 305 return; |
| 302 } | 306 } |
| 303 // Test if the selector includes this test. | 307 // Test if the selector includes this test. |
| 304 RegExp pattern = configuration['selectors'][suiteName]; | 308 var pattern = configuration['selectors'][suiteName] as RegExp; |
| 305 if (!pattern.hasMatch(testCase.displayName)) { | 309 if (!pattern.hasMatch(testCase.displayName)) { |
| 306 return; | 310 return; |
| 307 } | 311 } |
| 308 | 312 |
| 309 if (configuration['hot_reload'] || configuration['hot_reload_rollback']) { | 313 if ((configuration['hot_reload'] as bool) || |
| 314 (configuration['hot_reload_rollback'] as bool)) { |
| 310 // Handle reload special cases. | 315 // Handle reload special cases. |
| 311 if (expectations.contains(Expectation.compileTimeError) || | 316 if (expectations.contains(Expectation.compileTimeError) || |
| 312 testCase.hasCompileError || | 317 testCase.hasCompileError || |
| 313 testCase.expectCompileError) { | 318 testCase.expectCompileError) { |
| 314 // Running a test that expects a compilation error with hot reloading | 319 // Running a test that expects a compilation error with hot reloading |
| 315 // is redundant with a regular run of the test. | 320 // is redundant with a regular run of the test. |
| 316 return; | 321 return; |
| 317 } | 322 } |
| 318 } | 323 } |
| 319 | 324 |
| 320 // Update Summary report | 325 // Update Summary report |
| 321 if (configuration['report']) { | 326 if (configuration['report'] as bool) { |
| 322 if (testCase.expectCompileError && | 327 if (testCase.expectCompileError && |
| 323 TestUtils.isBrowserRuntime(configuration['runtime']) && | 328 TestUtils.isBrowserRuntime(configuration['runtime'] as String) && |
| 324 new CompilerConfiguration(configuration).hasCompiler) { | 329 new CompilerConfiguration(configuration).hasCompiler) { |
| 325 summaryReport.addCompileErrorSkipTest(); | 330 summaryReport.addCompileErrorSkipTest(); |
| 326 return; | 331 return; |
| 327 } else { | 332 } else { |
| 328 summaryReport.add(testCase); | 333 summaryReport.add(testCase); |
| 329 } | 334 } |
| 330 } | 335 } |
| 331 | 336 |
| 332 // Handle skipped tests | 337 // Handle skipped tests |
| 333 if (expectations.contains(Expectation.skip) || | 338 if (expectations.contains(Expectation.skip) || |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 testName = concat(testName, multitestName); | 382 testName = concat(testName, multitestName); |
| 378 return testName; | 383 return testName; |
| 379 } | 384 } |
| 380 | 385 |
| 381 /** | 386 /** |
| 382 * Create a directories for generated assets (tests, html files, | 387 * Create a directories for generated assets (tests, html files, |
| 383 * pubspec checkouts ...). | 388 * pubspec checkouts ...). |
| 384 */ | 389 */ |
| 385 | 390 |
| 386 String createOutputDirectory(Path testPath, String optionsName) { | 391 String createOutputDirectory(Path testPath, String optionsName) { |
| 387 var checked = configuration['checked'] ? '-checked' : ''; | 392 var checked = configuration['checked'] as bool ? '-checked' : ''; |
| 388 var strong = configuration['strong'] ? '-strong' : ''; | 393 var strong = configuration['strong'] as bool ? '-strong' : ''; |
| 389 var minified = configuration['minified'] ? '-minified' : ''; | 394 var minified = configuration['minified'] as bool ? '-minified' : ''; |
| 390 var sdk = configuration['use_sdk'] ? '-sdk' : ''; | 395 var sdk = configuration['use_sdk'] as bool ? '-sdk' : ''; |
| 391 var dirName = "${configuration['compiler']}-${configuration['runtime']}" | 396 var dirName = "${configuration['compiler']}-${configuration['runtime']}" |
| 392 "$checked$strong$minified$sdk"; | 397 "$checked$strong$minified$sdk"; |
| 393 return createGeneratedTestDirectoryHelper( | 398 return createGeneratedTestDirectoryHelper( |
| 394 "tests", dirName, testPath, optionsName); | 399 "tests", dirName, testPath, optionsName); |
| 395 } | 400 } |
| 396 | 401 |
| 397 String createCompilationOutputDirectory(Path testPath) { | 402 String createCompilationOutputDirectory(Path testPath) { |
| 398 var checked = configuration['checked'] ? '-checked' : ''; | 403 var checked = configuration['checked'] as bool ? '-checked' : ''; |
| 399 var strong = configuration['strong'] ? '-strong' : ''; | 404 var strong = configuration['strong'] as bool ? '-strong' : ''; |
| 400 var minified = configuration['minified'] ? '-minified' : ''; | 405 var minified = configuration['minified'] as bool ? '-minified' : ''; |
| 401 var csp = configuration['csp'] ? '-csp' : ''; | 406 var csp = configuration['csp'] as bool ? '-csp' : ''; |
| 402 var sdk = configuration['use_sdk'] ? '-sdk' : ''; | 407 var sdk = configuration['use_sdk'] as bool ? '-sdk' : ''; |
| 403 var dirName = "${configuration['compiler']}" | 408 var dirName = "${configuration['compiler']}" |
| 404 "$checked$strong$minified$csp$sdk"; | 409 "$checked$strong$minified$csp$sdk"; |
| 405 return createGeneratedTestDirectoryHelper( | 410 return createGeneratedTestDirectoryHelper( |
| 406 "compilations", dirName, testPath, ""); | 411 "compilations", dirName, testPath, ""); |
| 407 } | 412 } |
| 408 | 413 |
| 409 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) { | 414 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) { |
| 410 var sdk = configuration['use_sdk'] ? 'sdk' : ''; | 415 var sdk = configuration['use_sdk'] as bool ? 'sdk' : ''; |
| 411 return createGeneratedTestDirectoryHelper( | 416 return createGeneratedTestDirectoryHelper( |
| 412 "pubspec_checkouts", sdk, directoryOfPubspecYaml, ""); | 417 "pubspec_checkouts", sdk, directoryOfPubspecYaml, ""); |
| 413 } | 418 } |
| 414 | 419 |
| 415 String createPubPackageBuildsDirectory(Path directoryOfPubspecYaml) { | 420 String createPubPackageBuildsDirectory(Path directoryOfPubspecYaml) { |
| 416 return createGeneratedTestDirectoryHelper( | 421 return createGeneratedTestDirectoryHelper( |
| 417 "pub_package_builds", 'public_packages', directoryOfPubspecYaml, ""); | 422 "pub_package_builds", 'public_packages', directoryOfPubspecYaml, ""); |
| 418 } | 423 } |
| 419 } | 424 } |
| 420 | 425 |
| 421 Future<Iterable<String>> ccTestLister(String runnerPath) { | 426 Future<Iterable<String>> ccTestLister(String runnerPath) { |
| 422 return Process.run(runnerPath, ["--list"]).then((ProcessResult result) { | 427 return Process.run(runnerPath, ["--list"]).then((ProcessResult result) { |
| 423 if (result.exitCode != 0) { | 428 if (result.exitCode != 0) { |
| 424 throw "Failed to list tests: '$runnerPath --list'. " | 429 throw "Failed to list tests: '$runnerPath --list'. " |
| 425 "Process exited with ${result.exitCode}"; | 430 "Process exited with ${result.exitCode}"; |
| 426 } | 431 } |
| 427 return result.stdout | 432 return (result.stdout as String) |
| 428 .split('\n') | 433 .split('\n') |
| 429 .map((line) => line.trim()) | 434 .map((line) => line.trim()) |
| 430 .where((name) => name.isNotEmpty); | 435 .where((name) => name.isNotEmpty); |
| 431 }); | 436 }); |
| 432 } | 437 } |
| 433 | 438 |
| 434 /** | 439 /** |
| 435 * A specialized [TestSuite] that runs tests written in C to unit test | 440 * A specialized [TestSuite] that runs tests written in C to unit test |
| 436 * the Dart virtual machine and its API. | 441 * the Dart virtual machine and its API. |
| 437 * | 442 * |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 * * Test files are directly in that directory and end in "_test.dart". | 613 * * Test files are directly in that directory and end in "_test.dart". |
| 609 * | 614 * |
| 610 * If you follow that convention, then you can construct one of these like: | 615 * If you follow that convention, then you can construct one of these like: |
| 611 * | 616 * |
| 612 * new StandardTestSuite.forDirectory(configuration, 'path/to/mytestsuite'); | 617 * new StandardTestSuite.forDirectory(configuration, 'path/to/mytestsuite'); |
| 613 * | 618 * |
| 614 * instead of having to create a custom [StandardTestSuite] subclass. In | 619 * instead of having to create a custom [StandardTestSuite] subclass. In |
| 615 * particular, if you add 'path/to/mytestsuite' to [TEST_SUITE_DIRECTORIES] | 620 * particular, if you add 'path/to/mytestsuite' to [TEST_SUITE_DIRECTORIES] |
| 616 * in test.dart, this will all be set up for you. | 621 * in test.dart, this will all be set up for you. |
| 617 */ | 622 */ |
| 618 factory StandardTestSuite.forDirectory(Map configuration, Path directory) { | 623 factory StandardTestSuite.forDirectory( |
| 624 Map<String, dynamic> configuration, Path directory) { |
| 619 var name = directory.filename; | 625 var name = directory.filename; |
| 620 var status_paths = [ | 626 var status_paths = [ |
| 621 '$directory/$name.status', | 627 '$directory/$name.status', |
| 622 '$directory/.status', | 628 '$directory/.status', |
| 623 '$directory/${name}_dart2js.status', | 629 '$directory/${name}_dart2js.status', |
| 624 '$directory/${name}_analyzer2.status', | 630 '$directory/${name}_analyzer2.status', |
| 625 '$directory/${name}_kernel.status' | 631 '$directory/${name}_kernel.status' |
| 626 ]; | 632 ]; |
| 627 | 633 |
| 628 return new StandardTestSuite(configuration, name, directory, status_paths, | 634 return new StandardTestSuite(configuration, name, directory, status_paths, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 639 bool isTestFile(String filename) { | 645 bool isTestFile(String filename) { |
| 640 // Use the specified predicate, if provided. | 646 // Use the specified predicate, if provided. |
| 641 if (isTestFilePredicate != null) return isTestFilePredicate(filename); | 647 if (isTestFilePredicate != null) return isTestFilePredicate(filename); |
| 642 return filename.endsWith("Test.dart"); | 648 return filename.endsWith("Test.dart"); |
| 643 } | 649 } |
| 644 | 650 |
| 645 bool isHtmlTestFile(String filename) => filename.endsWith('_htmltest.html'); | 651 bool isHtmlTestFile(String filename) => filename.endsWith('_htmltest.html'); |
| 646 | 652 |
| 647 List<String> additionalOptions(Path filePath) => []; | 653 List<String> additionalOptions(Path filePath) => []; |
| 648 | 654 |
| 649 forEachTest(Function onTest, Map testCache, [VoidFunction onDone]) async { | 655 Future forEachTest( |
| 656 Function onTest, Map<String, List<TestInformation>> testCache, |
| 657 [VoidFunction onDone]) async { |
| 650 await updateDartium(); | 658 await updateDartium(); |
| 651 doTest = onTest; | 659 doTest = onTest; |
| 652 testExpectations = readExpectations(); | 660 testExpectations = readExpectations(); |
| 653 | 661 |
| 654 // Check if we have already found and generated the tests for this suite. | 662 // Check if we have already found and generated the tests for this suite. |
| 655 if (!testCache.containsKey(suiteName)) { | 663 if (!testCache.containsKey(suiteName)) { |
| 656 cachedTests = testCache[suiteName] = <TestInformation>[]; | 664 cachedTests = testCache[suiteName] = <TestInformation>[]; |
| 657 await enqueueTests(); | 665 await enqueueTests(); |
| 658 } else { | 666 } else { |
| 659 for (var info in testCache[suiteName]) { | 667 for (var info in testCache[suiteName]) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 cachedTests.add(info); | 740 cachedTests.add(info); |
| 733 enqueueTestCaseFromTestInformation(info); | 741 enqueueTestCaseFromTestInformation(info); |
| 734 return; | 742 return; |
| 735 } | 743 } |
| 736 if (!isTestFile(filename)) return; | 744 if (!isTestFile(filename)) return; |
| 737 Path filePath = new Path(filename); | 745 Path filePath = new Path(filename); |
| 738 | 746 |
| 739 var optionsFromFile = readOptionsFromFile(filePath); | 747 var optionsFromFile = readOptionsFromFile(filePath); |
| 740 CreateTest createTestCase = makeTestCaseCreator(optionsFromFile); | 748 CreateTest createTestCase = makeTestCaseCreator(optionsFromFile); |
| 741 | 749 |
| 742 if (optionsFromFile['isMultitest']) { | 750 if (optionsFromFile['isMultitest'] as bool) { |
| 743 group.add(doMultitest( | 751 group.add(doMultitest( |
| 744 filePath, | 752 filePath, |
| 745 buildDir, | 753 buildDir, |
| 746 suiteDir, | 754 suiteDir, |
| 747 createTestCase, | 755 createTestCase, |
| 748 (configuration['hot_reload'] || | 756 ((configuration['hot_reload'] as bool) || |
| 749 configuration['hot_reload_rollback']))); | 757 (configuration['hot_reload_rollback'] as bool)))); |
| 750 } else { | 758 } else { |
| 751 createTestCase(filePath, filePath, optionsFromFile['hasCompileError'], | 759 createTestCase( |
| 752 optionsFromFile['hasRuntimeError'], | 760 filePath, |
| 753 hasStaticWarning: optionsFromFile['hasStaticWarning']); | 761 filePath, |
| 762 optionsFromFile['hasCompileError'] as bool, |
| 763 optionsFromFile['hasRuntimeError'] as bool, |
| 764 hasStaticWarning: optionsFromFile['hasStaticWarning'] as bool); |
| 754 } | 765 } |
| 755 } | 766 } |
| 756 | 767 |
| 757 static Path _findPubspecYamlFile(Path filePath) { | 768 static Path _findPubspecYamlFile(Path filePath) { |
| 758 final existsCache = TestUtils.existsCache; | 769 final existsCache = TestUtils.existsCache; |
| 759 | 770 |
| 760 Path root = TestUtils.dartDir; | 771 Path root = TestUtils.dartDir; |
| 761 assert("$filePath".startsWith("$root")); | 772 assert("$filePath".startsWith("$root")); |
| 762 | 773 |
| 763 // We start with the parent directory of [filePath] and go up until | 774 // We start with the parent directory of [filePath] and go up until |
| 764 // the root directory (excluding the root). | 775 // the root directory (excluding the root). |
| 765 List<String> segments = filePath.directoryPath.relativeTo(root).segments(); | 776 List<String> segments = filePath.directoryPath.relativeTo(root).segments(); |
| 766 while (segments.length > 0) { | 777 while (segments.length > 0) { |
| 767 var pubspecYamlPath = new Path(segments.join('/')).append('pubspec.yaml'); | 778 var pubspecYamlPath = new Path(segments.join('/')).append('pubspec.yaml'); |
| 768 if (existsCache.doesFileExist(pubspecYamlPath.toNativePath())) { | 779 if (existsCache.doesFileExist(pubspecYamlPath.toNativePath())) { |
| 769 return root.join(pubspecYamlPath); | 780 return root.join(pubspecYamlPath); |
| 770 } | 781 } |
| 771 segments.removeLast(); | 782 segments.removeLast(); |
| 772 } | 783 } |
| 773 return null; | 784 return null; |
| 774 } | 785 } |
| 775 | 786 |
| 776 void enqueueTestCaseFromTestInformation(TestInformation info) { | 787 void enqueueTestCaseFromTestInformation(TestInformation info) { |
| 777 String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath, | 788 String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath, |
| 778 multitestName: | 789 multitestName: info.optionsFromFile['isMultitest'] as bool |
| 779 info.optionsFromFile['isMultitest'] ? info.multitestKey : ""); | 790 ? info.multitestKey |
| 791 : ""); |
| 780 Set<Expectation> expectations = testExpectations.expectations(testName); | 792 Set<Expectation> expectations = testExpectations.expectations(testName); |
| 781 if (info is HtmlTestInformation) { | 793 if (info is HtmlTestInformation) { |
| 782 enqueueHtmlTest(info, testName, expectations); | 794 enqueueHtmlTest(info, testName, expectations); |
| 783 return; | 795 return; |
| 784 } | 796 } |
| 785 var optionsFromFile = info.optionsFromFile; | 797 var optionsFromFile = info.optionsFromFile; |
| 786 | 798 |
| 787 // If this test is inside a package, we will check if there is a | 799 // If this test is inside a package, we will check if there is a |
| 788 // pubspec.yaml file and if so, create a custom package root for it. | 800 // pubspec.yaml file and if so, create a custom package root for it. |
| 789 List<Command> baseCommands = <Command>[]; | 801 List<Command> baseCommands = <Command>[]; |
| 790 Path packageRoot; | 802 Path packageRoot; |
| 791 Path packages; | 803 Path packages; |
| 792 | 804 |
| 793 if (optionsFromFile['packageRoot'] == null && | 805 if (optionsFromFile['packageRoot'] == null && |
| 794 optionsFromFile['packages'] == null) { | 806 optionsFromFile['packages'] == null) { |
| 795 if (configuration['package_root'] != null) { | 807 if (configuration['package_root'] != null) { |
| 796 packageRoot = new Path(configuration['package_root']); | 808 packageRoot = new Path(configuration['package_root'] as String); |
| 797 optionsFromFile['packageRoot'] = packageRoot.toNativePath(); | 809 optionsFromFile['packageRoot'] = packageRoot.toNativePath(); |
| 798 } | 810 } |
| 799 if (configuration['packages'] != null) { | 811 if (configuration['packages'] != null) { |
| 800 Path packages = new Path(configuration['packages']); | 812 Path packages = new Path(configuration['packages'] as String); |
| 801 optionsFromFile['packages'] = packages.toNativePath(); | 813 optionsFromFile['packages'] = packages.toNativePath(); |
| 802 } | 814 } |
| 803 } | 815 } |
| 804 if (new CompilerConfiguration(configuration).hasCompiler && | 816 if (new CompilerConfiguration(configuration).hasCompiler && |
| 805 expectCompileError(info)) { | 817 expectCompileError(info)) { |
| 806 // If a compile-time error is expected, and we're testing a | 818 // If a compile-time error is expected, and we're testing a |
| 807 // compiler, we never need to attempt to run the program (in a | 819 // compiler, we never need to attempt to run the program (in a |
| 808 // browser or otherwise). | 820 // browser or otherwise). |
| 809 enqueueStandardTest(baseCommands, info, testName, expectations); | 821 enqueueStandardTest(baseCommands, info, testName, expectations); |
| 810 } else if (TestUtils.isBrowserRuntime(configuration['runtime'])) { | 822 } else if (TestUtils.isBrowserRuntime(configuration['runtime'] as String)) { |
| 811 if (info.optionsFromFile['isMultiHtmlTest']) { | 823 if (info.optionsFromFile['isMultiHtmlTest'] as bool) { |
| 812 // A browser multi-test has multiple expectations for one test file. | 824 // A browser multi-test has multiple expectations for one test file. |
| 813 // Find all the different sub-test expecations for one entire test file. | 825 // Find all the different sub-test expecations for one entire test file. |
| 814 List<String> subtestNames = info.optionsFromFile['subtestNames']; | 826 var subtestNames = info.optionsFromFile['subtestNames'] as List<String>; |
| 815 Map<String, Set<Expectation>> multiHtmlTestExpectations = {}; | 827 var multiHtmlTestExpectations = <String, Set<Expectation>>{}; |
| 816 for (String name in subtestNames) { | 828 for (var name in subtestNames) { |
| 817 String fullTestName = '$testName/$name'; | 829 var fullTestName = '$testName/$name'; |
| 818 multiHtmlTestExpectations[fullTestName] = | 830 multiHtmlTestExpectations[fullTestName] = |
| 819 testExpectations.expectations(fullTestName); | 831 testExpectations.expectations(fullTestName); |
| 820 } | 832 } |
| 821 enqueueBrowserTest(baseCommands, packageRoot, packages, info, testName, | 833 enqueueBrowserTest(baseCommands, packageRoot, packages, info, testName, |
| 822 multiHtmlTestExpectations); | 834 multiHtmlTestExpectations); |
| 823 } else { | 835 } else { |
| 824 enqueueBrowserTest( | 836 enqueueBrowserTest( |
| 825 baseCommands, packageRoot, packages, info, testName, expectations); | 837 baseCommands, packageRoot, packages, info, testName, expectations); |
| 826 } | 838 } |
| 827 } else { | 839 } else { |
| 828 enqueueStandardTest(baseCommands, info, testName, expectations); | 840 enqueueStandardTest(baseCommands, info, testName, expectations); |
| 829 } | 841 } |
| 830 } | 842 } |
| 831 | 843 |
| 832 void enqueueStandardTest(List<Command> baseCommands, TestInformation info, | 844 void enqueueStandardTest(List<Command> baseCommands, TestInformation info, |
| 833 String testName, Set<Expectation> expectations) { | 845 String testName, Set<Expectation> expectations) { |
| 834 var commonArguments = | 846 var commonArguments = |
| 835 commonArgumentsFromFile(info.filePath, info.optionsFromFile); | 847 commonArgumentsFromFile(info.filePath, info.optionsFromFile); |
| 836 | 848 |
| 837 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); | 849 var vmOptionsList = getVmOptions(info.optionsFromFile); |
| 838 assert(!vmOptionsList.isEmpty); | 850 assert(!vmOptionsList.isEmpty); |
| 839 | 851 |
| 840 for (var vmOptionsVariant = 0; | 852 for (var vmOptionsVariant = 0; |
| 841 vmOptionsVariant < vmOptionsList.length; | 853 vmOptionsVariant < vmOptionsList.length; |
| 842 vmOptionsVariant++) { | 854 vmOptionsVariant++) { |
| 843 var vmOptions = vmOptionsList[vmOptionsVariant]; | 855 var vmOptions = vmOptionsList[vmOptionsVariant]; |
| 844 var allVmOptions = vmOptions; | 856 var allVmOptions = vmOptions; |
| 845 if (!extraVmOptions.isEmpty) { | 857 if (!extraVmOptions.isEmpty) { |
| 846 allVmOptions = new List.from(vmOptions)..addAll(extraVmOptions); | 858 allVmOptions = vmOptions.toList()..addAll(extraVmOptions); |
| 847 } | 859 } |
| 848 | 860 |
| 849 var commands = baseCommands.toList(); | 861 var commands = baseCommands.toList(); |
| 850 commands.addAll( | 862 commands.addAll( |
| 851 makeCommands(info, vmOptionsVariant, allVmOptions, commonArguments)); | 863 makeCommands(info, vmOptionsVariant, allVmOptions, commonArguments)); |
| 852 enqueueNewTestCase(new TestCase( | 864 enqueueNewTestCase(new TestCase( |
| 853 '$suiteName/$testName', commands, configuration, expectations, | 865 '$suiteName/$testName', commands, configuration, expectations, |
| 854 isNegative: isNegative(info), info: info)); | 866 isNegative: isNegative(info), info: info)); |
| 855 } | 867 } |
| 856 } | 868 } |
| 857 | 869 |
| 858 bool expectCompileError(TestInformation info) { | 870 bool expectCompileError(TestInformation info) { |
| 859 return info.hasCompileError || | 871 return info.hasCompileError || |
| 860 (configuration['checked'] && info.hasCompileErrorIfChecked); | 872 ((configuration['checked'] as bool) && info.hasCompileErrorIfChecked); |
| 861 } | 873 } |
| 862 | 874 |
| 863 bool isNegative(TestInformation info) { | 875 bool isNegative(TestInformation info) { |
| 864 bool negative = expectCompileError(info) || | 876 bool negative = expectCompileError(info) || |
| 865 (configuration['checked'] && info.isNegativeIfChecked); | 877 ((configuration['checked'] as bool) && info.isNegativeIfChecked); |
| 866 if (info.hasRuntimeError && hasRuntime) { | 878 if (info.hasRuntimeError && hasRuntime) { |
| 867 negative = true; | 879 negative = true; |
| 868 } | 880 } |
| 869 return negative; | 881 return negative; |
| 870 } | 882 } |
| 871 | 883 |
| 872 List<Command> makeCommands(TestInformation info, int vmOptionsVarient, | 884 List<Command> makeCommands(TestInformation info, int vmOptionsVarient, |
| 873 List<String> vmOptions, List<String> args) { | 885 List<String> vmOptions, List<String> args) { |
| 874 var commands = <Command>[]; | 886 var commands = <Command>[]; |
| 875 var compilerConfiguration = new CompilerConfiguration(configuration); | 887 var compilerConfiguration = new CompilerConfiguration(configuration); |
| 876 List<String> sharedOptions = info.optionsFromFile['sharedOptions']; | 888 var sharedOptions = info.optionsFromFile['sharedOptions'] as List<String>; |
| 877 | 889 |
| 878 var compileTimeArguments = <String>[]; | 890 var compileTimeArguments = <String>[]; |
| 879 String tempDir; | 891 String tempDir; |
| 880 if (compilerConfiguration.hasCompiler) { | 892 if (compilerConfiguration.hasCompiler) { |
| 881 compileTimeArguments = compilerConfiguration.computeCompilerArguments( | 893 compileTimeArguments = compilerConfiguration.computeCompilerArguments( |
| 882 vmOptions, sharedOptions, args); | 894 vmOptions, sharedOptions, args); |
| 883 // Avoid doing this for analyzer. | 895 // Avoid doing this for analyzer. |
| 884 var path = info.filePath; | 896 var path = info.filePath; |
| 885 if (vmOptionsVarient != 0) { | 897 if (vmOptionsVarient != 0) { |
| 886 // Ensure a unique directory for each test case. | 898 // Ensure a unique directory for each test case. |
| 887 path = path.join(new Path(vmOptionsVarient.toString())); | 899 path = path.join(new Path(vmOptionsVarient.toString())); |
| 888 } | 900 } |
| 889 tempDir = createCompilationOutputDirectory(path); | 901 tempDir = createCompilationOutputDirectory(path); |
| 890 | 902 |
| 891 List<String> otherResources = info.optionsFromFile['otherResources']; | 903 var otherResources = |
| 904 info.optionsFromFile['otherResources'] as List<String>; |
| 892 for (var name in otherResources) { | 905 for (var name in otherResources) { |
| 893 var namePath = new Path(name); | 906 var namePath = new Path(name); |
| 894 var fromPath = info.filePath.directoryPath.join(namePath); | 907 var fromPath = info.filePath.directoryPath.join(namePath); |
| 895 new File('$tempDir/$name').parent.createSync(recursive: true); | 908 new File('$tempDir/$name').parent.createSync(recursive: true); |
| 896 new File(fromPath.toNativePath()).copySync('$tempDir/$name'); | 909 new File(fromPath.toNativePath()).copySync('$tempDir/$name'); |
| 897 } | 910 } |
| 898 } | 911 } |
| 899 | 912 |
| 900 CommandArtifact compilationArtifact = | 913 CommandArtifact compilationArtifact = |
| 901 compilerConfiguration.computeCompilationArtifact( | 914 compilerConfiguration.computeCompilationArtifact( |
| 902 buildDir, | 915 buildDir, |
| 903 tempDir, | 916 tempDir, |
| 904 CommandBuilder.instance, | 917 CommandBuilder.instance, |
| 905 compileTimeArguments, | 918 compileTimeArguments, |
| 906 environmentOverrides); | 919 environmentOverrides); |
| 907 if (!configuration['skip-compilation']) { | 920 if (!(configuration['skip-compilation'] as bool)) { |
| 908 commands.addAll(compilationArtifact.commands); | 921 commands.addAll(compilationArtifact.commands); |
| 909 } | 922 } |
| 910 | 923 |
| 911 if (expectCompileError(info) && compilerConfiguration.hasCompiler) { | 924 if (expectCompileError(info) && compilerConfiguration.hasCompiler) { |
| 912 // Do not attempt to run the compiled result. A compilation | 925 // Do not attempt to run the compiled result. A compilation |
| 913 // error should be reported by the compilation command. | 926 // error should be reported by the compilation command. |
| 914 return commands; | 927 return commands; |
| 915 } | 928 } |
| 916 | 929 |
| 917 List<String> runtimeArguments = | 930 List<String> runtimeArguments = |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 } | 994 } |
| 982 // Unreachable | 995 // Unreachable |
| 983 print("Cannot create URL for path $file. Not in build or dart directory."); | 996 print("Cannot create URL for path $file. Not in build or dart directory."); |
| 984 exit(1); | 997 exit(1); |
| 985 return null; | 998 return null; |
| 986 } | 999 } |
| 987 | 1000 |
| 988 Uri _getUriForBrowserTest(String pathComponent, String subtestName) { | 1001 Uri _getUriForBrowserTest(String pathComponent, String subtestName) { |
| 989 // Note: If we run test.py with the "--list" option, no http servers | 1002 // Note: If we run test.py with the "--list" option, no http servers |
| 990 // will be started. So we return a dummy url instead. | 1003 // will be started. So we return a dummy url instead. |
| 991 if (configuration['list']) { | 1004 if (configuration['list'] as bool) { |
| 992 return Uri.parse('http://listing_the_tests_only'); | 1005 return Uri.parse('http://listing_the_tests_only'); |
| 993 } | 1006 } |
| 994 assert(configuration.containsKey('_servers_')); | 1007 assert(configuration.containsKey('_servers_')); |
| 995 int serverPort = configuration['_servers_'].port; | 1008 var servers = configuration['_servers_'] as TestingServers; |
| 996 int crossOriginPort = configuration['_servers_'].crossOriginPort; | 1009 var serverPort = servers.port; |
| 1010 var crossOriginPort = servers.crossOriginPort; |
| 997 var parameters = {'crossOriginPort': crossOriginPort.toString()}; | 1011 var parameters = {'crossOriginPort': crossOriginPort.toString()}; |
| 998 if (subtestName != null) { | 1012 if (subtestName != null) { |
| 999 parameters['group'] = subtestName; | 1013 parameters['group'] = subtestName; |
| 1000 } | 1014 } |
| 1001 return new Uri( | 1015 return new Uri( |
| 1002 scheme: 'http', | 1016 scheme: 'http', |
| 1003 host: configuration['local_ip'], | 1017 host: configuration['local_ip'] as String, |
| 1004 port: serverPort, | 1018 port: serverPort, |
| 1005 path: pathComponent, | 1019 path: pathComponent, |
| 1006 queryParameters: parameters); | 1020 queryParameters: parameters); |
| 1007 } | 1021 } |
| 1008 | 1022 |
| 1009 void _createWrapperFile( | 1023 void _createWrapperFile( |
| 1010 String dartWrapperFilename, Path localDartLibraryFilename) { | 1024 String dartWrapperFilename, Path localDartLibraryFilename) { |
| 1011 File file = new File(dartWrapperFilename); | 1025 File file = new File(dartWrapperFilename); |
| 1012 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE); | 1026 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE); |
| 1013 | 1027 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1031 * compilation and many browser runs). | 1045 * compilation and many browser runs). |
| 1032 */ | 1046 */ |
| 1033 void enqueueBrowserTest( | 1047 void enqueueBrowserTest( |
| 1034 List<Command> baseCommands, | 1048 List<Command> baseCommands, |
| 1035 Path packageRoot, | 1049 Path packageRoot, |
| 1036 Path packages, | 1050 Path packages, |
| 1037 TestInformation info, | 1051 TestInformation info, |
| 1038 String testName, | 1052 String testName, |
| 1039 /* Set<Expectation> | Map<String, Set<Expectation>> */ dynamic | 1053 /* Set<Expectation> | Map<String, Set<Expectation>> */ dynamic |
| 1040 expectations) { | 1054 expectations) { |
| 1041 RegExp badChars = new RegExp('[-=/]'); | 1055 var badChars = new RegExp('[-=/]'); |
| 1042 List VmOptionsList = getVmOptions(info.optionsFromFile); | 1056 var vmOptionsList = getVmOptions(info.optionsFromFile); |
| 1043 bool multipleOptions = VmOptionsList.length > 1; | 1057 var multipleOptions = vmOptionsList.length > 1; |
| 1044 for (var vmOptions in VmOptionsList) { | 1058 for (var vmOptions in vmOptionsList) { |
| 1045 String optionsName = | 1059 var optionsName = |
| 1046 multipleOptions ? vmOptions.join('-').replaceAll(badChars, '') : ''; | 1060 multipleOptions ? vmOptions.join('-').replaceAll(badChars, '') : ''; |
| 1047 String tempDir = createOutputDirectory(info.filePath, optionsName); | 1061 var tempDir = createOutputDirectory(info.filePath, optionsName); |
| 1048 enqueueBrowserTestWithOptions(baseCommands, packageRoot, packages, info, | 1062 enqueueBrowserTestWithOptions(baseCommands, packageRoot, packages, info, |
| 1049 testName, expectations, vmOptions, tempDir); | 1063 testName, expectations, vmOptions, tempDir); |
| 1050 } | 1064 } |
| 1051 } | 1065 } |
| 1052 | 1066 |
| 1053 void enqueueBrowserTestWithOptions( | 1067 void enqueueBrowserTestWithOptions( |
| 1054 List<Command> baseCommands, | 1068 List<Command> baseCommands, |
| 1055 Path packageRoot, | 1069 Path packageRoot, |
| 1056 Path packages, | 1070 Path packages, |
| 1057 TestInformation info, | 1071 TestInformation info, |
| 1058 String testName, | 1072 String testName, |
| 1059 /* Set<Expectation> | Map<String, Set<Expectation>> */ expectations, | 1073 /* Set<Expectation> | Map<String, Set<Expectation>> */ expectations, |
| 1060 List<String> vmOptions, | 1074 List<String> vmOptions, |
| 1061 String tempDir) { | 1075 String tempDir) { |
| 1062 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot] | 1076 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot] |
| 1063 // on to the browser (it may be test specific). | 1077 // on to the browser (it may be test specific). |
| 1064 | 1078 |
| 1065 Path filePath = info.filePath; | 1079 Path filePath = info.filePath; |
| 1066 String filename = filePath.toString(); | 1080 String filename = filePath.toString(); |
| 1067 | 1081 |
| 1068 final String compiler = configuration['compiler']; | 1082 var compiler = configuration['compiler'] as String; |
| 1069 final String runtime = configuration['runtime']; | 1083 var runtime = configuration['runtime'] as String; |
| 1070 final Map optionsFromFile = info.optionsFromFile; | 1084 final Map optionsFromFile = info.optionsFromFile; |
| 1071 | 1085 |
| 1072 final String compilationTempDir = | 1086 final String compilationTempDir = |
| 1073 createCompilationOutputDirectory(info.filePath); | 1087 createCompilationOutputDirectory(info.filePath); |
| 1074 | 1088 |
| 1075 String dartWrapperFilename = '$tempDir/test.dart'; | 1089 String dartWrapperFilename = '$tempDir/test.dart'; |
| 1076 String compiledDartWrapperFilename = '$compilationTempDir/test.js'; | 1090 String compiledDartWrapperFilename = '$compilationTempDir/test.js'; |
| 1077 | 1091 |
| 1078 String content = null; | 1092 String content = null; |
| 1079 Path dir = filePath.directoryPath; | 1093 Path dir = filePath.directoryPath; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 htmlTest.writeStringSync(content); | 1165 htmlTest.writeStringSync(content); |
| 1152 htmlTest.closeSync(); | 1166 htmlTest.closeSync(); |
| 1153 } | 1167 } |
| 1154 | 1168 |
| 1155 if (compiler != 'none') { | 1169 if (compiler != 'none') { |
| 1156 commands.add(_compileCommand(dartWrapperFilename, | 1170 commands.add(_compileCommand(dartWrapperFilename, |
| 1157 compiledDartWrapperFilename, compiler, tempDir, optionsFromFile)); | 1171 compiledDartWrapperFilename, compiler, tempDir, optionsFromFile)); |
| 1158 } | 1172 } |
| 1159 | 1173 |
| 1160 // some tests require compiling multiple input scripts. | 1174 // some tests require compiling multiple input scripts. |
| 1161 List<String> otherScripts = optionsFromFile['otherScripts']; | 1175 var otherScripts = optionsFromFile['otherScripts'] as List<String>; |
| 1162 for (String name in otherScripts) { | 1176 for (var name in otherScripts) { |
| 1163 Path namePath = new Path(name); | 1177 var namePath = new Path(name); |
| 1164 String fileName = namePath.filename; | 1178 var fileName = namePath.filename; |
| 1165 Path fromPath = filePath.directoryPath.join(namePath); | 1179 var fromPath = filePath.directoryPath.join(namePath); |
| 1166 if (compiler != 'none') { | 1180 if (compiler != 'none') { |
| 1167 assert(namePath.extension == 'dart'); | 1181 assert(namePath.extension == 'dart'); |
| 1168 commands.add(_compileCommand(fromPath.toNativePath(), | 1182 commands.add(_compileCommand(fromPath.toNativePath(), |
| 1169 '$tempDir/$fileName.js', compiler, tempDir, optionsFromFile)); | 1183 '$tempDir/$fileName.js', compiler, tempDir, optionsFromFile)); |
| 1170 } | 1184 } |
| 1171 if (compiler == 'none') { | 1185 if (compiler == 'none') { |
| 1172 // For the tests that require multiple input scripts but are not | 1186 // For the tests that require multiple input scripts but are not |
| 1173 // compiled, move the input scripts over with the script so they can | 1187 // compiled, move the input scripts over with the script so they can |
| 1174 // be accessed. | 1188 // be accessed. |
| 1175 String result = new File(fromPath.toNativePath()).readAsStringSync(); | 1189 var result = new File(fromPath.toNativePath()).readAsStringSync(); |
| 1176 new File('$tempDir/$fileName').writeAsStringSync(result); | 1190 new File('$tempDir/$fileName').writeAsStringSync(result); |
| 1177 } | 1191 } |
| 1178 } | 1192 } |
| 1179 | 1193 |
| 1180 // Variables for browser multi-tests. | 1194 // Variables for browser multi-tests. |
| 1181 bool multitest = info.optionsFromFile['isMultiHtmlTest']; | 1195 var multitest = info.optionsFromFile['isMultiHtmlTest'] as bool; |
| 1182 List<String> subtestNames = | 1196 var subtestNames = multitest |
| 1183 multitest ? info.optionsFromFile['subtestNames'] : [null]; | 1197 ? (info.optionsFromFile['subtestNames'] as List<String>) |
| 1184 for (String subtestName in subtestNames) { | 1198 : <String>[null]; |
| 1199 for (var subtestName in subtestNames) { |
| 1185 // Construct the command that executes the browser test | 1200 // Construct the command that executes the browser test |
| 1186 List<Command> commandSet = new List<Command>.from(commands); | 1201 var commandSet = commands.toList(); |
| 1187 | 1202 |
| 1188 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); | 1203 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); |
| 1189 var fullHtmlPath = | 1204 var fullHtmlPath = |
| 1190 _getUriForBrowserTest(htmlPath_subtest, subtestName).toString(); | 1205 _getUriForBrowserTest(htmlPath_subtest, subtestName).toString(); |
| 1191 | 1206 |
| 1192 if (runtime == "drt") { | 1207 if (runtime == "drt") { |
| 1193 var dartFlags = <String>[]; | 1208 var dartFlags = <String>[]; |
| 1194 var contentShellOptions = ['--no-timeout', '--run-layout-test']; | 1209 var contentShellOptions = ['--no-timeout', '--run-layout-test']; |
| 1195 | 1210 |
| 1196 // Disable the GPU under Linux and Dartium. If the GPU is enabled, | 1211 // Disable the GPU under Linux and Dartium. If the GPU is enabled, |
| 1197 // Chrome may send a termination signal to a test. The test will be | 1212 // Chrome may send a termination signal to a test. The test will be |
| 1198 // terminated if a machine (bot) doesn't have a GPU or if a test is | 1213 // terminated if a machine (bot) doesn't have a GPU or if a test is |
| 1199 // still running after a certain period of time. | 1214 // still running after a certain period of time. |
| 1200 if (configuration['system'] == 'linux' && | 1215 if (configuration['system'] == 'linux' && |
| 1201 configuration['runtime'] == 'drt') { | 1216 configuration['runtime'] == 'drt') { |
| 1202 contentShellOptions.add('--disable-gpu'); | 1217 contentShellOptions.add('--disable-gpu'); |
| 1203 // TODO(terry): Roll 50 need this in conjection with disable-gpu. | 1218 // TODO(terry): Roll 50 need this in conjection with disable-gpu. |
| 1204 contentShellOptions.add('--disable-gpu-early-init'); | 1219 contentShellOptions.add('--disable-gpu-early-init'); |
| 1205 } | 1220 } |
| 1206 if (compiler == 'none') { | 1221 if (compiler == 'none') { |
| 1207 dartFlags.add('--ignore-unrecognized-flags'); | 1222 dartFlags.add('--ignore-unrecognized-flags'); |
| 1208 if (configuration["checked"]) { | 1223 if (configuration["checked"] as bool) { |
| 1209 dartFlags.add('--enable_asserts'); | 1224 dartFlags.add('--enable_asserts'); |
| 1210 dartFlags.add("--enable_type_checks"); | 1225 dartFlags.add("--enable_type_checks"); |
| 1211 } | 1226 } |
| 1212 dartFlags.addAll(vmOptions); | 1227 dartFlags.addAll(vmOptions); |
| 1213 } | 1228 } |
| 1214 | 1229 |
| 1215 commandSet.add(CommandBuilder.instance.getContentShellCommand( | 1230 commandSet.add(CommandBuilder.instance.getContentShellCommand( |
| 1216 contentShellFilename, | 1231 contentShellFilename, |
| 1217 fullHtmlPath, | 1232 fullHtmlPath, |
| 1218 contentShellOptions, | 1233 contentShellOptions, |
| 1219 dartFlags, | 1234 dartFlags, |
| 1220 environmentOverrides)); | 1235 environmentOverrides)); |
| 1221 } else { | 1236 } else { |
| 1222 commandSet.add(CommandBuilder.instance.getBrowserTestCommand( | 1237 commandSet.add(CommandBuilder.instance.getBrowserTestCommand( |
| 1223 runtime, fullHtmlPath, configuration, !isNegative(info))); | 1238 runtime, fullHtmlPath, configuration, !isNegative(info))); |
| 1224 } | 1239 } |
| 1225 | 1240 |
| 1226 // Create BrowserTestCase and queue it. | 1241 // Create BrowserTestCase and queue it. |
| 1227 var fullTestName = multitest ? '$testName/$subtestName' : testName; | 1242 var fullTestName = multitest ? '$testName/$subtestName' : testName; |
| 1228 var expectation = multitest ? expectations[fullTestName] : expectations; | 1243 var expectation = (multitest ? expectations[fullTestName] : expectations) |
| 1244 as Set<Expectation>; |
| 1229 var testCase = new BrowserTestCase('$suiteName/$fullTestName', commandSet, | 1245 var testCase = new BrowserTestCase('$suiteName/$fullTestName', commandSet, |
| 1230 configuration, expectation, info, isNegative(info), fullHtmlPath); | 1246 configuration, expectation, info, isNegative(info), fullHtmlPath); |
| 1231 | 1247 |
| 1232 enqueueNewTestCase(testCase); | 1248 enqueueNewTestCase(testCase); |
| 1233 } | 1249 } |
| 1234 } | 1250 } |
| 1235 | 1251 |
| 1236 void enqueueHtmlTest(HtmlTestInformation info, String testName, | 1252 void enqueueHtmlTest(HtmlTestInformation info, String testName, |
| 1237 Set<Expectation> expectations) { | 1253 Set<Expectation> expectations) { |
| 1238 final String compiler = configuration['compiler']; | 1254 var compiler = configuration['compiler'] as String; |
| 1239 final String runtime = configuration['runtime']; | 1255 var runtime = configuration['runtime'] as String; |
| 1240 // Html tests work only with the browser controller. | 1256 // Html tests work only with the browser controller. |
| 1241 if (!TestUtils.isBrowserRuntime(runtime) || runtime == 'drt') { | 1257 if (!TestUtils.isBrowserRuntime(runtime) || runtime == 'drt') { |
| 1242 return; | 1258 return; |
| 1243 } | 1259 } |
| 1244 bool compileToJS = (compiler == 'dart2js'); | 1260 bool compileToJS = (compiler == 'dart2js'); |
| 1245 | 1261 |
| 1246 final Path filePath = info.filePath; | 1262 final Path filePath = info.filePath; |
| 1247 final String tempDir = createOutputDirectory(filePath, ''); | 1263 final String tempDir = createOutputDirectory(filePath, ''); |
| 1248 final Uri tempUri = new Uri.file('$tempDir/'); | 1264 final Uri tempUri = new Uri.file('$tempDir/'); |
| 1249 String contents = htmlTest.getContents(info, compileToJS); | 1265 String contents = htmlTest.getContents(info, compileToJS); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 String dir, Map optionsFromFile) { | 1321 String dir, Map optionsFromFile) { |
| 1306 assert(compiler == 'dart2js'); | 1322 assert(compiler == 'dart2js'); |
| 1307 List<String> args; | 1323 List<String> args; |
| 1308 if (compilerPath.endsWith('.dart')) { | 1324 if (compilerPath.endsWith('.dart')) { |
| 1309 // Run the compiler script via the Dart VM. | 1325 // Run the compiler script via the Dart VM. |
| 1310 args = [compilerPath]; | 1326 args = [compilerPath]; |
| 1311 } else { | 1327 } else { |
| 1312 args = []; | 1328 args = []; |
| 1313 } | 1329 } |
| 1314 args.addAll(TestUtils.standardOptions(configuration)); | 1330 args.addAll(TestUtils.standardOptions(configuration)); |
| 1315 String packages = packagesArgument( | 1331 var packages = packagesArgument(optionsFromFile['packageRoot'] as String, |
| 1316 optionsFromFile['packageRoot'], optionsFromFile['packages']); | 1332 optionsFromFile['packages'] as String); |
| 1317 if (packages != null) args.add(packages); | 1333 if (packages != null) args.add(packages); |
| 1318 args.add('--out=$outputFile'); | 1334 args.add('--out=$outputFile'); |
| 1319 args.add(inputFile); | 1335 args.add(inputFile); |
| 1320 List<String> options = optionsFromFile['sharedOptions']; | 1336 var options = optionsFromFile['sharedOptions'] as List<String>; |
| 1321 if (options != null) args.addAll(options); | 1337 if (options != null) args.addAll(options); |
| 1322 return CommandBuilder.instance.getCompilationCommand( | 1338 return CommandBuilder.instance.getCompilationCommand( |
| 1323 compiler, | 1339 compiler, |
| 1324 outputFile, | 1340 outputFile, |
| 1325 !useSdk, | 1341 !useSdk, |
| 1326 dart2JsBootstrapDependencies, | 1342 dart2JsBootstrapDependencies, |
| 1327 compilerPath, | 1343 compilerPath, |
| 1328 args, | 1344 args, |
| 1329 environmentOverrides); | 1345 environmentOverrides); |
| 1330 } | 1346 } |
| 1331 | 1347 |
| 1332 /** Helper to create a Polymer deploy command for a single HTML file. */ | 1348 /** Helper to create a Polymer deploy command for a single HTML file. */ |
| 1333 Command _polymerDeployCommand( | 1349 Command _polymerDeployCommand( |
| 1334 String inputFile, String outputDir, Map optionsFromFile) { | 1350 String inputFile, String outputDir, Map optionsFromFile) { |
| 1335 List<String> args = []; | 1351 List<String> args = []; |
| 1336 String packages = packagesArgument( | 1352 String packages = packagesArgument(optionsFromFile['packageRoot'] as String, |
| 1337 optionsFromFile['packageRoot'], optionsFromFile['packages']); | 1353 optionsFromFile['packages'] as String); |
| 1338 if (packages != null) args.add(packages); | 1354 if (packages != null) args.add(packages); |
| 1339 args | 1355 args |
| 1340 ..add('package:polymer/deploy.dart') | 1356 ..add('package:polymer/deploy.dart') |
| 1341 ..add('--test') | 1357 ..add('--test') |
| 1342 ..add(inputFile) | 1358 ..add(inputFile) |
| 1343 ..add('--out') | 1359 ..add('--out') |
| 1344 ..add(outputDir) | 1360 ..add(outputDir) |
| 1345 ..add('--file-filter') | 1361 ..add('--file-filter') |
| 1346 ..add('.svn'); | 1362 ..add('.svn'); |
| 1347 if (configuration['csp']) args.add('--csp'); | 1363 if (configuration['csp'] as bool) args.add('--csp'); |
| 1348 | 1364 |
| 1349 return CommandBuilder.instance.getProcessCommand( | 1365 return CommandBuilder.instance.getProcessCommand( |
| 1350 'polymer_deploy', dartVmBinaryFileName, args, environmentOverrides); | 1366 'polymer_deploy', dartVmBinaryFileName, args, environmentOverrides); |
| 1351 } | 1367 } |
| 1352 | 1368 |
| 1353 String get scriptType { | 1369 String get scriptType { |
| 1354 switch (configuration['compiler']) { | 1370 switch (configuration['compiler'] as String) { |
| 1355 case 'none': | 1371 case 'none': |
| 1356 return 'application/dart'; | 1372 return 'application/dart'; |
| 1357 case 'dart2js': | 1373 case 'dart2js': |
| 1358 case 'dart2analyzer': | 1374 case 'dart2analyzer': |
| 1359 return 'text/javascript'; | 1375 return 'text/javascript'; |
| 1360 default: | 1376 default: |
| 1361 print('Non-web runtime, so no scriptType for: ' | 1377 print('Non-web runtime, so no scriptType for: ' |
| 1362 '${configuration["compiler"]}'); | 1378 '${configuration["compiler"]}'); |
| 1363 exit(1); | 1379 exit(1); |
| 1364 return null; | 1380 return null; |
| 1365 } | 1381 } |
| 1366 } | 1382 } |
| 1367 | 1383 |
| 1368 bool get hasRuntime { | 1384 bool get hasRuntime { |
| 1369 switch (configuration['runtime']) { | 1385 switch (configuration['runtime'] as String) { |
| 1370 case 'none': | 1386 case 'none': |
| 1371 return false; | 1387 return false; |
| 1372 default: | 1388 default: |
| 1373 return true; | 1389 return true; |
| 1374 } | 1390 } |
| 1375 } | 1391 } |
| 1376 | 1392 |
| 1377 String get contentShellFilename { | 1393 String get contentShellFilename { |
| 1378 if (configuration['drt'] != '') { | 1394 if (configuration['drt'] != '') { |
| 1379 return configuration['drt']; | 1395 return configuration['drt'] as String; |
| 1380 } | 1396 } |
| 1381 if (Platform.operatingSystem == 'macos') { | 1397 if (Platform.operatingSystem == 'macos') { |
| 1382 final path = dartDir.append( | 1398 final path = dartDir.append( |
| 1383 '/client/tests/drt/Content Shell.app/Contents/MacOS/Content Shell'); | 1399 '/client/tests/drt/Content Shell.app/Contents/MacOS/Content Shell'); |
| 1384 return path.toNativePath(); | 1400 return path.toNativePath(); |
| 1385 } | 1401 } |
| 1386 return dartDir.append('client/tests/drt/content_shell').toNativePath(); | 1402 return dartDir.append('client/tests/drt/content_shell').toNativePath(); |
| 1387 } | 1403 } |
| 1388 | 1404 |
| 1389 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { | 1405 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { |
| 1390 var args = TestUtils.standardOptions(configuration); | 1406 var args = TestUtils.standardOptions(configuration); |
| 1391 | 1407 |
| 1392 String packages = packagesArgument( | 1408 String packages = packagesArgument(optionsFromFile['packageRoot'] as String, |
| 1393 optionsFromFile['packageRoot'], optionsFromFile['packages']); | 1409 optionsFromFile['packages'] as String); |
| 1394 if (packages != null) { | 1410 if (packages != null) { |
| 1395 args.add(packages); | 1411 args.add(packages); |
| 1396 } | 1412 } |
| 1397 args.addAll(additionalOptions(filePath)); | 1413 args.addAll(additionalOptions(filePath)); |
| 1398 if (configuration['analyzer']) { | 1414 if (configuration['analyzer'] as bool) { |
| 1399 args.add('--format=machine'); | 1415 args.add('--format=machine'); |
| 1400 args.add('--no-hints'); | 1416 args.add('--no-hints'); |
| 1401 } | 1417 } |
| 1402 | 1418 |
| 1403 if (configuration["compiler"] == "dart2analyzer" && | 1419 if (configuration["compiler"] == "dart2analyzer" && |
| 1404 (filePath.filename.contains("dart2js") || | 1420 (filePath.filename.contains("dart2js") || |
| 1405 filePath.directoryPath.segments().last.contains('html_common'))) { | 1421 filePath.directoryPath.segments().last.contains('html_common'))) { |
| 1406 args.add("--use-dart2js-libraries"); | 1422 args.add("--use-dart2js-libraries"); |
| 1407 } | 1423 } |
| 1408 | 1424 |
| 1409 bool isMultitest = optionsFromFile["isMultitest"]; | 1425 var isMultitest = optionsFromFile["isMultitest"] as bool; |
| 1410 List<String> dartOptions = optionsFromFile["dartOptions"]; | 1426 var dartOptions = optionsFromFile["dartOptions"] as List<String>; |
| 1411 | 1427 |
| 1412 assert(!isMultitest || dartOptions == null); | 1428 assert(!isMultitest || dartOptions == null); |
| 1413 args.add(filePath.toNativePath()); | 1429 args.add(filePath.toNativePath()); |
| 1414 if (dartOptions != null) { | 1430 if (dartOptions != null) { |
| 1415 args.addAll(dartOptions); | 1431 args.addAll(dartOptions); |
| 1416 } | 1432 } |
| 1417 | 1433 |
| 1418 return args; | 1434 return args; |
| 1419 } | 1435 } |
| 1420 | 1436 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 } | 1588 } |
| 1573 packages = match[1]; | 1589 packages = match[1]; |
| 1574 if (packages != 'none') { | 1590 if (packages != 'none') { |
| 1575 // Packages=none means that no packages or package-root option | 1591 // Packages=none means that no packages or package-root option |
| 1576 // should be given. Any other value overrides packages and removes | 1592 // should be given. Any other value overrides packages and removes |
| 1577 // any package-root option. Don't use with // PackageRoot=. | 1593 // any package-root option. Don't use with // PackageRoot=. |
| 1578 packages = '${filePath.directoryPath.join(new Path(packages))}'; | 1594 packages = '${filePath.directoryPath.join(new Path(packages))}'; |
| 1579 } | 1595 } |
| 1580 } | 1596 } |
| 1581 | 1597 |
| 1582 List<String> otherScripts = new List<String>(); | 1598 var otherScripts = <String>[]; |
| 1583 matches = otherScriptsRegExp.allMatches(contents); | 1599 matches = otherScriptsRegExp.allMatches(contents); |
| 1584 for (var match in matches) { | 1600 for (var match in matches) { |
| 1585 otherScripts.addAll(match[1].split(' ').where((e) => e != '').toList()); | 1601 otherScripts.addAll(match[1].split(' ').where((e) => e != '').toList()); |
| 1586 } | 1602 } |
| 1587 | 1603 |
| 1588 List<String> otherResources = new List<String>(); | 1604 var otherResources = <String>[]; |
| 1589 matches = otherResourcesRegExp.allMatches(contents); | 1605 matches = otherResourcesRegExp.allMatches(contents); |
| 1590 for (var match in matches) { | 1606 for (var match in matches) { |
| 1591 otherResources.addAll(match[1].split(' ').where((e) => e != '').toList()); | 1607 otherResources.addAll(match[1].split(' ').where((e) => e != '').toList()); |
| 1592 } | 1608 } |
| 1593 | 1609 |
| 1594 bool isMultitest = multiTestRegExp.hasMatch(contents); | 1610 var isMultitest = multiTestRegExp.hasMatch(contents); |
| 1595 bool isMultiHtmlTest = multiHtmlTestRegExp.hasMatch(contents); | 1611 var isMultiHtmlTest = multiHtmlTestRegExp.hasMatch(contents); |
| 1596 Match isolateMatch = isolateStubsRegExp.firstMatch(contents); | 1612 var isolateMatch = isolateStubsRegExp.firstMatch(contents); |
| 1597 String isolateStubs = isolateMatch != null ? isolateMatch[1] : ''; | 1613 var isolateStubs = isolateMatch != null ? isolateMatch[1] : ''; |
| 1598 bool containsDomImport = domImportRegExp.hasMatch(contents); | 1614 var containsDomImport = domImportRegExp.hasMatch(contents); |
| 1599 | 1615 |
| 1600 List<String> subtestNames = []; | 1616 var subtestNames = <String>[]; |
| 1601 Iterator matchesIter = | 1617 var matchesIter = multiHtmlTestGroupRegExp.allMatches(contents).iterator; |
| 1602 multiHtmlTestGroupRegExp.allMatches(contents).iterator; | |
| 1603 while (matchesIter.moveNext() && isMultiHtmlTest) { | 1618 while (matchesIter.moveNext() && isMultiHtmlTest) { |
| 1604 String fullMatch = matchesIter.current.group(0); | 1619 var fullMatch = matchesIter.current.group(0); |
| 1605 subtestNames.add(fullMatch.substring(fullMatch.indexOf("'") + 1)); | 1620 subtestNames.add(fullMatch.substring(fullMatch.indexOf("'") + 1)); |
| 1606 } | 1621 } |
| 1607 | 1622 |
| 1608 return { | 1623 return { |
| 1609 "vmOptions": result, | 1624 "vmOptions": result, |
| 1610 "sharedOptions": sharedOptions == null ? [] : sharedOptions, | 1625 "sharedOptions": sharedOptions ?? [], |
| 1611 "dartOptions": dartOptions, | 1626 "dartOptions": dartOptions, |
| 1612 "packageRoot": packageRoot, | 1627 "packageRoot": packageRoot, |
| 1613 "packages": packages, | 1628 "packages": packages, |
| 1614 "hasCompileError": false, | 1629 "hasCompileError": false, |
| 1615 "hasRuntimeError": false, | 1630 "hasRuntimeError": false, |
| 1616 "hasStaticWarning": false, | 1631 "hasStaticWarning": false, |
| 1617 "otherScripts": otherScripts, | 1632 "otherScripts": otherScripts, |
| 1618 "otherResources": otherResources, | 1633 "otherResources": otherResources, |
| 1619 "isMultitest": isMultitest, | 1634 "isMultitest": isMultitest, |
| 1620 "isMultiHtmlTest": isMultiHtmlTest, | 1635 "isMultiHtmlTest": isMultiHtmlTest, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1650 'dart_precompiled', | 1665 'dart_precompiled', |
| 1651 'vm', | 1666 'vm', |
| 1652 'drt', | 1667 'drt', |
| 1653 'dartium', | 1668 'dartium', |
| 1654 'ContentShellOnAndroid', | 1669 'ContentShellOnAndroid', |
| 1655 'DartiumOnAndroid' | 1670 'DartiumOnAndroid' |
| 1656 ]; | 1671 ]; |
| 1657 var needsVmOptions = COMPILERS.contains(configuration['compiler']) && | 1672 var needsVmOptions = COMPILERS.contains(configuration['compiler']) && |
| 1658 RUNTIMES.contains(configuration['runtime']); | 1673 RUNTIMES.contains(configuration['runtime']); |
| 1659 if (!needsVmOptions) return [[]]; | 1674 if (!needsVmOptions) return [[]]; |
| 1660 return optionsFromFile['vmOptions']; | 1675 return optionsFromFile['vmOptions'] as List<List<String>>; |
| 1661 } | 1676 } |
| 1662 | 1677 |
| 1663 /** | 1678 /** |
| 1664 * Read options from a co19 test file. | 1679 * Read options from a co19 test file. |
| 1665 * | 1680 * |
| 1666 * The reason this is different from [readOptionsFromFile] is that | 1681 * The reason this is different from [readOptionsFromFile] is that |
| 1667 * co19 is developed based on a contract which defines certain test | 1682 * co19 is developed based on a contract which defines certain test |
| 1668 * tags. These tags may appear unused, but should not be removed | 1683 * tags. These tags may appear unused, but should not be removed |
| 1669 * without consulting with the co19 team. | 1684 * without consulting with the co19 team. |
| 1670 * | 1685 * |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1698 "subtestNames": <String>[], | 1713 "subtestNames": <String>[], |
| 1699 "isolateStubs": '', | 1714 "isolateStubs": '', |
| 1700 "containsDomImport": false, | 1715 "containsDomImport": false, |
| 1701 }; | 1716 }; |
| 1702 } | 1717 } |
| 1703 } | 1718 } |
| 1704 | 1719 |
| 1705 /// Used for testing packages in on off settings, i.e., we pass in the actual | 1720 /// Used for testing packages in on off settings, i.e., we pass in the actual |
| 1706 /// directory that we want to test. | 1721 /// directory that we want to test. |
| 1707 class PKGTestSuite extends StandardTestSuite { | 1722 class PKGTestSuite extends StandardTestSuite { |
| 1708 PKGTestSuite(Map configuration, Path directoryPath) | 1723 PKGTestSuite(Map<String, dynamic> configuration, Path directoryPath) |
| 1709 : super(configuration, directoryPath.filename, directoryPath, | 1724 : super(configuration, directoryPath.filename, directoryPath, |
| 1710 ["$directoryPath/.status"], | 1725 ["$directoryPath/.status"], |
| 1711 isTestFilePredicate: (f) => f.endsWith('_test.dart'), | 1726 isTestFilePredicate: (f) => f.endsWith('_test.dart'), |
| 1712 recursive: true); | 1727 recursive: true); |
| 1713 | 1728 |
| 1714 void enqueueBrowserTest( | 1729 void enqueueBrowserTest( |
| 1715 List<Command> baseCommands, | 1730 List<Command> baseCommands, |
| 1716 Path packageRoot, | 1731 Path packageRoot, |
| 1717 packages, | 1732 packages, |
| 1718 TestInformation info, | 1733 TestInformation info, |
| 1719 String testName, | 1734 String testName, |
| 1720 /* Set<Expectation> | Map<String, Set<Expectation>> */ dynamic | 1735 /* Set<Expectation> | Map<String, Set<Expectation>> */ dynamic |
| 1721 expectations) { | 1736 expectations) { |
| 1722 String runtime = configuration['runtime']; | 1737 var runtime = configuration['runtime'] as String; |
| 1723 Path filePath = info.filePath; | 1738 var filePath = info.filePath; |
| 1724 Path dir = filePath.directoryPath; | 1739 var dir = filePath.directoryPath; |
| 1725 String nameNoExt = filePath.filenameWithoutExtension; | 1740 var nameNoExt = filePath.filenameWithoutExtension; |
| 1726 Path customHtmlPath = dir.append('$nameNoExt.html'); | 1741 var customHtmlPath = dir.append('$nameNoExt.html'); |
| 1727 File customHtml = new File(customHtmlPath.toNativePath()); | 1742 var customHtml = new File(customHtmlPath.toNativePath()); |
| 1728 if (!customHtml.existsSync()) { | 1743 if (!customHtml.existsSync()) { |
| 1729 super.enqueueBrowserTest( | 1744 super.enqueueBrowserTest( |
| 1730 baseCommands, packageRoot, packages, info, testName, expectations); | 1745 baseCommands, packageRoot, packages, info, testName, expectations); |
| 1731 } else { | 1746 } else { |
| 1732 Path relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir); | 1747 var relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir); |
| 1733 var commands = baseCommands.toList(); | 1748 var commands = baseCommands.toList(); |
| 1734 var fullPath = _createUrlPathFromFile(customHtmlPath); | 1749 var fullPath = _createUrlPathFromFile(customHtmlPath); |
| 1735 | 1750 |
| 1736 commands.add(CommandBuilder.instance.getBrowserTestCommand( | 1751 commands.add(CommandBuilder.instance.getBrowserTestCommand( |
| 1737 runtime, fullPath, configuration, !isNegative(info))); | 1752 runtime, fullPath, configuration, !isNegative(info))); |
| 1738 String testDisplayName = '$suiteName/$testName'; | 1753 var testDisplayName = '$suiteName/$testName'; |
| 1739 enqueueNewTestCase(new BrowserTestCase( | 1754 enqueueNewTestCase(new BrowserTestCase( |
| 1740 testDisplayName, | 1755 testDisplayName, |
| 1741 commands, | 1756 commands, |
| 1742 configuration, | 1757 configuration, |
| 1743 expectations, | 1758 expectations as Set<Expectation>, |
| 1744 info, | 1759 info, |
| 1745 isNegative(info), | 1760 isNegative(info), |
| 1746 relativeHtml.toNativePath())); | 1761 relativeHtml.toNativePath())); |
| 1747 } | 1762 } |
| 1748 } | 1763 } |
| 1749 } | 1764 } |
| 1750 | 1765 |
| 1751 /// A DartcCompilationTestSuite will run dartc on all of the tests. | 1766 /// A DartcCompilationTestSuite will run dartc on all of the tests. |
| 1752 /// | 1767 /// |
| 1753 /// Usually, the result of a dartc run is determined by the output of | 1768 /// Usually, the result of a dartc run is determined by the output of |
| 1754 /// dartc in connection with annotations in the test file. | 1769 /// dartc in connection with annotations in the test file. |
| 1755 class DartcCompilationTestSuite extends StandardTestSuite { | 1770 class DartcCompilationTestSuite extends StandardTestSuite { |
| 1756 List<String> _testDirs; | 1771 List<String> _testDirs; |
| 1757 | 1772 |
| 1758 DartcCompilationTestSuite( | 1773 DartcCompilationTestSuite( |
| 1759 Map configuration, | 1774 Map<String, dynamic> configuration, |
| 1760 String suiteName, | 1775 String suiteName, |
| 1761 String directoryPath, | 1776 String directoryPath, |
| 1762 List<String> this._testDirs, | 1777 List<String> this._testDirs, |
| 1763 List<String> expectations) | 1778 List<String> expectations) |
| 1764 : super(configuration, suiteName, new Path(directoryPath), expectations); | 1779 : super(configuration, suiteName, new Path(directoryPath), expectations); |
| 1765 | 1780 |
| 1766 List<String> additionalOptions(Path filePath) { | 1781 List<String> additionalOptions(Path filePath) { |
| 1767 return ['--fatal-warnings', '--fatal-type-errors']; | 1782 return ['--fatal-warnings', '--fatal-type-errors']; |
| 1768 } | 1783 } |
| 1769 | 1784 |
| 1770 Future enqueueTests() { | 1785 Future enqueueTests() { |
| 1771 var group = new FutureGroup(); | 1786 var group = new FutureGroup(); |
| 1772 | 1787 |
| 1773 for (String testDir in _testDirs) { | 1788 for (String testDir in _testDirs) { |
| 1774 Directory dir = new Directory(suiteDir.append(testDir).toNativePath()); | 1789 Directory dir = new Directory(suiteDir.append(testDir).toNativePath()); |
| 1775 if (dir.existsSync()) { | 1790 if (dir.existsSync()) { |
| 1776 enqueueDirectory(dir, group); | 1791 enqueueDirectory(dir, group); |
| 1777 } | 1792 } |
| 1778 } | 1793 } |
| 1779 | 1794 |
| 1780 return group.future; | 1795 return group.future; |
| 1781 } | 1796 } |
| 1782 } | 1797 } |
| 1783 | 1798 |
| 1784 class AnalyzeLibraryTestSuite extends DartcCompilationTestSuite { | 1799 class AnalyzeLibraryTestSuite extends DartcCompilationTestSuite { |
| 1785 static String libraryPath(Map configuration) => configuration['use_sdk'] | 1800 static String libraryPath(Map<String, dynamic> configuration) => |
| 1786 ? '${TestUtils.buildDir(configuration)}/dart-sdk' | 1801 configuration['use_sdk'] as bool |
| 1787 : 'sdk'; | 1802 ? '${TestUtils.buildDir(configuration)}/dart-sdk' |
| 1803 : 'sdk'; |
| 1788 | 1804 |
| 1789 AnalyzeLibraryTestSuite(Map configuration) | 1805 AnalyzeLibraryTestSuite(Map<String, dynamic> configuration) |
| 1790 : super(configuration, 'analyze_library', libraryPath(configuration), | 1806 : super(configuration, 'analyze_library', libraryPath(configuration), |
| 1791 ['lib'], ['tests/lib/analyzer/analyze_library.status']); | 1807 ['lib'], ['tests/lib/analyzer/analyze_library.status']); |
| 1792 | 1808 |
| 1793 List<String> additionalOptions(Path filePath, {bool showSdkWarnings}) { | 1809 List<String> additionalOptions(Path filePath, {bool showSdkWarnings}) { |
| 1794 var options = super.additionalOptions(filePath); | 1810 var options = super.additionalOptions(filePath); |
| 1795 options.add('--sdk-warnings'); | 1811 options.add('--sdk-warnings'); |
| 1796 return options; | 1812 return options; |
| 1797 } | 1813 } |
| 1798 | 1814 |
| 1799 bool isTestFile(String filename) { | 1815 bool isTestFile(String filename) { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1946 } else { | 1962 } else { |
| 1947 var dir = new Directory(path); | 1963 var dir = new Directory(path); |
| 1948 return dir.delete(recursive: true); | 1964 return dir.delete(recursive: true); |
| 1949 } | 1965 } |
| 1950 } | 1966 } |
| 1951 | 1967 |
| 1952 static void deleteTempSnapshotDirectory(Map configuration) { | 1968 static void deleteTempSnapshotDirectory(Map configuration) { |
| 1953 if (configuration['compiler'] == 'dart2app' || | 1969 if (configuration['compiler'] == 'dart2app' || |
| 1954 configuration['compiler'] == 'dart2appjit' || | 1970 configuration['compiler'] == 'dart2appjit' || |
| 1955 configuration['compiler'] == 'precompiler') { | 1971 configuration['compiler'] == 'precompiler') { |
| 1956 var checked = configuration['checked'] ? '-checked' : ''; | 1972 var checked = (configuration['checked'] as bool) ? '-checked' : ''; |
| 1957 var strong = configuration['strong'] ? '-strong' : ''; | 1973 var strong = (configuration['strong'] as bool) ? '-strong' : ''; |
| 1958 var minified = configuration['minified'] ? '-minified' : ''; | 1974 var minified = (configuration['minified'] as bool) ? '-minified' : ''; |
| 1959 var csp = configuration['csp'] ? '-csp' : ''; | 1975 var csp = (configuration['csp'] as bool) ? '-csp' : ''; |
| 1960 var sdk = configuration['use_sdk'] ? '-sdk' : ''; | 1976 var sdk = (configuration['use_sdk'] as bool) ? '-sdk' : ''; |
| 1961 var dirName = "${configuration['compiler']}" | 1977 var dirName = "${configuration['compiler']}" |
| 1962 "$checked$strong$minified$csp$sdk"; | 1978 "$checked$strong$minified$csp$sdk"; |
| 1963 String generatedPath = "${TestUtils.buildDir(configuration)}" | 1979 String generatedPath = "${TestUtils.buildDir(configuration)}" |
| 1964 "/generated_compilations/$dirName"; | 1980 "/generated_compilations/$dirName"; |
| 1965 TestUtils.deleteDirectory(generatedPath); | 1981 TestUtils.deleteDirectory(generatedPath); |
| 1966 } | 1982 } |
| 1967 } | 1983 } |
| 1968 | 1984 |
| 1969 static final debugLogFilePath = new Path(".debug.log"); | 1985 static final debugLogFilePath = new Path(".debug.log"); |
| 1970 | 1986 |
| 1971 /// If a flaky test did fail, infos about it (i.e. test name, stdin, stdout) | 1987 /// If a flaky test did fail, infos about it (i.e. test name, stdin, stdout) |
| 1972 /// will be written to this file. | 1988 /// will be written to this file. |
| 1973 /// | 1989 /// |
| 1974 /// This is useful for debugging flaky tests. When running on a buildbot, the | 1990 /// This is useful for debugging flaky tests. When running on a buildbot, the |
| 1975 /// file can be made visible in the waterfall UI. | 1991 /// file can be made visible in the waterfall UI. |
| 1976 static const flakyFileName = ".flaky.log"; | 1992 static const flakyFileName = ".flaky.log"; |
| 1977 | 1993 |
| 1978 /// If test.py was invoked with '--write-test-outcome-log it will write | 1994 /// If test.py was invoked with '--write-test-outcome-log it will write |
| 1979 /// test outcomes to this file. | 1995 /// test outcomes to this file. |
| 1980 static const testOutcomeFileName = ".test-outcome.log"; | 1996 static const testOutcomeFileName = ".test-outcome.log"; |
| 1981 | 1997 |
| 1982 static void ensureExists(String filename, Map configuration) { | 1998 static void ensureExists(String filename, Map configuration) { |
| 1983 if (!configuration['list'] && !existsCache.doesFileExist(filename)) { | 1999 if (!(configuration['list'] as bool) && |
| 2000 !existsCache.doesFileExist(filename)) { |
| 1984 throw "'$filename' does not exist"; | 2001 throw "'$filename' does not exist"; |
| 1985 } | 2002 } |
| 1986 } | 2003 } |
| 1987 | 2004 |
| 1988 static Path absolutePath(Path path) { | 2005 static Path absolutePath(Path path) { |
| 1989 if (!path.isAbsolute) { | 2006 if (!path.isAbsolute) { |
| 1990 return currentWorkingDirectory.join(path); | 2007 return currentWorkingDirectory.join(path); |
| 1991 } | 2008 } |
| 1992 return path; | 2009 return path; |
| 1993 } | 2010 } |
| 1994 | 2011 |
| 1995 static String outputDir(Map configuration) { | 2012 static String outputDir(Map configuration) { |
| 1996 var result = ''; | 2013 var result = ''; |
| 1997 var system = configuration['system']; | 2014 var system = configuration['system'] as String; |
| 1998 if (system == 'fuchsia' || | 2015 if (system == 'fuchsia' || |
| 1999 system == 'linux' || | 2016 system == 'linux' || |
| 2000 system == 'android' || | 2017 system == 'android' || |
| 2001 system == 'windows') { | 2018 system == 'windows') { |
| 2002 result = 'out/'; | 2019 result = 'out/'; |
| 2003 } else if (system == 'macos') { | 2020 } else if (system == 'macos') { |
| 2004 result = 'xcodebuild/'; | 2021 result = 'xcodebuild/'; |
| 2005 } else { | 2022 } else { |
| 2006 throw new Exception('Unknown operating system: "$system"'); | 2023 throw new Exception('Unknown operating system: "$system"'); |
| 2007 } | 2024 } |
| 2008 return result; | 2025 return result; |
| 2009 } | 2026 } |
| 2010 | 2027 |
| 2011 static List<String> standardOptions(Map configuration) { | 2028 static List<String> standardOptions(Map configuration) { |
| 2012 var args = ["--ignore-unrecognized-flags"]; | 2029 var args = ["--ignore-unrecognized-flags"]; |
| 2013 String compiler = configuration["compiler"]; | 2030 var compiler = configuration["compiler"] as String; |
| 2014 if (compiler == "dart2js") { | 2031 if (compiler == "dart2js") { |
| 2015 args = ['--generate-code-with-compile-time-errors', '--test-mode']; | 2032 args = ['--generate-code-with-compile-time-errors', '--test-mode']; |
| 2016 if (configuration["checked"]) { | 2033 if (configuration["checked"] as bool) { |
| 2017 args.add('--enable-checked-mode'); | 2034 args.add('--enable-checked-mode'); |
| 2018 } | 2035 } |
| 2019 // args.add("--verbose"); | 2036 // args.add("--verbose"); |
| 2020 if (!isBrowserRuntime(configuration['runtime'])) { | 2037 if (!isBrowserRuntime(configuration['runtime'] as String)) { |
| 2021 args.add("--allow-mock-compilation"); | 2038 args.add("--allow-mock-compilation"); |
| 2022 args.add("--categories=all"); | 2039 args.add("--categories=all"); |
| 2023 } | 2040 } |
| 2024 } | 2041 } |
| 2025 if ((compiler == "dart2js") && configuration["minified"]) { | 2042 if ((compiler == "dart2js") && (configuration["minified"] as bool)) { |
| 2026 args.add("--minify"); | 2043 args.add("--minify"); |
| 2027 } | 2044 } |
| 2028 if (compiler == "dart2js" && configuration["csp"]) { | 2045 if (compiler == "dart2js" && (configuration["csp"] as bool)) { |
| 2029 args.add("--csp"); | 2046 args.add("--csp"); |
| 2030 } | 2047 } |
| 2031 if (compiler == "dart2js" && configuration["fast_startup"]) { | 2048 if (compiler == "dart2js" && (configuration["fast_startup"] as bool)) { |
| 2032 args.add("--fast-startup"); | 2049 args.add("--fast-startup"); |
| 2033 } | 2050 } |
| 2034 if (compiler == "dart2js" && configuration["dart2js_with_kernel"]) { | 2051 if (compiler == "dart2js" && |
| 2052 (configuration["dart2js_with_kernel"] as bool)) { |
| 2035 args.add("--use-kernel"); | 2053 args.add("--use-kernel"); |
| 2036 } | 2054 } |
| 2037 return args; | 2055 return args; |
| 2038 } | 2056 } |
| 2039 | 2057 |
| 2040 static bool isBrowserRuntime(String runtime) { | 2058 static bool isBrowserRuntime(String runtime) { |
| 2041 const BROWSERS = const [ | 2059 const BROWSERS = const [ |
| 2042 'drt', | 2060 'drt', |
| 2043 'dartium', | 2061 'dartium', |
| 2044 'ie9', | 2062 'ie9', |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2063 compiler == 'dart2analyzer'; | 2081 compiler == 'dart2analyzer'; |
| 2064 | 2082 |
| 2065 static String buildDir(Map configuration) { | 2083 static String buildDir(Map configuration) { |
| 2066 // FIXME(kustermann,ricow): Our code assumes that the returned 'buildDir' | 2084 // FIXME(kustermann,ricow): Our code assumes that the returned 'buildDir' |
| 2067 // is relative to the current working directory. | 2085 // is relative to the current working directory. |
| 2068 // Thus, if we pass in an absolute path (e.g. '--build-directory=/tmp/out') | 2086 // Thus, if we pass in an absolute path (e.g. '--build-directory=/tmp/out') |
| 2069 // we get into trouble. | 2087 // we get into trouble. |
| 2070 if (configuration['build_directory'] == '') { | 2088 if (configuration['build_directory'] == '') { |
| 2071 configuration['configuration_directory'] = | 2089 configuration['configuration_directory'] = |
| 2072 configurationDir(configuration); | 2090 configurationDir(configuration); |
| 2073 configuration['build_directory'] = | 2091 configuration['build_directory'] = outputDir(configuration) + |
| 2074 outputDir(configuration) + configuration['configuration_directory']; | 2092 (configuration['configuration_directory'] as String); |
| 2075 } | 2093 } |
| 2076 return configuration['build_directory']; | 2094 return configuration['build_directory'] as String; |
| 2077 } | 2095 } |
| 2078 | 2096 |
| 2079 static String configurationDir(Map configuration) { | 2097 static String configurationDir(Map configuration) { |
| 2080 // This returns the correct configuration directory (the last component | 2098 // This returns the correct configuration directory (the last component |
| 2081 // of the output directory path) for regular dart checkouts. | 2099 // of the output directory path) for regular dart checkouts. |
| 2082 // Dartium checkouts use the --build-directory option to pass in the | 2100 // Dartium checkouts use the --build-directory option to pass in the |
| 2083 // correct build directory explicitly. | 2101 // correct build directory explicitly. |
| 2084 // We allow our code to have been cross compiled, i.e., that there | 2102 // We allow our code to have been cross compiled, i.e., that there |
| 2085 // is an X in front of the arch. We don't allow both a cross compiled | 2103 // is an X in front of the arch. We don't allow both a cross compiled |
| 2086 // and a normal version to be present (except if you specifically pass | 2104 // and a normal version to be present (except if you specifically pass |
| 2087 // in the build_directory). | 2105 // in the build_directory). |
| 2088 String mode; | 2106 String mode; |
| 2089 switch (configuration['mode']) { | 2107 switch (configuration['mode'] as String) { |
| 2090 case 'debug': | 2108 case 'debug': |
| 2091 mode = 'Debug'; | 2109 mode = 'Debug'; |
| 2092 break; | 2110 break; |
| 2093 case 'release': | 2111 case 'release': |
| 2094 mode = 'Release'; | 2112 mode = 'Release'; |
| 2095 break; | 2113 break; |
| 2096 case 'product': | 2114 case 'product': |
| 2097 mode = 'Product'; | 2115 mode = 'Product'; |
| 2098 break; | 2116 break; |
| 2099 default: | 2117 default: |
| 2100 throw 'Unrecognized mode configuration: ${configuration['mode']}'; | 2118 throw 'Unrecognized mode configuration: ${configuration['mode']}'; |
| 2101 } | 2119 } |
| 2102 String os; | 2120 String os; |
| 2103 switch (configuration['system']) { | 2121 switch (configuration['system'] as String) { |
| 2104 case 'android': | 2122 case 'android': |
| 2105 os = 'Android'; | 2123 os = 'Android'; |
| 2106 break; | 2124 break; |
| 2107 case 'fuchsia': | 2125 case 'fuchsia': |
| 2108 case 'linux': | 2126 case 'linux': |
| 2109 case 'macos': | 2127 case 'macos': |
| 2110 case 'windows': | 2128 case 'windows': |
| 2111 os = ''; | 2129 os = ''; |
| 2112 break; | 2130 break; |
| 2113 default: | 2131 default: |
| 2114 throw 'Unrecognized operating system: ${configuration['system']}'; | 2132 throw 'Unrecognized operating system: ${configuration['system']}'; |
| 2115 } | 2133 } |
| 2116 var arch = configuration['arch'].toUpperCase(); | 2134 var arch = (configuration['arch'] as String).toUpperCase(); |
| 2117 var normal = '$mode$os$arch'; | 2135 var normal = '$mode$os$arch'; |
| 2118 var cross = '$mode${os}X$arch'; | 2136 var cross = '$mode${os}X$arch'; |
| 2119 var outDir = outputDir(configuration); | 2137 var outDir = outputDir(configuration); |
| 2120 var normalDir = new Directory(new Path('$outDir$normal').toNativePath()); | 2138 var normalDir = new Directory(new Path('$outDir$normal').toNativePath()); |
| 2121 var crossDir = new Directory(new Path('$outDir$cross').toNativePath()); | 2139 var crossDir = new Directory(new Path('$outDir$cross').toNativePath()); |
| 2122 if (normalDir.existsSync() && crossDir.existsSync()) { | 2140 if (normalDir.existsSync() && crossDir.existsSync()) { |
| 2123 throw "You can't have both $normalDir and $crossDir, we don't know which" | 2141 throw "You can't have both $normalDir and $crossDir, we don't know which" |
| 2124 " binary to use"; | 2142 " binary to use"; |
| 2125 } | 2143 } |
| 2126 if (crossDir.existsSync()) { | 2144 if (crossDir.existsSync()) { |
| 2127 return cross; | 2145 return cross; |
| 2128 } | 2146 } |
| 2129 return normal; | 2147 return normal; |
| 2130 } | 2148 } |
| 2131 | 2149 |
| 2132 /** | 2150 /** |
| 2133 * Gets extra options under [key] passed to the testing script. | 2151 * Gets extra options under [key] passed to the testing script. |
| 2134 */ | 2152 */ |
| 2135 static List<String> getExtraOptions(Map configuration, String key) { | 2153 static List<String> getExtraOptions(Map configuration, String key) { |
| 2136 if (configuration[key] == null) return <String>[]; | 2154 if (configuration[key] == null) return <String>[]; |
| 2137 return configuration[key] | 2155 return (configuration[key] as String) |
| 2138 .split(" ") | 2156 .split(" ") |
| 2139 .map((s) => s.trim()) | 2157 .map((s) => s.trim()) |
| 2140 .where((s) => s.isNotEmpty) | 2158 .where((s) => s.isNotEmpty) |
| 2141 .toList(); | 2159 .toList(); |
| 2142 } | 2160 } |
| 2143 | 2161 |
| 2144 /** | 2162 /** |
| 2145 * Gets extra vm options passed to the testing script. | 2163 * Gets extra vm options passed to the testing script. |
| 2146 */ | 2164 */ |
| 2147 static List<String> getExtraVmOptions(Map configuration) => | 2165 static List<String> getExtraVmOptions(Map configuration) => |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2223 } | 2241 } |
| 2224 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { | 2242 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { |
| 2225 ++shortNameCounter; | 2243 ++shortNameCounter; |
| 2226 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); | 2244 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); |
| 2227 path = "short${shortNameCounter}_$pathEnd"; | 2245 path = "short${shortNameCounter}_$pathEnd"; |
| 2228 } | 2246 } |
| 2229 } | 2247 } |
| 2230 return path; | 2248 return path; |
| 2231 } | 2249 } |
| 2232 } | 2250 } |
| OLD | NEW |