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 import 'dart:async'; |
16 | 16 import 'dart:io'; |
17 import "dart:async"; | 17 import 'dart:math'; |
18 import "dart:io"; | |
19 import "dart:math"; | |
20 import "drt_updater.dart"; | |
21 import "html_test.dart" as htmlTest; | |
22 import "http_server.dart"; | |
23 import "path.dart"; | |
24 import "multitest.dart"; | |
25 import "expectation.dart"; | |
26 import "expectation_set.dart"; | |
27 import "summary_report.dart"; | |
28 import "test_runner.dart"; | |
29 import "utils.dart"; | |
30 import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR; | |
31 | |
32 import "compiler_configuration.dart" | |
33 show CommandArtifact, CompilerConfiguration; | |
34 | |
35 import "runtime_configuration.dart" show RuntimeConfiguration; | |
36 | 18 |
37 import 'browser_test.dart'; | 19 import 'browser_test.dart'; |
| 20 import 'compiler_configuration.dart'; |
| 21 import 'configuration.dart'; |
| 22 import 'drt_updater.dart'; |
| 23 import 'expectation.dart'; |
| 24 import 'expectation_set.dart'; |
| 25 import 'html_test.dart' as html_test; |
| 26 import 'http_server.dart'; |
| 27 import 'multitest.dart'; |
| 28 import 'path.dart'; |
| 29 import 'summary_report.dart'; |
| 30 import 'test_configurations.dart'; |
| 31 import 'test_runner.dart'; |
| 32 import 'utils.dart'; |
38 | 33 |
39 RegExp multiHtmlTestGroupRegExp = new RegExp(r"\s*[^/]\s*group\('[^,']*"); | 34 RegExp multiHtmlTestGroupRegExp = new RegExp(r"\s*[^/]\s*group\('[^,']*"); |
40 RegExp multiHtmlTestRegExp = new RegExp(r"useHtmlIndividualConfiguration()"); | 35 RegExp multiHtmlTestRegExp = new RegExp(r"useHtmlIndividualConfiguration()"); |
41 // Require at least one non-space character before '//[/#]' | 36 // Require at least one non-space character before '//[/#]' |
42 RegExp multiTestRegExp = new RegExp(r"\S *" | 37 RegExp multiTestRegExp = new RegExp(r"\S *" |
43 r"//[#/] \w+:(.*)"); | 38 r"//[#/] \w+:(.*)"); |
44 RegExp dartExtension = new RegExp(r'\.dart$'); | 39 RegExp dartExtension = new RegExp(r'\.dart$'); |
45 | 40 |
46 /** | 41 /** |
47 * A simple function that tests [arg] and returns `true` or `false`. | 42 * A simple function that tests [arg] and returns `true` or `false`. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 /** | 79 /** |
85 * Wait for [task] to complete (assuming this barrier has not already been | 80 * Wait for [task] to complete (assuming this barrier has not already been |
86 * marked as completed, otherwise you'll get an exception indicating that a | 81 * marked as completed, otherwise you'll get an exception indicating that a |
87 * future has already been completed). | 82 * future has already been completed). |
88 */ | 83 */ |
89 void add(Future task) { | 84 void add(Future task) { |
90 if (_pending == _FINISHED) { | 85 if (_pending == _FINISHED) { |
91 throw new Exception("FutureFutureAlreadyCompleteException"); | 86 throw new Exception("FutureFutureAlreadyCompleteException"); |
92 } | 87 } |
93 _pending++; | 88 _pending++; |
94 var handledTaskFuture = task.catchError((e) { | 89 var handledTaskFuture = task.catchError((e, StackTrace s) { |
95 if (!wasCompleted) { | 90 if (!wasCompleted) { |
96 _completer.completeError(e); | 91 _completer.completeError(e, s); |
97 wasCompleted = true; | 92 wasCompleted = true; |
98 } | 93 } |
99 }).then((_) { | 94 }).then((_) { |
100 _pending--; | 95 _pending--; |
101 if (_pending == 0) { | 96 if (_pending == 0) { |
102 _pending = _FINISHED; | 97 _pending = _FINISHED; |
103 if (!wasCompleted) { | 98 if (!wasCompleted) { |
104 _completer.complete(futures); | 99 _completer.complete(futures); |
105 wasCompleted = true; | 100 wasCompleted = true; |
106 } | 101 } |
107 } | 102 } |
108 }); | 103 }); |
109 futures.add(handledTaskFuture); | 104 futures.add(handledTaskFuture); |
110 } | 105 } |
111 | 106 |
112 Future<List> get future => _completer.future; | 107 Future<List> get future => _completer.future; |
113 } | 108 } |
114 | 109 |
115 /** | 110 /** |
116 * A TestSuite represents a collection of tests. It creates a [TestCase] | 111 * A TestSuite represents a collection of tests. It creates a [TestCase] |
117 * object for each test to be run, and passes the test cases to a callback. | 112 * object for each test to be run, and passes the test cases to a callback. |
118 * | 113 * |
119 * Most TestSuites represent a directory or directory tree containing tests, | 114 * Most TestSuites represent a directory or directory tree containing tests, |
120 * and a status file containing the expected results when these tests are run. | 115 * and a status file containing the expected results when these tests are run. |
121 */ | 116 */ |
122 abstract class TestSuite { | 117 abstract class TestSuite { |
123 final Map<String, dynamic> configuration; | 118 final Configuration configuration; |
124 final String suiteName; | 119 final String suiteName; |
125 // This function is set by subclasses before enqueueing starts. | 120 // This function is set by subclasses before enqueueing starts. |
126 Function doTest; | 121 Function doTest; |
127 Map<String, String> _environmentOverrides; | 122 Map<String, String> _environmentOverrides; |
128 RuntimeConfiguration runtimeConfiguration; | |
129 | 123 |
130 TestSuite(this.configuration, this.suiteName) { | 124 TestSuite(this.configuration, this.suiteName) { |
131 TestUtils.buildDir(configuration); // Sets configuration_directory. | 125 _environmentOverrides = { |
132 if (configuration['configuration_directory'] != null) { | 126 'DART_CONFIGURATION': configuration.configurationDirectory |
133 _environmentOverrides = { | 127 }; |
134 'DART_CONFIGURATION': configuration['configuration_directory'] as String | |
135 }; | |
136 } | |
137 runtimeConfiguration = new RuntimeConfiguration(configuration); | |
138 } | 128 } |
139 | 129 |
140 Map<String, String> get environmentOverrides => _environmentOverrides; | 130 Map<String, String> get environmentOverrides => _environmentOverrides; |
141 | 131 |
142 /** | 132 /** |
143 * Whether or not binaries should be found in the root build directory or | 133 * Whether or not binaries should be found in the root build directory or |
144 * in the built SDK. | 134 * in the built SDK. |
145 */ | 135 */ |
146 bool get useSdk { | 136 bool get useSdk { |
147 // The pub suite always uses the SDK. | 137 // The pub suite always uses the SDK. |
148 // TODO(rnystrom): Eventually, all test suites should run out of the SDK | 138 // TODO(rnystrom): Eventually, all test suites should run out of the SDK |
149 // and this check should go away. | 139 // and this check should go away. |
150 // TODO(ahe): This check is broken for several reasons: | 140 // TODO(ahe): This check is broken for several reasons: |
151 // First, it is not true that all tests should be running out of the | 141 // First, it is not true that all tests should be running out of the |
152 // SDK. It is absolutely critical to VM development that you can test the | 142 // SDK. It is absolutely critical to VM development that you can test the |
153 // VM without building the SDK. | 143 // VM without building the SDK. |
154 // Second, it is convenient for dart2js developers to run tests without | 144 // Second, it is convenient for dart2js developers to run tests without |
155 // rebuilding the SDK, and similarly, it should be convenient for pub | 145 // rebuilding the SDK, and similarly, it should be convenient for pub |
156 // developers. | 146 // developers. |
157 // Third, even if pub can only run from the SDK directory, this is the | 147 // Third, even if pub can only run from the SDK directory, this is the |
158 // wrong place to work around that problem. Instead, test_options.dart | 148 // wrong place to work around that problem. Instead, test_options.dart |
159 // should have been modified so that configuration['use_sdk'] is always | 149 // should have been modified so that configuration['use_sdk'] is always |
160 // true when testing pub. Attempting to override the value here is brittle | 150 // true when testing pub. Attempting to override the value here is brittle |
161 // because we read configuration['use_sdk'] directly in many places without | 151 // because we read configuration['use_sdk'] directly in many places without |
162 // using this getter. | 152 // using this getter. |
163 if (suiteName == 'pub') return true; | 153 if (suiteName == 'pub') return true; |
164 | 154 |
165 return configuration['use_sdk'] as bool; | 155 return configuration.useSdk; |
166 } | 156 } |
167 | 157 |
168 /** | 158 /** |
169 * The output directory for this suite's configuration. | 159 * The output directory for this suite's configuration. |
170 */ | 160 */ |
171 String get buildDir => TestUtils.buildDir(configuration); | 161 String get buildDir => configuration.buildDirectory; |
172 | 162 |
173 /** | 163 /** |
174 * The path to the compiler for this suite's configuration. Returns `null` if | 164 * The path to the compiler for this suite's configuration. Returns `null` if |
175 * no compiler should be used. | 165 * no compiler should be used. |
176 */ | 166 */ |
177 String get compilerPath { | 167 String get compilerPath { |
178 var compilerConfiguration = new CompilerConfiguration(configuration); | 168 var compilerConfiguration = configuration.compilerConfiguration; |
179 if (!compilerConfiguration.hasCompiler) return null; | 169 if (!compilerConfiguration.hasCompiler) return null; |
180 var name = compilerConfiguration.computeCompilerPath(buildDir); | 170 var name = compilerConfiguration.computeCompilerPath(buildDir); |
181 // TODO(ahe): Only validate this once, in test_options.dart. | 171 // TODO(ahe): Only validate this once, in test_options.dart. |
182 TestUtils.ensureExists(name, configuration); | 172 TestUtils.ensureExists(name, configuration); |
183 return name; | 173 return name; |
184 } | 174 } |
185 | 175 |
186 String get pubPath { | 176 String get pubPath { |
187 var prefix = 'sdk/bin/'; | 177 var prefix = 'sdk/bin/'; |
188 if (configuration['use_sdk'] as bool) { | 178 if (configuration.useSdk) { |
189 prefix = '$buildDir/dart-sdk/bin/'; | 179 prefix = '$buildDir/dart-sdk/bin/'; |
190 } | 180 } |
191 var suffix = getExecutableSuffix('pub'); | 181 var suffix = getExecutableSuffix('pub'); |
192 var name = '${prefix}pub$suffix'; | 182 var name = '${prefix}pub$suffix'; |
193 TestUtils.ensureExists(name, configuration); | 183 TestUtils.ensureExists(name, configuration); |
194 return name; | 184 return name; |
195 } | 185 } |
196 | 186 |
197 /// Returns the name of the Dart VM executable. | 187 /// Returns the name of the Dart VM executable. |
198 String get dartVmBinaryFileName { | 188 String get dartVmBinaryFileName { |
199 // Controlled by user with the option "--dart". | 189 // Controlled by user with the option "--dart". |
200 var dartExecutable = configuration['dart'] as String; | 190 var dartExecutable = configuration.dartPath; |
201 | 191 |
202 if (dartExecutable == '') { | 192 if (dartExecutable == null) { |
203 var suffix = executableBinarySuffix; | 193 var suffix = executableBinarySuffix; |
204 dartExecutable = useSdk | 194 dartExecutable = useSdk |
205 ? '$buildDir/dart-sdk/bin/dart$suffix' | 195 ? '$buildDir/dart-sdk/bin/dart$suffix' |
206 : '$buildDir/dart$suffix'; | 196 : '$buildDir/dart$suffix'; |
207 } | 197 } |
208 | 198 |
209 TestUtils.ensureExists(dartExecutable, configuration); | 199 TestUtils.ensureExists(dartExecutable, configuration); |
210 return dartExecutable; | 200 return dartExecutable; |
211 } | 201 } |
212 | 202 |
213 /// Returns the name of the flutter engine executable. | 203 /// Returns the name of the flutter engine executable. |
214 String get flutterEngineBinaryFileName { | 204 String get flutterEngineBinaryFileName { |
215 // Controlled by user with the option "--flutter". | 205 // Controlled by user with the option "--flutter". |
216 var flutterExecutable = configuration['flutter'] as String; | 206 var flutterExecutable = configuration.flutterPath; |
217 TestUtils.ensureExists(flutterExecutable, configuration); | 207 TestUtils.ensureExists(flutterExecutable, configuration); |
218 return flutterExecutable; | 208 return flutterExecutable; |
219 } | 209 } |
220 | 210 |
221 String get dartPrecompiledBinaryFileName { | 211 String get dartPrecompiledBinaryFileName { |
222 // Controlled by user with the option "--dart_precompiled". | 212 // Controlled by user with the option "--dart_precompiled". |
223 var dartExecutable = configuration['dart_precompiled'] as String; | 213 var dartExecutable = configuration.dartPrecompiledPath; |
224 | 214 |
225 if (dartExecutable == null || dartExecutable == '') { | 215 if (dartExecutable == null || dartExecutable == '') { |
226 var suffix = executableBinarySuffix; | 216 var suffix = executableBinarySuffix; |
227 dartExecutable = '$buildDir/dart_precompiled_runtime$suffix'; | 217 dartExecutable = '$buildDir/dart_precompiled_runtime$suffix'; |
228 } | 218 } |
229 | 219 |
230 TestUtils.ensureExists(dartExecutable, configuration); | 220 TestUtils.ensureExists(dartExecutable, configuration); |
231 return dartExecutable; | 221 return dartExecutable; |
232 } | 222 } |
233 | 223 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 [VoidFunction onDone]); | 275 [VoidFunction onDone]); |
286 | 276 |
287 // This function will be called for every TestCase of this test suite. | 277 // This function will be called for every TestCase of this test suite. |
288 // It will | 278 // It will |
289 // - handle sharding | 279 // - handle sharding |
290 // - update SummaryReport | 280 // - update SummaryReport |
291 // - handle SKIP/SKIP_BY_DESIGN markers | 281 // - handle SKIP/SKIP_BY_DESIGN markers |
292 // - test if the selector matches | 282 // - test if the selector matches |
293 // and will enqueue the test (if necessary). | 283 // and will enqueue the test (if necessary). |
294 void enqueueNewTestCase(TestCase testCase) { | 284 void enqueueNewTestCase(TestCase testCase) { |
295 if (testCase.isNegative && runtimeConfiguration.shouldSkipNegativeTests) { | 285 if (testCase.isNegative && |
| 286 configuration.runtimeConfiguration.shouldSkipNegativeTests) { |
296 return; | 287 return; |
297 } | 288 } |
298 var expectations = testCase.expectedOutcomes; | 289 var expectations = testCase.expectedOutcomes; |
299 | 290 |
300 // Handle sharding based on the original test path (i.e. all multitests | 291 // Handle sharding based on the original test path (i.e. all multitests |
301 // of a given original test belong to the same shard) | 292 // of a given original test belong to the same shard) |
302 var shards = configuration['shards'] as int; | 293 if (configuration.shardCount > 1 && |
303 if (shards > 1 && | 294 testCase.hash % configuration.shardCount != configuration.shard - 1) { |
304 testCase.hash % shards != (configuration['shard'] as int) - 1) { | |
305 return; | 295 return; |
306 } | 296 } |
| 297 |
307 // Test if the selector includes this test. | 298 // Test if the selector includes this test. |
308 var pattern = configuration['selectors'][suiteName] as RegExp; | 299 var pattern = configuration.selectors[suiteName]; |
309 if (!pattern.hasMatch(testCase.displayName)) { | 300 if (!pattern.hasMatch(testCase.displayName)) { |
310 return; | 301 return; |
311 } | 302 } |
312 | 303 |
313 if ((configuration['hot_reload'] as bool) || | 304 if (configuration.hotReload || configuration.hotReloadRollback) { |
314 (configuration['hot_reload_rollback'] as bool)) { | |
315 // Handle reload special cases. | 305 // Handle reload special cases. |
316 if (expectations.contains(Expectation.compileTimeError) || | 306 if (expectations.contains(Expectation.compileTimeError) || |
317 testCase.hasCompileError || | 307 testCase.hasCompileError || |
318 testCase.expectCompileError) { | 308 testCase.expectCompileError) { |
319 // Running a test that expects a compilation error with hot reloading | 309 // Running a test that expects a compilation error with hot reloading |
320 // is redundant with a regular run of the test. | 310 // is redundant with a regular run of the test. |
321 return; | 311 return; |
322 } | 312 } |
323 } | 313 } |
324 | 314 |
325 // Update Summary report | 315 // Update Summary report |
326 if (configuration['report'] as bool) { | 316 if (configuration.printReport) { |
327 if (testCase.expectCompileError && | 317 if (testCase.expectCompileError && |
328 TestUtils.isBrowserRuntime(configuration['runtime'] as String) && | 318 configuration.runtime.isBrowser && |
329 new CompilerConfiguration(configuration).hasCompiler) { | 319 configuration.compilerConfiguration.hasCompiler) { |
330 summaryReport.addCompileErrorSkipTest(); | 320 summaryReport.addCompileErrorSkipTest(); |
331 return; | 321 return; |
332 } else { | 322 } else { |
333 summaryReport.add(testCase); | 323 summaryReport.add(testCase); |
334 } | 324 } |
335 } | 325 } |
336 | 326 |
337 // Handle skipped tests | 327 // Handle skipped tests |
338 if (expectations.contains(Expectation.skip) || | 328 if (expectations.contains(Expectation.skip) || |
339 expectations.contains(Expectation.skipByDesign) || | 329 expectations.contains(Expectation.skipByDesign) || |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 testName = concat(testName, multitestName); | 372 testName = concat(testName, multitestName); |
383 return testName; | 373 return testName; |
384 } | 374 } |
385 | 375 |
386 /** | 376 /** |
387 * Create a directories for generated assets (tests, html files, | 377 * Create a directories for generated assets (tests, html files, |
388 * pubspec checkouts ...). | 378 * pubspec checkouts ...). |
389 */ | 379 */ |
390 | 380 |
391 String createOutputDirectory(Path testPath, String optionsName) { | 381 String createOutputDirectory(Path testPath, String optionsName) { |
392 var checked = configuration['checked'] as bool ? '-checked' : ''; | 382 var checked = configuration.isChecked ? '-checked' : ''; |
393 var strong = configuration['strong'] as bool ? '-strong' : ''; | 383 var strong = configuration.isStrong ? '-strong' : ''; |
394 var minified = configuration['minified'] as bool ? '-minified' : ''; | 384 var minified = configuration.isMinified ? '-minified' : ''; |
395 var sdk = configuration['use_sdk'] as bool ? '-sdk' : ''; | 385 var sdk = configuration.useSdk ? '-sdk' : ''; |
396 var dirName = "${configuration['compiler']}-${configuration['runtime']}" | 386 var dirName = "${configuration.compiler.name}-${configuration.runtime.name}" |
397 "$checked$strong$minified$sdk"; | 387 "$checked$strong$minified$sdk"; |
398 return createGeneratedTestDirectoryHelper( | 388 return createGeneratedTestDirectoryHelper( |
399 "tests", dirName, testPath, optionsName); | 389 "tests", dirName, testPath, optionsName); |
400 } | 390 } |
401 | 391 |
402 String createCompilationOutputDirectory(Path testPath) { | 392 String createCompilationOutputDirectory(Path testPath) { |
403 var checked = configuration['checked'] as bool ? '-checked' : ''; | 393 var checked = configuration.isChecked ? '-checked' : ''; |
404 var strong = configuration['strong'] as bool ? '-strong' : ''; | 394 var strong = configuration.isStrong ? '-strong' : ''; |
405 var minified = configuration['minified'] as bool ? '-minified' : ''; | 395 var minified = configuration.isMinified ? '-minified' : ''; |
406 var csp = configuration['csp'] as bool ? '-csp' : ''; | 396 var csp = configuration.isCsp ? '-csp' : ''; |
407 var sdk = configuration['use_sdk'] as bool ? '-sdk' : ''; | 397 var sdk = configuration.useSdk ? '-sdk' : ''; |
408 var dirName = "${configuration['compiler']}" | 398 var dirName = "${configuration.compiler.name}" |
409 "$checked$strong$minified$csp$sdk"; | 399 "$checked$strong$minified$csp$sdk"; |
410 return createGeneratedTestDirectoryHelper( | 400 return createGeneratedTestDirectoryHelper( |
411 "compilations", dirName, testPath, ""); | 401 "compilations", dirName, testPath, ""); |
412 } | 402 } |
413 | 403 |
414 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) { | 404 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) { |
415 var sdk = configuration['use_sdk'] as bool ? 'sdk' : ''; | 405 var sdk = configuration.useSdk ? 'sdk' : ''; |
416 return createGeneratedTestDirectoryHelper( | 406 return createGeneratedTestDirectoryHelper( |
417 "pubspec_checkouts", sdk, directoryOfPubspecYaml, ""); | 407 "pubspec_checkouts", sdk, directoryOfPubspecYaml, ""); |
418 } | 408 } |
419 | 409 |
420 String createPubPackageBuildsDirectory(Path directoryOfPubspecYaml) { | 410 String createPubPackageBuildsDirectory(Path directoryOfPubspecYaml) { |
421 return createGeneratedTestDirectoryHelper( | 411 return createGeneratedTestDirectoryHelper( |
422 "pub_package_builds", 'public_packages', directoryOfPubspecYaml, ""); | 412 "pub_package_builds", 'public_packages', directoryOfPubspecYaml, ""); |
423 } | 413 } |
424 } | 414 } |
425 | 415 |
(...skipping 18 matching lines...) Expand all Loading... |
444 * The executable lists its tests when run with the --list command line flag. | 434 * The executable lists its tests when run with the --list command line flag. |
445 * Individual tests are run by specifying them on the command line. | 435 * Individual tests are run by specifying them on the command line. |
446 */ | 436 */ |
447 class CCTestSuite extends TestSuite { | 437 class CCTestSuite extends TestSuite { |
448 final String testPrefix; | 438 final String testPrefix; |
449 String targetRunnerPath; | 439 String targetRunnerPath; |
450 String hostRunnerPath; | 440 String hostRunnerPath; |
451 final String dartDir; | 441 final String dartDir; |
452 List<String> statusFilePaths; | 442 List<String> statusFilePaths; |
453 | 443 |
454 CCTestSuite(Map<String, dynamic> configuration, String suiteName, | 444 CCTestSuite(Configuration configuration, String suiteName, String runnerName, |
455 String runnerName, this.statusFilePaths, | 445 this.statusFilePaths, |
456 {this.testPrefix: ''}) | 446 {this.testPrefix: ''}) |
457 : dartDir = TestUtils.dartDir.toNativePath(), | 447 : dartDir = TestUtils.dartDir.toNativePath(), |
458 super(configuration, suiteName) { | 448 super(configuration, suiteName) { |
459 // For running the tests we use the given '$runnerName' binary | 449 // For running the tests we use the given '$runnerName' binary |
460 targetRunnerPath = '$buildDir/$runnerName'; | 450 targetRunnerPath = '$buildDir/$runnerName'; |
461 | 451 |
462 // For listing the tests we use the '$runnerName.host' binary if it exists | 452 // For listing the tests we use the '$runnerName.host' binary if it exists |
463 // and use '$runnerName' if it doesn't. | 453 // and use '$runnerName' if it doesn't. |
464 var binarySuffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; | 454 var binarySuffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; |
465 var hostBinary = '$targetRunnerPath.host$binarySuffix'; | 455 var hostBinary = '$targetRunnerPath.host$binarySuffix'; |
466 if (new File(hostBinary).existsSync()) { | 456 if (new File(hostBinary).existsSync()) { |
467 hostRunnerPath = hostBinary; | 457 hostRunnerPath = hostBinary; |
468 } else { | 458 } else { |
469 hostRunnerPath = targetRunnerPath; | 459 hostRunnerPath = targetRunnerPath; |
470 } | 460 } |
471 } | 461 } |
472 | 462 |
473 void testNameHandler(ExpectationSet testExpectations, String testName) { | 463 void testNameHandler(ExpectationSet testExpectations, String testName) { |
474 // Only run the tests that match the pattern. Use the name | 464 // Only run the tests that match the pattern. Use the name |
475 // "suiteName/testName" for cc tests. | 465 // "suiteName/testName" for cc tests. |
476 String constructedName = '$suiteName/$testPrefix$testName'; | 466 String constructedName = '$suiteName/$testPrefix$testName'; |
477 | 467 |
478 var expectations = testExpectations.expectations('$testPrefix$testName'); | 468 var expectations = testExpectations.expectations('$testPrefix$testName'); |
479 | 469 |
480 var args = TestUtils.standardOptions(configuration); | 470 var args = configuration.standardOptions.toList(); |
481 var compilerConfiguration = new CompilerConfiguration(configuration); | 471 if (configuration.compilerConfiguration.useDfe) { |
482 if (compilerConfiguration.useDfe) { | |
483 args.add('--use-dart-frontend'); | 472 args.add('--use-dart-frontend'); |
484 // '--dfe' has to be the first argument for run_vm_test to pick it up. | 473 // '--dfe' has to be the first argument for run_vm_test to pick it up. |
485 args.insert(0, '--dfe=$buildDir/gen/kernel-service.dart.snapshot'); | 474 args.insert(0, '--dfe=$buildDir/gen/kernel-service.dart.snapshot'); |
486 } | 475 } |
| 476 |
487 args.add(testName); | 477 args.add(testName); |
488 | 478 |
489 var command = CommandBuilder.instance.getProcessCommand( | 479 var command = CommandBuilder.instance.getProcessCommand( |
490 'run_vm_unittest', targetRunnerPath, args, environmentOverrides); | 480 'run_vm_unittest', targetRunnerPath, args, environmentOverrides); |
491 enqueueNewTestCase( | 481 enqueueNewTestCase( |
492 new TestCase(constructedName, [command], configuration, expectations)); | 482 new TestCase(constructedName, [command], configuration, expectations)); |
493 } | 483 } |
494 | 484 |
495 Future<Null> forEachTest(Function onTest, Map testCache, | 485 Future<Null> forEachTest(Function onTest, Map testCache, |
496 [VoidFunction onDone]) async { | 486 [VoidFunction onDone]) async { |
(...skipping 14 matching lines...) Expand all Loading... |
511 } catch (error) { | 501 } catch (error) { |
512 print("Fatal error occured: $error"); | 502 print("Fatal error occured: $error"); |
513 exit(1); | 503 exit(1); |
514 } | 504 } |
515 } | 505 } |
516 } | 506 } |
517 | 507 |
518 class TestInformation { | 508 class TestInformation { |
519 Path filePath; | 509 Path filePath; |
520 Path originTestPath; | 510 Path originTestPath; |
521 Map optionsFromFile; | 511 Map<String, dynamic> optionsFromFile; |
522 bool hasCompileError; | 512 bool hasCompileError; |
523 bool hasRuntimeError; | 513 bool hasRuntimeError; |
524 bool isNegativeIfChecked; | 514 bool isNegativeIfChecked; |
525 bool hasCompileErrorIfChecked; | 515 bool hasCompileErrorIfChecked; |
526 bool hasStaticWarning; | 516 bool hasStaticWarning; |
527 String multitestKey; | 517 String multitestKey; |
528 | 518 |
529 TestInformation( | 519 TestInformation( |
530 this.filePath, | 520 this.filePath, |
531 this.originTestPath, | 521 this.originTestPath, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 final Path suiteDir; | 554 final Path suiteDir; |
565 final List<String> statusFilePaths; | 555 final List<String> statusFilePaths; |
566 ExpectationSet testExpectations; | 556 ExpectationSet testExpectations; |
567 List<TestInformation> cachedTests; | 557 List<TestInformation> cachedTests; |
568 final Path dartDir; | 558 final Path dartDir; |
569 Predicate<String> isTestFilePredicate; | 559 Predicate<String> isTestFilePredicate; |
570 final bool listRecursively; | 560 final bool listRecursively; |
571 final List<String> extraVmOptions; | 561 final List<String> extraVmOptions; |
572 List<Uri> _dart2JsBootstrapDependencies; | 562 List<Uri> _dart2JsBootstrapDependencies; |
573 | 563 |
574 StandardTestSuite(Map<String, dynamic> configuration, String suiteName, | 564 StandardTestSuite(Configuration configuration, String suiteName, |
575 Path suiteDirectory, this.statusFilePaths, | 565 Path suiteDirectory, this.statusFilePaths, |
576 {this.isTestFilePredicate, bool recursive: false}) | 566 {this.isTestFilePredicate, bool recursive: false}) |
577 : dartDir = TestUtils.dartDir, | 567 : dartDir = TestUtils.dartDir, |
578 listRecursively = recursive, | 568 listRecursively = recursive, |
579 suiteDir = TestUtils.dartDir.join(suiteDirectory), | 569 suiteDir = TestUtils.dartDir.join(suiteDirectory), |
580 extraVmOptions = TestUtils.getExtraVmOptions(configuration), | 570 extraVmOptions = configuration.vmOptions, |
581 super(configuration, suiteName) { | 571 super(configuration, suiteName) { |
582 if (!useSdk) { | 572 if (!useSdk) { |
583 _dart2JsBootstrapDependencies = []; | 573 _dart2JsBootstrapDependencies = []; |
584 } else { | 574 } else { |
585 var snapshotPath = TestUtils | 575 var snapshotPath = TestUtils |
586 .absolutePath( | 576 .absolutePath( |
587 new Path(buildDir).join(new Path('dart-sdk/bin/snapshots/' | 577 new Path(buildDir).join(new Path('dart-sdk/bin/snapshots/' |
588 'utils_wrapper.dart.snapshot'))) | 578 'utils_wrapper.dart.snapshot'))) |
589 .toString(); | 579 .toString(); |
590 _dart2JsBootstrapDependencies = [ | 580 _dart2JsBootstrapDependencies = [ |
(...skipping 23 matching lines...) Expand all Loading... |
614 * | 604 * |
615 * If you follow that convention, then you can construct one of these like: | 605 * If you follow that convention, then you can construct one of these like: |
616 * | 606 * |
617 * new StandardTestSuite.forDirectory(configuration, 'path/to/mytestsuite'); | 607 * new StandardTestSuite.forDirectory(configuration, 'path/to/mytestsuite'); |
618 * | 608 * |
619 * instead of having to create a custom [StandardTestSuite] subclass. In | 609 * instead of having to create a custom [StandardTestSuite] subclass. In |
620 * particular, if you add 'path/to/mytestsuite' to [TEST_SUITE_DIRECTORIES] | 610 * particular, if you add 'path/to/mytestsuite' to [TEST_SUITE_DIRECTORIES] |
621 * in test.dart, this will all be set up for you. | 611 * in test.dart, this will all be set up for you. |
622 */ | 612 */ |
623 factory StandardTestSuite.forDirectory( | 613 factory StandardTestSuite.forDirectory( |
624 Map<String, dynamic> configuration, Path directory) { | 614 Configuration configuration, Path directory) { |
625 var name = directory.filename; | 615 var name = directory.filename; |
626 var status_paths = [ | 616 var status_paths = [ |
627 '$directory/$name.status', | 617 '$directory/$name.status', |
628 '$directory/.status', | 618 '$directory/.status', |
629 '$directory/${name}_dart2js.status', | 619 '$directory/${name}_dart2js.status', |
630 '$directory/${name}_analyzer2.status', | 620 '$directory/${name}_analyzer2.status', |
631 '$directory/${name}_kernel.status' | 621 '$directory/${name}_kernel.status' |
632 ]; | 622 ]; |
633 | 623 |
634 return new StandardTestSuite(configuration, name, directory, status_paths, | 624 return new StandardTestSuite(configuration, name, directory, status_paths, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 doTest = null; | 663 doTest = null; |
674 if (onDone != null) onDone(); | 664 if (onDone != null) onDone(); |
675 } | 665 } |
676 | 666 |
677 /** | 667 /** |
678 * If Content shell/Dartium is required, and not yet updated, waits for | 668 * If Content shell/Dartium is required, and not yet updated, waits for |
679 * the update then completes. Otherwise completes immediately. | 669 * the update then completes. Otherwise completes immediately. |
680 */ | 670 */ |
681 Future updateDartium() { | 671 Future updateDartium() { |
682 var completer = new Completer(); | 672 var completer = new Completer(); |
683 var updater = runtimeUpdater(configuration); | 673 var updater = runtimeUpdater(configuration.runtime, configuration.drtPath, |
| 674 configuration.dartiumPath); |
684 if (updater == null || updater.updated) { | 675 if (updater == null || updater.updated) { |
685 return new Future.value(null); | 676 return new Future.value(null); |
686 } | 677 } |
687 | 678 |
688 assert(updater.isActive); | 679 assert(updater.isActive); |
689 updater.onUpdated.add(() => completer.complete(null)); | 680 updater.onUpdated.add(() => completer.complete(null)); |
690 | 681 |
691 return completer.future; | 682 return completer.future; |
692 } | 683 } |
693 | 684 |
(...skipping 30 matching lines...) Expand all Loading... |
724 .list(recursive: listRecursively) | 715 .list(recursive: listRecursively) |
725 .where((fse) => fse is File) | 716 .where((fse) => fse is File) |
726 .forEach((FileSystemEntity entity) { | 717 .forEach((FileSystemEntity entity) { |
727 enqueueFile((entity as File).path, group); | 718 enqueueFile((entity as File).path, group); |
728 }); | 719 }); |
729 group.add(lister); | 720 group.add(lister); |
730 } | 721 } |
731 | 722 |
732 void enqueueFile(String filename, FutureGroup group) { | 723 void enqueueFile(String filename, FutureGroup group) { |
733 if (isHtmlTestFile(filename)) { | 724 if (isHtmlTestFile(filename)) { |
734 var info = htmlTest.getInformation(filename); | 725 var info = html_test.getInformation(filename); |
735 if (info == null) { | 726 if (info == null) { |
736 DebugLogger | 727 DebugLogger |
737 .error("HtmlTest $filename does not contain required annotations"); | 728 .error("HtmlTest $filename does not contain required annotations"); |
738 return; | 729 return; |
739 } | 730 } |
740 cachedTests.add(info); | 731 cachedTests.add(info); |
741 enqueueTestCaseFromTestInformation(info); | 732 enqueueTestCaseFromTestInformation(info); |
742 return; | 733 return; |
743 } | 734 } |
744 if (!isTestFile(filename)) return; | 735 if (!isTestFile(filename)) return; |
745 Path filePath = new Path(filename); | 736 Path filePath = new Path(filename); |
746 | 737 |
747 var optionsFromFile = readOptionsFromFile(filePath); | 738 var optionsFromFile = readOptionsFromFile(filePath); |
748 CreateTest createTestCase = makeTestCaseCreator(optionsFromFile); | 739 CreateTest createTestCase = makeTestCaseCreator(optionsFromFile); |
749 | 740 |
750 if (optionsFromFile['isMultitest'] as bool) { | 741 if (optionsFromFile['isMultitest'] as bool) { |
751 group.add(doMultitest( | 742 group.add(doMultitest(filePath, buildDir, suiteDir, createTestCase, |
752 filePath, | 743 configuration.hotReload || configuration.hotReloadRollback)); |
753 buildDir, | |
754 suiteDir, | |
755 createTestCase, | |
756 ((configuration['hot_reload'] as bool) || | |
757 (configuration['hot_reload_rollback'] as bool)))); | |
758 } else { | 744 } else { |
759 createTestCase( | 745 createTestCase( |
760 filePath, | 746 filePath, |
761 filePath, | 747 filePath, |
762 optionsFromFile['hasCompileError'] as bool, | 748 optionsFromFile['hasCompileError'] as bool, |
763 optionsFromFile['hasRuntimeError'] as bool, | 749 optionsFromFile['hasRuntimeError'] as bool, |
764 hasStaticWarning: optionsFromFile['hasStaticWarning'] as bool); | 750 hasStaticWarning: optionsFromFile['hasStaticWarning'] as bool); |
765 } | 751 } |
766 } | 752 } |
767 | 753 |
(...skipping 29 matching lines...) Expand all Loading... |
797 var optionsFromFile = info.optionsFromFile; | 783 var optionsFromFile = info.optionsFromFile; |
798 | 784 |
799 // If this test is inside a package, we will check if there is a | 785 // If this test is inside a package, we will check if there is a |
800 // pubspec.yaml file and if so, create a custom package root for it. | 786 // pubspec.yaml file and if so, create a custom package root for it. |
801 List<Command> baseCommands = <Command>[]; | 787 List<Command> baseCommands = <Command>[]; |
802 Path packageRoot; | 788 Path packageRoot; |
803 Path packages; | 789 Path packages; |
804 | 790 |
805 if (optionsFromFile['packageRoot'] == null && | 791 if (optionsFromFile['packageRoot'] == null && |
806 optionsFromFile['packages'] == null) { | 792 optionsFromFile['packages'] == null) { |
807 if (configuration['package_root'] != null) { | 793 if (configuration.packageRoot != null) { |
808 packageRoot = new Path(configuration['package_root'] as String); | 794 packageRoot = new Path(configuration.packageRoot); |
809 optionsFromFile['packageRoot'] = packageRoot.toNativePath(); | 795 optionsFromFile['packageRoot'] = packageRoot.toNativePath(); |
810 } | 796 } |
811 if (configuration['packages'] != null) { | 797 if (configuration.packages != null) { |
812 Path packages = new Path(configuration['packages'] as String); | 798 Path packages = new Path(configuration.packages); |
813 optionsFromFile['packages'] = packages.toNativePath(); | 799 optionsFromFile['packages'] = packages.toNativePath(); |
814 } | 800 } |
815 } | 801 } |
816 if (new CompilerConfiguration(configuration).hasCompiler && | 802 if (configuration.compilerConfiguration.hasCompiler && |
817 expectCompileError(info)) { | 803 expectCompileError(info)) { |
818 // If a compile-time error is expected, and we're testing a | 804 // If a compile-time error is expected, and we're testing a |
819 // compiler, we never need to attempt to run the program (in a | 805 // compiler, we never need to attempt to run the program (in a |
820 // browser or otherwise). | 806 // browser or otherwise). |
821 enqueueStandardTest(baseCommands, info, testName, expectations); | 807 enqueueStandardTest(baseCommands, info, testName, expectations); |
822 } else if (TestUtils.isBrowserRuntime(configuration['runtime'] as String)) { | 808 } else if (configuration.runtime.isBrowser) { |
823 if (info.optionsFromFile['isMultiHtmlTest'] as bool) { | 809 if (info.optionsFromFile['isMultiHtmlTest'] as bool) { |
824 // A browser multi-test has multiple expectations for one test file. | 810 // A browser multi-test has multiple expectations for one test file. |
825 // Find all the different sub-test expecations for one entire test file. | 811 // Find all the different sub-test expecations for one entire test file. |
826 var subtestNames = info.optionsFromFile['subtestNames'] as List<String>; | 812 var subtestNames = info.optionsFromFile['subtestNames'] as List<String>; |
827 var multiHtmlTestExpectations = <String, Set<Expectation>>{}; | 813 var multiHtmlTestExpectations = <String, Set<Expectation>>{}; |
828 for (var name in subtestNames) { | 814 for (var name in subtestNames) { |
829 var fullTestName = '$testName/$name'; | 815 var fullTestName = '$testName/$name'; |
830 multiHtmlTestExpectations[fullTestName] = | 816 multiHtmlTestExpectations[fullTestName] = |
831 testExpectations.expectations(fullTestName); | 817 testExpectations.expectations(fullTestName); |
832 } | 818 } |
(...skipping 29 matching lines...) Expand all Loading... |
862 commands.addAll( | 848 commands.addAll( |
863 makeCommands(info, vmOptionsVariant, allVmOptions, commonArguments)); | 849 makeCommands(info, vmOptionsVariant, allVmOptions, commonArguments)); |
864 enqueueNewTestCase(new TestCase( | 850 enqueueNewTestCase(new TestCase( |
865 '$suiteName/$testName', commands, configuration, expectations, | 851 '$suiteName/$testName', commands, configuration, expectations, |
866 isNegative: isNegative(info), info: info)); | 852 isNegative: isNegative(info), info: info)); |
867 } | 853 } |
868 } | 854 } |
869 | 855 |
870 bool expectCompileError(TestInformation info) { | 856 bool expectCompileError(TestInformation info) { |
871 return info.hasCompileError || | 857 return info.hasCompileError || |
872 ((configuration['checked'] as bool) && info.hasCompileErrorIfChecked); | 858 (configuration.isChecked && info.hasCompileErrorIfChecked); |
873 } | 859 } |
874 | 860 |
875 bool isNegative(TestInformation info) { | 861 bool isNegative(TestInformation info) { |
876 bool negative = expectCompileError(info) || | 862 bool negative = expectCompileError(info) || |
877 ((configuration['checked'] as bool) && info.isNegativeIfChecked); | 863 (configuration.isChecked && info.isNegativeIfChecked); |
878 if (info.hasRuntimeError && hasRuntime) { | 864 if (info.hasRuntimeError && hasRuntime) { |
879 negative = true; | 865 negative = true; |
880 } | 866 } |
881 return negative; | 867 return negative; |
882 } | 868 } |
883 | 869 |
884 List<Command> makeCommands(TestInformation info, int vmOptionsVarient, | 870 List<Command> makeCommands(TestInformation info, int vmOptionsVarient, |
885 List<String> vmOptions, List<String> args) { | 871 List<String> vmOptions, List<String> args) { |
886 var commands = <Command>[]; | 872 var commands = <Command>[]; |
887 var compilerConfiguration = new CompilerConfiguration(configuration); | 873 var compilerConfiguration = configuration.compilerConfiguration; |
888 var sharedOptions = info.optionsFromFile['sharedOptions'] as List<String>; | 874 var sharedOptions = info.optionsFromFile['sharedOptions'] as List<String>; |
889 | 875 |
890 var compileTimeArguments = <String>[]; | 876 var compileTimeArguments = <String>[]; |
891 String tempDir; | 877 String tempDir; |
892 if (compilerConfiguration.hasCompiler) { | 878 if (compilerConfiguration.hasCompiler) { |
893 compileTimeArguments = compilerConfiguration.computeCompilerArguments( | 879 compileTimeArguments = compilerConfiguration.computeCompilerArguments( |
894 vmOptions, sharedOptions, args); | 880 vmOptions, sharedOptions, args); |
895 // Avoid doing this for analyzer. | 881 // Avoid doing this for analyzer. |
896 var path = info.filePath; | 882 var path = info.filePath; |
897 if (vmOptionsVarient != 0) { | 883 if (vmOptionsVarient != 0) { |
(...skipping 12 matching lines...) Expand all Loading... |
910 } | 896 } |
911 } | 897 } |
912 | 898 |
913 CommandArtifact compilationArtifact = | 899 CommandArtifact compilationArtifact = |
914 compilerConfiguration.computeCompilationArtifact( | 900 compilerConfiguration.computeCompilationArtifact( |
915 buildDir, | 901 buildDir, |
916 tempDir, | 902 tempDir, |
917 CommandBuilder.instance, | 903 CommandBuilder.instance, |
918 compileTimeArguments, | 904 compileTimeArguments, |
919 environmentOverrides); | 905 environmentOverrides); |
920 if (!(configuration['skip-compilation'] as bool)) { | 906 if (!configuration.skipCompilation) { |
921 commands.addAll(compilationArtifact.commands); | 907 commands.addAll(compilationArtifact.commands); |
922 } | 908 } |
923 | 909 |
924 if (expectCompileError(info) && compilerConfiguration.hasCompiler) { | 910 if (expectCompileError(info) && compilerConfiguration.hasCompiler) { |
925 // Do not attempt to run the compiled result. A compilation | 911 // Do not attempt to run the compiled result. A compilation |
926 // error should be reported by the compilation command. | 912 // error should be reported by the compilation command. |
927 return commands; | 913 return commands; |
928 } | 914 } |
929 | 915 |
930 List<String> runtimeArguments = | 916 List<String> runtimeArguments = |
931 compilerConfiguration.computeRuntimeArguments( | 917 compilerConfiguration.computeRuntimeArguments( |
932 runtimeConfiguration, | 918 configuration.runtimeConfiguration, |
933 buildDir, | 919 buildDir, |
934 info, | 920 info, |
935 vmOptions, | 921 vmOptions, |
936 sharedOptions, | 922 sharedOptions, |
937 args, | 923 args, |
938 compilationArtifact); | 924 compilationArtifact); |
939 | 925 |
940 return commands | 926 return commands |
941 ..addAll(runtimeConfiguration.computeRuntimeCommands( | 927 ..addAll(configuration.runtimeConfiguration.computeRuntimeCommands( |
942 this, | 928 this, |
943 CommandBuilder.instance, | 929 CommandBuilder.instance, |
944 compilationArtifact, | 930 compilationArtifact, |
945 runtimeArguments, | 931 runtimeArguments, |
946 environmentOverrides)); | 932 environmentOverrides)); |
947 } | 933 } |
948 | 934 |
949 CreateTest makeTestCaseCreator(Map optionsFromFile) { | 935 CreateTest makeTestCaseCreator(Map<String, dynamic> optionsFromFile) { |
950 return (Path filePath, Path originTestPath, bool hasCompileError, | 936 return (Path filePath, Path originTestPath, bool hasCompileError, |
951 bool hasRuntimeError, | 937 bool hasRuntimeError, |
952 {bool isNegativeIfChecked: false, | 938 {bool isNegativeIfChecked: false, |
953 bool hasCompileErrorIfChecked: false, | 939 bool hasCompileErrorIfChecked: false, |
954 bool hasStaticWarning: false, | 940 bool hasStaticWarning: false, |
955 String multitestKey}) { | 941 String multitestKey}) { |
956 // Cache the test information for each test case. | 942 // Cache the test information for each test case. |
957 var info = new TestInformation( | 943 var info = new TestInformation( |
958 filePath, | 944 filePath, |
959 originTestPath, | 945 originTestPath, |
(...skipping 13 matching lines...) Expand all Loading... |
973 * _createUrlPathFromFile takes a [file], which is either located in the dart | 959 * _createUrlPathFromFile takes a [file], which is either located in the dart |
974 * or in the build directory, and will return a String representing | 960 * or in the build directory, and will return a String representing |
975 * the relative path to either the dart or the build directory. | 961 * the relative path to either the dart or the build directory. |
976 * Thus, the returned [String] will be the path component of the URL | 962 * Thus, the returned [String] will be the path component of the URL |
977 * corresponding to [file] (the http server serves files relative to the | 963 * corresponding to [file] (the http server serves files relative to the |
978 * dart/build directories). | 964 * dart/build directories). |
979 */ | 965 */ |
980 String _createUrlPathFromFile(Path file) { | 966 String _createUrlPathFromFile(Path file) { |
981 file = TestUtils.absolutePath(file); | 967 file = TestUtils.absolutePath(file); |
982 | 968 |
983 var relativeBuildDir = new Path(TestUtils.buildDir(configuration)); | 969 var relativeBuildDir = new Path(configuration.buildDirectory); |
984 var buildDir = TestUtils.absolutePath(relativeBuildDir); | 970 var buildDir = TestUtils.absolutePath(relativeBuildDir); |
985 var dartDir = TestUtils.absolutePath(TestUtils.dartDir); | 971 var dartDir = TestUtils.absolutePath(TestUtils.dartDir); |
986 | 972 |
987 var fileString = file.toString(); | 973 var fileString = file.toString(); |
988 if (fileString.startsWith(buildDir.toString())) { | 974 if (fileString.startsWith(buildDir.toString())) { |
989 var fileRelativeToBuildDir = file.relativeTo(buildDir); | 975 var fileRelativeToBuildDir = file.relativeTo(buildDir); |
990 return "/$PREFIX_BUILDDIR/$fileRelativeToBuildDir"; | 976 return "/$PREFIX_BUILDDIR/$fileRelativeToBuildDir"; |
991 } else if (fileString.startsWith(dartDir.toString())) { | 977 } else if (fileString.startsWith(dartDir.toString())) { |
992 var fileRelativeToDartDir = file.relativeTo(dartDir); | 978 var fileRelativeToDartDir = file.relativeTo(dartDir); |
993 return "/$PREFIX_DARTDIR/$fileRelativeToDartDir"; | 979 return "/$PREFIX_DARTDIR/$fileRelativeToDartDir"; |
994 } | 980 } |
995 // Unreachable | 981 // Unreachable |
996 print("Cannot create URL for path $file. Not in build or dart directory."); | 982 print("Cannot create URL for path $file. Not in build or dart directory."); |
997 exit(1); | 983 exit(1); |
998 return null; | 984 return null; |
999 } | 985 } |
1000 | 986 |
1001 Uri _getUriForBrowserTest(String pathComponent, String subtestName) { | 987 Uri _getUriForBrowserTest(String pathComponent, String subtestName) { |
1002 // Note: If we run test.py with the "--list" option, no http servers | 988 // Note: If we run test.py with the "--list" option, no http servers |
1003 // will be started. So we return a dummy url instead. | 989 // will be started. So we return a dummy url instead. |
1004 if (configuration['list'] as bool) { | 990 if (configuration.listTests) { |
1005 return Uri.parse('http://listing_the_tests_only'); | 991 return Uri.parse('http://listing_the_tests_only'); |
1006 } | 992 } |
1007 assert(configuration.containsKey('_servers_')); | 993 |
1008 var servers = configuration['_servers_'] as TestingServers; | 994 var serverPort = configuration.servers.port; |
1009 var serverPort = servers.port; | 995 var crossOriginPort = configuration.servers.crossOriginPort; |
1010 var crossOriginPort = servers.crossOriginPort; | |
1011 var parameters = {'crossOriginPort': crossOriginPort.toString()}; | 996 var parameters = {'crossOriginPort': crossOriginPort.toString()}; |
1012 if (subtestName != null) { | 997 if (subtestName != null) { |
1013 parameters['group'] = subtestName; | 998 parameters['group'] = subtestName; |
1014 } | 999 } |
1015 return new Uri( | 1000 return new Uri( |
1016 scheme: 'http', | 1001 scheme: 'http', |
1017 host: configuration['local_ip'] as String, | 1002 host: configuration.localIP, |
1018 port: serverPort, | 1003 port: serverPort, |
1019 path: pathComponent, | 1004 path: pathComponent, |
1020 queryParameters: parameters); | 1005 queryParameters: parameters); |
1021 } | 1006 } |
1022 | 1007 |
1023 void _createWrapperFile( | 1008 void _createWrapperFile( |
1024 String dartWrapperFilename, Path localDartLibraryFilename) { | 1009 String dartWrapperFilename, Path localDartLibraryFilename) { |
1025 File file = new File(dartWrapperFilename); | 1010 File file = new File(dartWrapperFilename); |
1026 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE); | 1011 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE); |
1027 | 1012 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 Path packageRoot, | 1054 Path packageRoot, |
1070 Path packages, | 1055 Path packages, |
1071 TestInformation info, | 1056 TestInformation info, |
1072 String testName, | 1057 String testName, |
1073 /* Set<Expectation> | Map<String, Set<Expectation>> */ expectations, | 1058 /* Set<Expectation> | Map<String, Set<Expectation>> */ expectations, |
1074 List<String> vmOptions, | 1059 List<String> vmOptions, |
1075 String tempDir) { | 1060 String tempDir) { |
1076 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot] | 1061 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot] |
1077 // on to the browser (it may be test specific). | 1062 // on to the browser (it may be test specific). |
1078 | 1063 |
1079 Path filePath = info.filePath; | 1064 var filePath = info.filePath; |
1080 String filename = filePath.toString(); | 1065 var fileName = filePath.toString(); |
1081 | 1066 |
1082 var compiler = configuration['compiler'] as String; | 1067 var optionsFromFile = info.optionsFromFile; |
1083 var runtime = configuration['runtime'] as String; | |
1084 final Map optionsFromFile = info.optionsFromFile; | |
1085 | 1068 |
1086 final String compilationTempDir = | 1069 var compilationTempDir = createCompilationOutputDirectory(info.filePath); |
1087 createCompilationOutputDirectory(info.filePath); | |
1088 | 1070 |
1089 String dartWrapperFilename = '$tempDir/test.dart'; | 1071 var dartWrapperFilename = '$tempDir/test.dart'; |
1090 String compiledDartWrapperFilename = '$compilationTempDir/test.js'; | 1072 var compiledDartWrapperFilename = '$compilationTempDir/test.js'; |
1091 | 1073 |
1092 String content = null; | 1074 String content = null; |
1093 Path dir = filePath.directoryPath; | 1075 var dir = filePath.directoryPath; |
1094 String nameNoExt = filePath.filenameWithoutExtension; | 1076 var nameNoExt = filePath.filenameWithoutExtension; |
1095 | 1077 |
1096 String customHtmlPath = dir.append('$nameNoExt.html').toNativePath(); | 1078 var customHtmlPath = dir.append('$nameNoExt.html').toNativePath(); |
1097 File customHtml = new File(customHtmlPath); | 1079 var customHtml = new File(customHtmlPath); |
1098 | 1080 |
1099 // Construct the command(s) that compile all the inputs needed by the | 1081 // Construct the command(s) that compile all the inputs needed by the |
1100 // browser test. For running Dart in DRT, this will be noop commands. | 1082 // browser test. For running Dart in DRT, this will be noop commands. |
1101 List<Command> commands = []..addAll(baseCommands); | 1083 var commands = baseCommands.toList(); |
1102 | 1084 |
1103 // Use existing HTML document if available. | 1085 // Use existing HTML document if available. |
1104 String htmlPath; | 1086 String htmlPath; |
1105 if (customHtml.existsSync()) { | 1087 if (customHtml.existsSync()) { |
1106 // If necessary, run the Polymer deploy steps. | 1088 // If necessary, run the Polymer deploy steps. |
1107 // TODO(jmesserly): this should be generalized for any tests that | 1089 // TODO(jmesserly): this should be generalized for any tests that |
1108 // require Pub deploy, not just polymer. | 1090 // require Pub deploy, not just polymer. |
1109 if (customHtml.readAsStringSync().contains('<!--polymer-test')) { | 1091 if (customHtml.readAsStringSync().contains('<!--polymer-test')) { |
1110 if (compiler != 'none') { | 1092 if (configuration.compiler != Compiler.none) { |
1111 commands.add( | 1093 commands.add( |
1112 _polymerDeployCommand(customHtmlPath, tempDir, optionsFromFile)); | 1094 _polymerDeployCommand(customHtmlPath, tempDir, optionsFromFile)); |
1113 | 1095 |
1114 Path pubspecYamlFile = _findPubspecYamlFile(filePath); | 1096 Path pubspecYamlFile = _findPubspecYamlFile(filePath); |
1115 Path homeDir = | 1097 Path homeDir = |
1116 (pubspecYamlFile == null) ? dir : pubspecYamlFile.directoryPath; | 1098 (pubspecYamlFile == null) ? dir : pubspecYamlFile.directoryPath; |
1117 htmlPath = '$tempDir/${dir.relativeTo(homeDir)}/$nameNoExt.html'; | 1099 htmlPath = '$tempDir/${dir.relativeTo(homeDir)}/$nameNoExt.html'; |
1118 dartWrapperFilename = '${htmlPath}_bootstrap.dart'; | 1100 dartWrapperFilename = '${htmlPath}_bootstrap.dart'; |
1119 compiledDartWrapperFilename = '$dartWrapperFilename.js'; | 1101 compiledDartWrapperFilename = '$dartWrapperFilename.js'; |
1120 } else { | 1102 } else { |
1121 htmlPath = customHtmlPath; | 1103 htmlPath = customHtmlPath; |
1122 } | 1104 } |
1123 } else { | 1105 } else { |
1124 htmlPath = '$tempDir/test.html'; | 1106 htmlPath = '$tempDir/test.html'; |
1125 dartWrapperFilename = filePath.toNativePath(); | 1107 dartWrapperFilename = filePath.toNativePath(); |
1126 | 1108 |
1127 var htmlContents = customHtml.readAsStringSync(); | 1109 var htmlContents = customHtml.readAsStringSync(); |
1128 if (compiler == 'none') { | 1110 if (configuration.compiler == Compiler.none) { |
1129 var dartUrl = _createUrlPathFromFile(filePath); | 1111 var dartUrl = _createUrlPathFromFile(filePath); |
1130 var dartScript = | 1112 var dartScript = |
1131 '<script type="application/dart" src="$dartUrl"></script>'; | 1113 '<script type="application/dart" src="$dartUrl"></script>'; |
1132 var jsUrl = '/packages/browser/dart.js'; | 1114 var jsUrl = '/packages/browser/dart.js'; |
1133 var jsScript = | 1115 var jsScript = |
1134 '<script type="text/javascript" src="$jsUrl"></script>'; | 1116 '<script type="text/javascript" src="$jsUrl"></script>'; |
1135 htmlContents = htmlContents.replaceAll( | 1117 htmlContents = htmlContents.replaceAll( |
1136 '%TEST_SCRIPTS%', '$dartScript\n$jsScript'); | 1118 '%TEST_SCRIPTS%', '$dartScript\n$jsScript'); |
1137 } else { | 1119 } else { |
1138 compiledDartWrapperFilename = '$tempDir/$nameNoExt.js'; | 1120 compiledDartWrapperFilename = '$tempDir/$nameNoExt.js'; |
1139 var jsUrl = '$nameNoExt.js'; | 1121 var jsUrl = '$nameNoExt.js'; |
1140 htmlContents = htmlContents.replaceAll( | 1122 htmlContents = htmlContents.replaceAll( |
1141 '%TEST_SCRIPTS%', '<script src="$jsUrl"></script>'); | 1123 '%TEST_SCRIPTS%', '<script src="$jsUrl"></script>'); |
1142 } | 1124 } |
1143 new File(htmlPath).writeAsStringSync(htmlContents); | 1125 new File(htmlPath).writeAsStringSync(htmlContents); |
1144 } | 1126 } |
1145 } else { | 1127 } else { |
1146 htmlPath = '$tempDir/test.html'; | 1128 htmlPath = '$tempDir/test.html'; |
1147 if (configuration['compiler'] != 'dart2js') { | 1129 if (configuration.compiler != Compiler.dart2js) { |
1148 // test.dart will import the dart test. | 1130 // test.dart will import the dart test. |
1149 _createWrapperFile(dartWrapperFilename, filePath); | 1131 _createWrapperFile(dartWrapperFilename, filePath); |
1150 } else { | 1132 } else { |
1151 dartWrapperFilename = filename; | 1133 dartWrapperFilename = fileName; |
1152 } | 1134 } |
1153 | 1135 |
1154 // Create the HTML file for the test. | 1136 // Create the HTML file for the test. |
1155 RandomAccessFile htmlTest = | 1137 var htmlTest = new File(htmlPath).openSync(mode: FileMode.WRITE); |
1156 new File(htmlPath).openSync(mode: FileMode.WRITE); | |
1157 | 1138 |
1158 String scriptPath = dartWrapperFilename; | 1139 var scriptPath = dartWrapperFilename; |
1159 if (compiler != 'none') { | 1140 if (configuration.compiler != Compiler.none) { |
1160 scriptPath = compiledDartWrapperFilename; | 1141 scriptPath = compiledDartWrapperFilename; |
1161 } | 1142 } |
1162 scriptPath = _createUrlPathFromFile(new Path(scriptPath)); | 1143 scriptPath = _createUrlPathFromFile(new Path(scriptPath)); |
1163 | 1144 |
1164 content = getHtmlContents(filename, scriptType, new Path("$scriptPath")); | 1145 content = getHtmlContents(fileName, scriptType, new Path("$scriptPath")); |
1165 htmlTest.writeStringSync(content); | 1146 htmlTest.writeStringSync(content); |
1166 htmlTest.closeSync(); | 1147 htmlTest.closeSync(); |
1167 } | 1148 } |
1168 | 1149 |
1169 if (compiler != 'none') { | 1150 if (configuration.compiler != Compiler.none) { |
| 1151 assert(configuration.compiler == Compiler.dart2js); |
| 1152 |
1170 commands.add(_compileCommand(dartWrapperFilename, | 1153 commands.add(_compileCommand(dartWrapperFilename, |
1171 compiledDartWrapperFilename, compiler, tempDir, optionsFromFile)); | 1154 compiledDartWrapperFilename, tempDir, optionsFromFile)); |
1172 } | 1155 } |
1173 | 1156 |
1174 // some tests require compiling multiple input scripts. | 1157 // some tests require compiling multiple input scripts. |
1175 var otherScripts = optionsFromFile['otherScripts'] as List<String>; | 1158 var otherScripts = optionsFromFile['otherScripts'] as List<String>; |
1176 for (var name in otherScripts) { | 1159 for (var name in otherScripts) { |
1177 var namePath = new Path(name); | 1160 var namePath = new Path(name); |
1178 var fileName = namePath.filename; | |
1179 var fromPath = filePath.directoryPath.join(namePath); | 1161 var fromPath = filePath.directoryPath.join(namePath); |
1180 if (compiler != 'none') { | 1162 |
| 1163 if (configuration.compiler != Compiler.none) { |
| 1164 assert(configuration.compiler == Compiler.dart2js); |
1181 assert(namePath.extension == 'dart'); | 1165 assert(namePath.extension == 'dart'); |
| 1166 |
1182 commands.add(_compileCommand(fromPath.toNativePath(), | 1167 commands.add(_compileCommand(fromPath.toNativePath(), |
1183 '$tempDir/$fileName.js', compiler, tempDir, optionsFromFile)); | 1168 '$tempDir/${namePath.filename}.js', tempDir, optionsFromFile)); |
1184 } | 1169 } |
1185 if (compiler == 'none') { | 1170 |
| 1171 if (configuration.compiler == Compiler.none) { |
1186 // For the tests that require multiple input scripts but are not | 1172 // For the tests that require multiple input scripts but are not |
1187 // compiled, move the input scripts over with the script so they can | 1173 // compiled, move the input scripts over with the script so they can |
1188 // be accessed. | 1174 // be accessed. |
1189 var result = new File(fromPath.toNativePath()).readAsStringSync(); | 1175 var result = new File(fromPath.toNativePath()).readAsStringSync(); |
1190 new File('$tempDir/$fileName').writeAsStringSync(result); | 1176 new File('$tempDir/${namePath.filename}').writeAsStringSync(result); |
1191 } | 1177 } |
1192 } | 1178 } |
1193 | 1179 |
1194 // Variables for browser multi-tests. | 1180 // Variables for browser multi-tests. |
1195 var multitest = info.optionsFromFile['isMultiHtmlTest'] as bool; | 1181 var multitest = info.optionsFromFile['isMultiHtmlTest'] as bool; |
1196 var subtestNames = multitest | 1182 var subtestNames = multitest |
1197 ? (info.optionsFromFile['subtestNames'] as List<String>) | 1183 ? (info.optionsFromFile['subtestNames'] as List<String>) |
1198 : <String>[null]; | 1184 : <String>[null]; |
1199 for (var subtestName in subtestNames) { | 1185 for (var subtestName in subtestNames) { |
1200 // Construct the command that executes the browser test | 1186 // Construct the command that executes the browser test |
1201 var commandSet = commands.toList(); | 1187 var commandSet = commands.toList(); |
1202 | 1188 |
1203 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); | 1189 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); |
1204 var fullHtmlPath = | 1190 var fullHtmlPath = |
1205 _getUriForBrowserTest(htmlPath_subtest, subtestName).toString(); | 1191 _getUriForBrowserTest(htmlPath_subtest, subtestName).toString(); |
1206 | 1192 |
1207 if (runtime == "drt") { | 1193 if (configuration.runtime == Runtime.drt) { |
1208 var dartFlags = <String>[]; | 1194 var dartFlags = <String>[]; |
1209 var contentShellOptions = ['--no-timeout', '--run-layout-test']; | 1195 var contentShellOptions = ['--no-timeout', '--run-layout-test']; |
1210 | 1196 |
1211 // Disable the GPU under Linux and Dartium. If the GPU is enabled, | 1197 // Disable the GPU under Linux and Dartium. If the GPU is enabled, |
1212 // Chrome may send a termination signal to a test. The test will be | 1198 // Chrome may send a termination signal to a test. The test will be |
1213 // terminated if a machine (bot) doesn't have a GPU or if a test is | 1199 // terminated if a machine (bot) doesn't have a GPU or if a test is |
1214 // still running after a certain period of time. | 1200 // still running after a certain period of time. |
1215 if (configuration['system'] == 'linux' && | 1201 if (configuration.system == System.linux && |
1216 configuration['runtime'] == 'drt') { | 1202 configuration.runtime == Runtime.drt) { |
1217 contentShellOptions.add('--disable-gpu'); | 1203 contentShellOptions.add('--disable-gpu'); |
1218 // TODO(terry): Roll 50 need this in conjection with disable-gpu. | 1204 // TODO(terry): Roll 50 need this in conjection with disable-gpu. |
1219 contentShellOptions.add('--disable-gpu-early-init'); | 1205 contentShellOptions.add('--disable-gpu-early-init'); |
1220 } | 1206 } |
1221 if (compiler == 'none') { | 1207 |
| 1208 if (configuration.compiler == Compiler.none) { |
1222 dartFlags.add('--ignore-unrecognized-flags'); | 1209 dartFlags.add('--ignore-unrecognized-flags'); |
1223 if (configuration["checked"] as bool) { | 1210 if (configuration.isChecked) { |
1224 dartFlags.add('--enable_asserts'); | 1211 dartFlags.add('--enable_asserts'); |
1225 dartFlags.add("--enable_type_checks"); | 1212 dartFlags.add("--enable_type_checks"); |
1226 } | 1213 } |
1227 dartFlags.addAll(vmOptions); | 1214 dartFlags.addAll(vmOptions); |
1228 } | 1215 } |
1229 | 1216 |
1230 commandSet.add(CommandBuilder.instance.getContentShellCommand( | 1217 commandSet.add(CommandBuilder.instance.getContentShellCommand( |
1231 contentShellFilename, | 1218 contentShellFilename, |
1232 fullHtmlPath, | 1219 fullHtmlPath, |
1233 contentShellOptions, | 1220 contentShellOptions, |
1234 dartFlags, | 1221 dartFlags, |
1235 environmentOverrides)); | 1222 environmentOverrides)); |
1236 } else { | 1223 } else { |
1237 commandSet.add(CommandBuilder.instance.getBrowserTestCommand( | 1224 commandSet.add(CommandBuilder.instance.getBrowserTestCommand( |
1238 runtime, fullHtmlPath, configuration, !isNegative(info))); | 1225 fullHtmlPath, configuration, !isNegative(info))); |
1239 } | 1226 } |
1240 | 1227 |
1241 // Create BrowserTestCase and queue it. | 1228 // Create BrowserTestCase and queue it. |
1242 var fullTestName = multitest ? '$testName/$subtestName' : testName; | 1229 var fullTestName = multitest ? '$testName/$subtestName' : testName; |
1243 var expectation = (multitest ? expectations[fullTestName] : expectations) | 1230 var expectation = (multitest ? expectations[fullTestName] : expectations) |
1244 as Set<Expectation>; | 1231 as Set<Expectation>; |
1245 var testCase = new BrowserTestCase('$suiteName/$fullTestName', commandSet, | 1232 var testCase = new BrowserTestCase('$suiteName/$fullTestName', commandSet, |
1246 configuration, expectation, info, isNegative(info), fullHtmlPath); | 1233 configuration, expectation, info, isNegative(info), fullHtmlPath); |
1247 | 1234 |
1248 enqueueNewTestCase(testCase); | 1235 enqueueNewTestCase(testCase); |
1249 } | 1236 } |
1250 } | 1237 } |
1251 | 1238 |
1252 void enqueueHtmlTest(HtmlTestInformation info, String testName, | 1239 void enqueueHtmlTest(HtmlTestInformation info, String testName, |
1253 Set<Expectation> expectations) { | 1240 Set<Expectation> expectations) { |
1254 var compiler = configuration['compiler'] as String; | 1241 var compiler = configuration.compiler; |
1255 var runtime = configuration['runtime'] as String; | 1242 var runtime = configuration.runtime; |
1256 // Html tests work only with the browser controller. | |
1257 if (!TestUtils.isBrowserRuntime(runtime) || runtime == 'drt') { | |
1258 return; | |
1259 } | |
1260 bool compileToJS = (compiler == 'dart2js'); | |
1261 | 1243 |
1262 final Path filePath = info.filePath; | 1244 // HTML tests work only with the browser controller. |
1263 final String tempDir = createOutputDirectory(filePath, ''); | 1245 if (!runtime.isBrowser || runtime == Runtime.drt) return; |
1264 final Uri tempUri = new Uri.file('$tempDir/'); | |
1265 String contents = htmlTest.getContents(info, compileToJS); | |
1266 final commands = <Command>[]; | |
1267 | 1246 |
1268 void Fail(String message) { | 1247 var compileToJS = compiler == Compiler.dart2js; |
| 1248 |
| 1249 var filePath = info.filePath; |
| 1250 var tempDir = createOutputDirectory(filePath, ''); |
| 1251 var tempUri = new Uri.file('$tempDir/'); |
| 1252 var contents = html_test.getContents(info, compileToJS); |
| 1253 var commands = <Command>[]; |
| 1254 |
| 1255 void fail(String message) { |
1269 var msg = "$message: ${info.filePath}"; | 1256 var msg = "$message: ${info.filePath}"; |
1270 DebugLogger.warning(msg); | 1257 DebugLogger.warning(msg); |
1271 contents = htmlTest.makeFailingHtmlFile(msg); | 1258 contents = html_test.makeFailingHtmlFile(msg); |
1272 } | 1259 } |
1273 | 1260 |
1274 if (info.scripts.length > 0) { | 1261 if (info.scripts.length > 0) { |
1275 Uri testUri = new Uri.file(filePath.toNativePath()); | 1262 var testUri = new Uri.file(filePath.toNativePath()); |
1276 for (String scriptPath in info.scripts) { | 1263 for (var scriptPath in info.scripts) { |
1277 if (!scriptPath.endsWith('.dart') && !scriptPath.endsWith('.js')) { | 1264 if (!scriptPath.endsWith('.dart') && !scriptPath.endsWith('.js')) { |
1278 Fail('HTML test scripts must be dart or javascript: $scriptPath'); | 1265 fail('HTML test scripts must be dart or javascript: $scriptPath'); |
1279 break; | 1266 break; |
1280 } | 1267 } |
1281 Uri uri = Uri.parse(scriptPath); | 1268 |
| 1269 var uri = Uri.parse(scriptPath); |
1282 if (uri.isAbsolute) { | 1270 if (uri.isAbsolute) { |
1283 Fail('HTML test scripts must have relative paths: $scriptPath'); | 1271 fail('HTML test scripts must have relative paths: $scriptPath'); |
1284 break; | 1272 break; |
1285 } | 1273 } |
| 1274 |
1286 if (uri.pathSegments.length > 1) { | 1275 if (uri.pathSegments.length > 1) { |
1287 Fail('HTML test scripts must be in test directory: $scriptPath'); | 1276 fail('HTML test scripts must be in test directory: $scriptPath'); |
1288 break; | 1277 break; |
1289 } | 1278 } |
1290 Uri script = testUri.resolveUri(uri); | 1279 |
1291 Uri copiedScript = tempUri.resolveUri(uri); | 1280 var script = testUri.resolveUri(uri); |
1292 if (compiler == 'none' || scriptPath.endsWith('.js')) { | 1281 var copiedScript = tempUri.resolveUri(uri); |
| 1282 if (compiler == Compiler.none || scriptPath.endsWith('.js')) { |
1293 new File.fromUri(copiedScript) | 1283 new File.fromUri(copiedScript) |
1294 .writeAsStringSync(new File.fromUri(script).readAsStringSync()); | 1284 .writeAsStringSync(new File.fromUri(script).readAsStringSync()); |
1295 } else { | 1285 } else { |
1296 var destination = copiedScript.toFilePath(); | 1286 var destination = copiedScript.toFilePath(); |
1297 if (compileToJS) { | 1287 if (compileToJS) { |
1298 destination = destination.replaceFirst(dartExtension, '.js'); | 1288 destination = destination.replaceFirst(dartExtension, '.js'); |
1299 } | 1289 } |
1300 commands.add(_compileCommand(script.toFilePath(), destination, | 1290 |
1301 compiler, tempDir, info.optionsFromFile)); | 1291 assert(compiler == Compiler.dart2js); |
| 1292 |
| 1293 commands.add(_compileCommand( |
| 1294 script.toFilePath(), destination, tempDir, info.optionsFromFile)); |
1302 } | 1295 } |
1303 } | 1296 } |
1304 } | 1297 } |
1305 final Uri htmlFile = tempUri.resolve(filePath.filename); | 1298 |
| 1299 var htmlFile = tempUri.resolve(filePath.filename); |
1306 new File.fromUri(htmlFile).writeAsStringSync(contents); | 1300 new File.fromUri(htmlFile).writeAsStringSync(contents); |
1307 | 1301 |
1308 var htmlPath = _createUrlPathFromFile(new Path(htmlFile.toFilePath())); | 1302 var htmlPath = _createUrlPathFromFile(new Path(htmlFile.toFilePath())); |
1309 var fullHtmlPath = _getUriForBrowserTest(htmlPath, null).toString(); | 1303 var fullHtmlPath = _getUriForBrowserTest(htmlPath, null).toString(); |
1310 commands.add(CommandBuilder.instance.getBrowserHtmlTestCommand(runtime, | 1304 commands.add(CommandBuilder.instance.getBrowserHtmlTestCommand( |
1311 fullHtmlPath, configuration, info.expectedMessages, !isNegative(info))); | 1305 fullHtmlPath, configuration, info.expectedMessages, !isNegative(info))); |
1312 String testDisplayName = '$suiteName/$testName'; | 1306 var testDisplayName = '$suiteName/$testName'; |
1313 var testCase = new BrowserTestCase(testDisplayName, commands, configuration, | 1307 var testCase = new BrowserTestCase(testDisplayName, commands, configuration, |
1314 expectations, info, isNegative(info), fullHtmlPath); | 1308 expectations, info, isNegative(info), fullHtmlPath); |
1315 enqueueNewTestCase(testCase); | 1309 enqueueNewTestCase(testCase); |
1316 return; | |
1317 } | 1310 } |
1318 | 1311 |
1319 /** Helper to create a compilation command for a single input file. */ | 1312 /** Helper to create a compilation command for a single input file. */ |
1320 Command _compileCommand(String inputFile, String outputFile, String compiler, | 1313 Command _compileCommand(String inputFile, String outputFile, String dir, |
1321 String dir, Map optionsFromFile) { | 1314 Map<String, dynamic> optionsFromFile) { |
1322 assert(compiler == 'dart2js'); | 1315 var args = <String>[]; |
1323 List<String> args; | 1316 |
1324 if (compilerPath.endsWith('.dart')) { | 1317 if (compilerPath.endsWith('.dart')) { |
1325 // Run the compiler script via the Dart VM. | 1318 // Run the compiler script via the Dart VM. |
1326 args = [compilerPath]; | 1319 args.add(compilerPath); |
1327 } else { | |
1328 args = []; | |
1329 } | 1320 } |
1330 args.addAll(TestUtils.standardOptions(configuration)); | 1321 |
| 1322 args.addAll(configuration.standardOptions); |
| 1323 |
1331 var packages = packagesArgument(optionsFromFile['packageRoot'] as String, | 1324 var packages = packagesArgument(optionsFromFile['packageRoot'] as String, |
1332 optionsFromFile['packages'] as String); | 1325 optionsFromFile['packages'] as String); |
1333 if (packages != null) args.add(packages); | 1326 if (packages != null) args.add(packages); |
| 1327 |
1334 args.add('--out=$outputFile'); | 1328 args.add('--out=$outputFile'); |
1335 args.add(inputFile); | 1329 args.add(inputFile); |
| 1330 |
1336 var options = optionsFromFile['sharedOptions'] as List<String>; | 1331 var options = optionsFromFile['sharedOptions'] as List<String>; |
1337 if (options != null) args.addAll(options); | 1332 if (options != null) args.addAll(options); |
| 1333 |
1338 return CommandBuilder.instance.getCompilationCommand( | 1334 return CommandBuilder.instance.getCompilationCommand( |
1339 compiler, | 1335 Compiler.dart2js.name, |
1340 outputFile, | 1336 outputFile, |
1341 !useSdk, | 1337 !useSdk, |
1342 dart2JsBootstrapDependencies, | 1338 dart2JsBootstrapDependencies, |
1343 compilerPath, | 1339 compilerPath, |
1344 args, | 1340 args, |
1345 environmentOverrides); | 1341 environmentOverrides); |
1346 } | 1342 } |
1347 | 1343 |
1348 /** Helper to create a Polymer deploy command for a single HTML file. */ | 1344 /** Helper to create a Polymer deploy command for a single HTML file. */ |
1349 Command _polymerDeployCommand( | 1345 Command _polymerDeployCommand(String inputFile, String outputDir, |
1350 String inputFile, String outputDir, Map optionsFromFile) { | 1346 Map<String, dynamic> optionsFromFile) { |
1351 List<String> args = []; | 1347 var args = <String>[]; |
1352 String packages = packagesArgument(optionsFromFile['packageRoot'] as String, | 1348 var packages = packagesArgument(optionsFromFile['packageRoot'] as String, |
1353 optionsFromFile['packages'] as String); | 1349 optionsFromFile['packages'] as String); |
1354 if (packages != null) args.add(packages); | 1350 if (packages != null) args.add(packages); |
1355 args | 1351 args |
1356 ..add('package:polymer/deploy.dart') | 1352 ..add('package:polymer/deploy.dart') |
1357 ..add('--test') | 1353 ..add('--test') |
1358 ..add(inputFile) | 1354 ..add(inputFile) |
1359 ..add('--out') | 1355 ..add('--out') |
1360 ..add(outputDir) | 1356 ..add(outputDir) |
1361 ..add('--file-filter') | 1357 ..add('--file-filter') |
1362 ..add('.svn'); | 1358 ..add('.svn'); |
1363 if (configuration['csp'] as bool) args.add('--csp'); | 1359 if (configuration.isCsp) args.add('--csp'); |
1364 | 1360 |
1365 return CommandBuilder.instance.getProcessCommand( | 1361 return CommandBuilder.instance.getProcessCommand( |
1366 'polymer_deploy', dartVmBinaryFileName, args, environmentOverrides); | 1362 'polymer_deploy', dartVmBinaryFileName, args, environmentOverrides); |
1367 } | 1363 } |
1368 | 1364 |
1369 String get scriptType { | 1365 String get scriptType { |
1370 switch (configuration['compiler'] as String) { | 1366 switch (configuration.compiler) { |
1371 case 'none': | 1367 case Compiler.none: |
1372 return 'application/dart'; | 1368 return 'application/dart'; |
1373 case 'dart2js': | 1369 case Compiler.dart2js: |
1374 case 'dart2analyzer': | 1370 case Compiler.dart2analyzer: |
1375 return 'text/javascript'; | 1371 return 'text/javascript'; |
1376 default: | 1372 default: |
1377 print('Non-web runtime, so no scriptType for: ' | 1373 print('Non-web runtime, so no scriptType for: ' |
1378 '${configuration["compiler"]}'); | 1374 '${configuration.compiler.name}'); |
1379 exit(1); | 1375 exit(1); |
1380 return null; | 1376 return null; |
1381 } | 1377 } |
1382 } | 1378 } |
1383 | 1379 |
1384 bool get hasRuntime { | 1380 bool get hasRuntime => configuration.runtime != Runtime.none; |
1385 switch (configuration['runtime'] as String) { | |
1386 case 'none': | |
1387 return false; | |
1388 default: | |
1389 return true; | |
1390 } | |
1391 } | |
1392 | 1381 |
1393 String get contentShellFilename { | 1382 String get contentShellFilename { |
1394 if (configuration['drt'] != '') { | 1383 if (configuration.drtPath != null) return configuration.drtPath; |
1395 return configuration['drt'] as String; | 1384 |
1396 } | |
1397 if (Platform.operatingSystem == 'macos') { | 1385 if (Platform.operatingSystem == 'macos') { |
1398 final path = dartDir.append( | 1386 final path = dartDir.append( |
1399 '/client/tests/drt/Content Shell.app/Contents/MacOS/Content Shell'); | 1387 '/client/tests/drt/Content Shell.app/Contents/MacOS/Content Shell'); |
1400 return path.toNativePath(); | 1388 return path.toNativePath(); |
1401 } | 1389 } |
1402 return dartDir.append('client/tests/drt/content_shell').toNativePath(); | 1390 return dartDir.append('client/tests/drt/content_shell').toNativePath(); |
1403 } | 1391 } |
1404 | 1392 |
1405 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { | 1393 List<String> commonArgumentsFromFile( |
1406 var args = TestUtils.standardOptions(configuration); | 1394 Path filePath, Map<String, dynamic> optionsFromFile) { |
| 1395 var args = configuration.standardOptions.toList(); |
1407 | 1396 |
1408 String packages = packagesArgument(optionsFromFile['packageRoot'] as String, | 1397 String packages = packagesArgument(optionsFromFile['packageRoot'] as String, |
1409 optionsFromFile['packages'] as String); | 1398 optionsFromFile['packages'] as String); |
1410 if (packages != null) { | 1399 if (packages != null) { |
1411 args.add(packages); | 1400 args.add(packages); |
1412 } | 1401 } |
1413 args.addAll(additionalOptions(filePath)); | 1402 args.addAll(additionalOptions(filePath)); |
1414 if (configuration['analyzer'] as bool) { | 1403 if (configuration.compiler == Compiler.dart2analyzer) { |
1415 args.add('--format=machine'); | 1404 args.add('--format=machine'); |
1416 args.add('--no-hints'); | 1405 args.add('--no-hints'); |
1417 } | |
1418 | 1406 |
1419 if (configuration["compiler"] == "dart2analyzer" && | 1407 if (filePath.filename.contains("dart2js") || |
1420 (filePath.filename.contains("dart2js") || | 1408 filePath.directoryPath.segments().last.contains('html_common')) { |
1421 filePath.directoryPath.segments().last.contains('html_common'))) { | 1409 args.add("--use-dart2js-libraries"); |
1422 args.add("--use-dart2js-libraries"); | 1410 } |
1423 } | 1411 } |
1424 | 1412 |
1425 var isMultitest = optionsFromFile["isMultitest"] as bool; | 1413 var isMultitest = optionsFromFile["isMultitest"] as bool; |
1426 var dartOptions = optionsFromFile["dartOptions"] as List<String>; | 1414 var dartOptions = optionsFromFile["dartOptions"] as List<String>; |
1427 | 1415 |
1428 assert(!isMultitest || dartOptions == null); | 1416 assert(!isMultitest || dartOptions == null); |
1429 args.add(filePath.toNativePath()); | 1417 args.add(filePath.toNativePath()); |
1430 if (dartOptions != null) { | 1418 if (dartOptions != null) { |
1431 args.addAll(dartOptions); | 1419 args.addAll(dartOptions); |
1432 } | 1420 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 * an image, if the expectation ends in .png. 'test.dart' will compare the | 1492 * an image, if the expectation ends in .png. 'test.dart' will compare the |
1505 * snapshot to the expectation file. When tests fail, 'test.dart' saves the | 1493 * snapshot to the expectation file. When tests fail, 'test.dart' saves the |
1506 * new snapshot into a file so it can be visualized or copied over. | 1494 * new snapshot into a file so it can be visualized or copied over. |
1507 * Expectations can be recorded for the first time by creating an empty file | 1495 * Expectations can be recorded for the first time by creating an empty file |
1508 * with the right name (touch test_name_test.png), running the test, and | 1496 * with the right name (touch test_name_test.png), running the test, and |
1509 * executing the copy command printed by the test script. | 1497 * executing the copy command printed by the test script. |
1510 * | 1498 * |
1511 * This method is static as the map is cached and shared amongst | 1499 * This method is static as the map is cached and shared amongst |
1512 * configurations, so it may not use [configuration]. | 1500 * configurations, so it may not use [configuration]. |
1513 */ | 1501 */ |
1514 Map readOptionsFromFile(Path filePath) { | 1502 Map<String, dynamic> readOptionsFromFile(Path filePath) { |
1515 if (filePath.filename.endsWith('.dill')) { | 1503 if (filePath.filename.endsWith('.dill')) { |
1516 return optionsFromKernelFile(); | 1504 return optionsFromKernelFile(); |
1517 } else if (filePath.segments().contains('co19')) { | 1505 } else if (filePath.segments().contains('co19')) { |
1518 return readOptionsFromCo19File(filePath); | 1506 return readOptionsFromCo19File(filePath); |
1519 } | 1507 } |
1520 RegExp testOptionsRegExp = new RegExp(r"// VMOptions=(.*)"); | 1508 RegExp testOptionsRegExp = new RegExp(r"// VMOptions=(.*)"); |
1521 RegExp sharedOptionsRegExp = new RegExp(r"// SharedOptions=(.*)"); | 1509 RegExp sharedOptionsRegExp = new RegExp(r"// SharedOptions=(.*)"); |
1522 RegExp dartOptionsRegExp = new RegExp(r"// DartOptions=(.*)"); | 1510 RegExp dartOptionsRegExp = new RegExp(r"// DartOptions=(.*)"); |
1523 RegExp otherScriptsRegExp = new RegExp(r"// OtherScripts=(.*)"); | 1511 RegExp otherScriptsRegExp = new RegExp(r"// OtherScripts=(.*)"); |
1524 RegExp otherResourcesRegExp = new RegExp(r"// OtherResources=(.*)"); | 1512 RegExp otherResourcesRegExp = new RegExp(r"// OtherResources=(.*)"); |
1525 RegExp packageRootRegExp = new RegExp(r"// PackageRoot=(.*)"); | 1513 RegExp packageRootRegExp = new RegExp(r"// PackageRoot=(.*)"); |
1526 RegExp packagesRegExp = new RegExp(r"// Packages=(.*)"); | 1514 RegExp packagesRegExp = new RegExp(r"// Packages=(.*)"); |
1527 RegExp isolateStubsRegExp = new RegExp(r"// IsolateStubs=(.*)"); | 1515 RegExp isolateStubsRegExp = new RegExp(r"// IsolateStubs=(.*)"); |
1528 // TODO(gram) Clean these up once the old directives are not supported. | 1516 // TODO(gram) Clean these up once the old directives are not supported. |
1529 RegExp domImportRegExp = new RegExp( | 1517 RegExp domImportRegExp = new RegExp( |
1530 r"^[#]?import.*dart:(html|web_audio|indexed_db|svg|web_sql)", | 1518 r"^[#]?import.*dart:(html|web_audio|indexed_db|svg|web_sql)", |
1531 multiLine: true); | 1519 multiLine: true); |
1532 | 1520 |
1533 var bytes = new File(filePath.toNativePath()).readAsBytesSync(); | 1521 var bytes = new File(filePath.toNativePath()).readAsBytesSync(); |
1534 String contents = decodeUtf8(bytes); | 1522 String contents = decodeUtf8(bytes); |
1535 bytes = null; | 1523 bytes = null; |
1536 | 1524 |
1537 // Find the options in the file. | 1525 // Find the options in the file. |
1538 var result = <List<String>>[]; | 1526 var result = <List<String>>[]; |
1539 List<String> dartOptions; | 1527 List<String> dartOptions; |
1540 List<String> sharedOptions; | 1528 List<String> sharedOptions; |
1541 String packageRoot; | 1529 String packageRoot; |
1542 String packages; | 1530 String packages; |
1543 | 1531 |
1544 Iterable<Match> matches = testOptionsRegExp.allMatches(contents); | 1532 var matches = testOptionsRegExp.allMatches(contents); |
1545 for (var match in matches) { | 1533 for (var match in matches) { |
1546 result.add(match[1].split(' ').where((e) => e != '').toList()); | 1534 result.add(match[1].split(' ').where((e) => e != '').toList()); |
1547 } | 1535 } |
1548 if (result.isEmpty) result.add([]); | 1536 if (result.isEmpty) result.add([]); |
1549 | 1537 |
1550 matches = dartOptionsRegExp.allMatches(contents); | 1538 matches = dartOptionsRegExp.allMatches(contents); |
1551 for (var match in matches) { | 1539 for (var match in matches) { |
1552 if (dartOptions != null) { | 1540 if (dartOptions != null) { |
1553 throw new Exception( | 1541 throw new Exception( |
1554 'More than one "// DartOptions=" line in test $filePath'); | 1542 'More than one "// DartOptions=" line in test $filePath'); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 "otherScripts": otherScripts, | 1620 "otherScripts": otherScripts, |
1633 "otherResources": otherResources, | 1621 "otherResources": otherResources, |
1634 "isMultitest": isMultitest, | 1622 "isMultitest": isMultitest, |
1635 "isMultiHtmlTest": isMultiHtmlTest, | 1623 "isMultiHtmlTest": isMultiHtmlTest, |
1636 "subtestNames": subtestNames, | 1624 "subtestNames": subtestNames, |
1637 "isolateStubs": isolateStubs, | 1625 "isolateStubs": isolateStubs, |
1638 "containsDomImport": containsDomImport | 1626 "containsDomImport": containsDomImport |
1639 }; | 1627 }; |
1640 } | 1628 } |
1641 | 1629 |
1642 Map optionsFromKernelFile() { | 1630 Map<String, dynamic> optionsFromKernelFile() { |
1643 return const { | 1631 return const { |
1644 "vmOptions": const [const []], | 1632 "vmOptions": const [const []], |
1645 "sharedOptions": const [], | 1633 "sharedOptions": const [], |
1646 "dartOptions": null, | 1634 "dartOptions": null, |
1647 "packageRoot": null, | 1635 "packageRoot": null, |
1648 "packages": null, | 1636 "packages": null, |
1649 "hasCompileError": false, | 1637 "hasCompileError": false, |
1650 "hasRuntimeError": false, | 1638 "hasRuntimeError": false, |
1651 "hasStaticWarning": false, | 1639 "hasStaticWarning": false, |
1652 "otherScripts": const [], | 1640 "otherScripts": const [], |
1653 "isMultitest": false, | 1641 "isMultitest": false, |
1654 "isMultiHtmlTest": false, | 1642 "isMultiHtmlTest": false, |
1655 "subtestNames": const [], | 1643 "subtestNames": const [], |
1656 "isolateStubs": '', | 1644 "isolateStubs": '', |
1657 "containsDomImport": false, | 1645 "containsDomImport": false, |
1658 }; | 1646 }; |
1659 } | 1647 } |
1660 | 1648 |
1661 List<List<String>> getVmOptions(Map optionsFromFile) { | 1649 List<List<String>> getVmOptions(Map<String, dynamic> optionsFromFile) { |
1662 var COMPILERS = const ['none', 'dartk', 'dartkp', 'precompiler', 'app_jit']; | 1650 const compilers = const [ |
1663 var RUNTIMES = const [ | 1651 Compiler.none, |
1664 'none', | 1652 Compiler.dartk, |
1665 'dart_precompiled', | 1653 Compiler.dartkp, |
1666 'vm', | 1654 Compiler.precompiler, |
1667 'drt', | 1655 Compiler.appJit |
1668 'dartium', | |
1669 'ContentShellOnAndroid', | |
1670 'DartiumOnAndroid' | |
1671 ]; | 1656 ]; |
1672 var needsVmOptions = COMPILERS.contains(configuration['compiler']) && | 1657 |
1673 RUNTIMES.contains(configuration['runtime']); | 1658 const runtimes = const [ |
| 1659 Runtime.none, |
| 1660 Runtime.dartPrecompiled, |
| 1661 Runtime.vm, |
| 1662 Runtime.drt, |
| 1663 Runtime.dartium, |
| 1664 Runtime.contentShellOnAndroid, |
| 1665 Runtime.dartiumOnAndroid |
| 1666 ]; |
| 1667 |
| 1668 var needsVmOptions = compilers.contains(configuration.compiler) && |
| 1669 runtimes.contains(configuration.runtime); |
1674 if (!needsVmOptions) return [[]]; | 1670 if (!needsVmOptions) return [[]]; |
1675 return optionsFromFile['vmOptions'] as List<List<String>>; | 1671 return optionsFromFile['vmOptions'] as List<List<String>>; |
1676 } | 1672 } |
1677 | 1673 |
1678 /** | 1674 /** |
1679 * Read options from a co19 test file. | 1675 * Read options from a co19 test file. |
1680 * | 1676 * |
1681 * The reason this is different from [readOptionsFromFile] is that | 1677 * The reason this is different from [readOptionsFromFile] is that |
1682 * co19 is developed based on a contract which defines certain test | 1678 * co19 is developed based on a contract which defines certain test |
1683 * tags. These tags may appear unused, but should not be removed | 1679 * tags. These tags may appear unused, but should not be removed |
1684 * without consulting with the co19 team. | 1680 * without consulting with the co19 team. |
1685 * | 1681 * |
1686 * Also, [readOptionsFromFile] recognizes a number of additional | 1682 * Also, [readOptionsFromFile] recognizes a number of additional |
1687 * tags that are not appropriate for use in general tests of | 1683 * tags that are not appropriate for use in general tests of |
1688 * conformance to the Dart language. Any Dart implementation must | 1684 * conformance to the Dart language. Any Dart implementation must |
1689 * pass the co19 test suite as is, and not require extra flags, | 1685 * pass the co19 test suite as is, and not require extra flags, |
1690 * environment variables, configuration files, etc. | 1686 * environment variables, configuration files, etc. |
1691 */ | 1687 */ |
1692 Map readOptionsFromCo19File(Path filePath) { | 1688 Map<String, dynamic> readOptionsFromCo19File(Path filePath) { |
1693 String contents = | 1689 String contents = |
1694 decodeUtf8(new File(filePath.toNativePath()).readAsBytesSync()); | 1690 decodeUtf8(new File(filePath.toNativePath()).readAsBytesSync()); |
1695 | 1691 |
1696 bool hasCompileError = contents.contains("@compile-error"); | 1692 bool hasCompileError = contents.contains("@compile-error"); |
1697 bool hasRuntimeError = contents.contains("@runtime-error"); | 1693 bool hasRuntimeError = contents.contains("@runtime-error"); |
1698 bool hasStaticWarning = contents.contains("@static-warning"); | 1694 bool hasStaticWarning = contents.contains("@static-warning"); |
1699 bool isMultitest = multiTestRegExp.hasMatch(contents); | 1695 bool isMultitest = multiTestRegExp.hasMatch(contents); |
1700 | 1696 |
1701 return { | 1697 return { |
1702 "vmOptions": <List>[[]], | 1698 "vmOptions": <List>[[]], |
(...skipping 10 matching lines...) Expand all Loading... |
1713 "subtestNames": <String>[], | 1709 "subtestNames": <String>[], |
1714 "isolateStubs": '', | 1710 "isolateStubs": '', |
1715 "containsDomImport": false, | 1711 "containsDomImport": false, |
1716 }; | 1712 }; |
1717 } | 1713 } |
1718 } | 1714 } |
1719 | 1715 |
1720 /// Used for testing packages in on off settings, i.e., we pass in the actual | 1716 /// Used for testing packages in on off settings, i.e., we pass in the actual |
1721 /// directory that we want to test. | 1717 /// directory that we want to test. |
1722 class PKGTestSuite extends StandardTestSuite { | 1718 class PKGTestSuite extends StandardTestSuite { |
1723 PKGTestSuite(Map<String, dynamic> configuration, Path directoryPath) | 1719 PKGTestSuite(Configuration configuration, Path directoryPath) |
1724 : super(configuration, directoryPath.filename, directoryPath, | 1720 : super(configuration, directoryPath.filename, directoryPath, |
1725 ["$directoryPath/.status"], | 1721 ["$directoryPath/.status"], |
1726 isTestFilePredicate: (f) => f.endsWith('_test.dart'), | 1722 isTestFilePredicate: (f) => f.endsWith('_test.dart'), |
1727 recursive: true); | 1723 recursive: true); |
1728 | 1724 |
1729 void enqueueBrowserTest( | 1725 void enqueueBrowserTest( |
1730 List<Command> baseCommands, | 1726 List<Command> baseCommands, |
1731 Path packageRoot, | 1727 Path packageRoot, |
1732 packages, | 1728 packages, |
1733 TestInformation info, | 1729 TestInformation info, |
1734 String testName, | 1730 String testName, |
1735 /* Set<Expectation> | Map<String, Set<Expectation>> */ dynamic | 1731 /* Set<Expectation> | Map<String, Set<Expectation>> */ dynamic |
1736 expectations) { | 1732 expectations) { |
1737 var runtime = configuration['runtime'] as String; | |
1738 var filePath = info.filePath; | 1733 var filePath = info.filePath; |
1739 var dir = filePath.directoryPath; | 1734 var dir = filePath.directoryPath; |
1740 var nameNoExt = filePath.filenameWithoutExtension; | 1735 var nameNoExt = filePath.filenameWithoutExtension; |
1741 var customHtmlPath = dir.append('$nameNoExt.html'); | 1736 var customHtmlPath = dir.append('$nameNoExt.html'); |
1742 var customHtml = new File(customHtmlPath.toNativePath()); | 1737 var customHtml = new File(customHtmlPath.toNativePath()); |
1743 if (!customHtml.existsSync()) { | 1738 if (!customHtml.existsSync()) { |
1744 super.enqueueBrowserTest( | 1739 super.enqueueBrowserTest( |
1745 baseCommands, packageRoot, packages, info, testName, expectations); | 1740 baseCommands, packageRoot, packages, info, testName, expectations); |
1746 } else { | 1741 } else { |
1747 var relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir); | 1742 var relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir); |
1748 var commands = baseCommands.toList(); | 1743 var commands = baseCommands.toList(); |
1749 var fullPath = _createUrlPathFromFile(customHtmlPath); | 1744 var fullPath = _createUrlPathFromFile(customHtmlPath); |
1750 | 1745 |
1751 commands.add(CommandBuilder.instance.getBrowserTestCommand( | 1746 commands.add(CommandBuilder.instance |
1752 runtime, fullPath, configuration, !isNegative(info))); | 1747 .getBrowserTestCommand(fullPath, configuration, !isNegative(info))); |
1753 var testDisplayName = '$suiteName/$testName'; | 1748 var testDisplayName = '$suiteName/$testName'; |
1754 enqueueNewTestCase(new BrowserTestCase( | 1749 enqueueNewTestCase(new BrowserTestCase( |
1755 testDisplayName, | 1750 testDisplayName, |
1756 commands, | 1751 commands, |
1757 configuration, | 1752 configuration, |
1758 expectations as Set<Expectation>, | 1753 expectations as Set<Expectation>, |
1759 info, | 1754 info, |
1760 isNegative(info), | 1755 isNegative(info), |
1761 relativeHtml.toNativePath())); | 1756 relativeHtml.toNativePath())); |
1762 } | 1757 } |
1763 } | 1758 } |
1764 } | 1759 } |
1765 | 1760 |
1766 /// A DartcCompilationTestSuite will run dartc on all of the tests. | 1761 /// A DartcCompilationTestSuite will run dartc on all of the tests. |
1767 /// | 1762 /// |
1768 /// Usually, the result of a dartc run is determined by the output of | 1763 /// Usually, the result of a dartc run is determined by the output of |
1769 /// dartc in connection with annotations in the test file. | 1764 /// dartc in connection with annotations in the test file. |
1770 class DartcCompilationTestSuite extends StandardTestSuite { | 1765 class DartcCompilationTestSuite extends StandardTestSuite { |
1771 List<String> _testDirs; | 1766 List<String> _testDirs; |
1772 | 1767 |
1773 DartcCompilationTestSuite( | 1768 DartcCompilationTestSuite( |
1774 Map<String, dynamic> configuration, | 1769 Configuration configuration, |
1775 String suiteName, | 1770 String suiteName, |
1776 String directoryPath, | 1771 String directoryPath, |
1777 List<String> this._testDirs, | 1772 List<String> this._testDirs, |
1778 List<String> expectations) | 1773 List<String> expectations) |
1779 : super(configuration, suiteName, new Path(directoryPath), expectations); | 1774 : super(configuration, suiteName, new Path(directoryPath), expectations); |
1780 | 1775 |
1781 List<String> additionalOptions(Path filePath) { | 1776 List<String> additionalOptions(Path filePath) { |
1782 return ['--fatal-warnings', '--fatal-type-errors']; | 1777 return ['--fatal-warnings', '--fatal-type-errors']; |
1783 } | 1778 } |
1784 | 1779 |
1785 Future enqueueTests() { | 1780 Future enqueueTests() { |
1786 var group = new FutureGroup(); | 1781 var group = new FutureGroup(); |
1787 | 1782 |
1788 for (String testDir in _testDirs) { | 1783 for (String testDir in _testDirs) { |
1789 Directory dir = new Directory(suiteDir.append(testDir).toNativePath()); | 1784 Directory dir = new Directory(suiteDir.append(testDir).toNativePath()); |
1790 if (dir.existsSync()) { | 1785 if (dir.existsSync()) { |
1791 enqueueDirectory(dir, group); | 1786 enqueueDirectory(dir, group); |
1792 } | 1787 } |
1793 } | 1788 } |
1794 | 1789 |
1795 return group.future; | 1790 return group.future; |
1796 } | 1791 } |
1797 } | 1792 } |
1798 | 1793 |
1799 class AnalyzeLibraryTestSuite extends DartcCompilationTestSuite { | 1794 class AnalyzeLibraryTestSuite extends DartcCompilationTestSuite { |
1800 static String libraryPath(Map<String, dynamic> configuration) => | 1795 static String libraryPath(Configuration configuration) => |
1801 configuration['use_sdk'] as bool | 1796 configuration.useSdk ? '${configuration.buildDirectory}/dart-sdk' : 'sdk'; |
1802 ? '${TestUtils.buildDir(configuration)}/dart-sdk' | |
1803 : 'sdk'; | |
1804 | 1797 |
1805 AnalyzeLibraryTestSuite(Map<String, dynamic> configuration) | 1798 AnalyzeLibraryTestSuite(Configuration configuration) |
1806 : super(configuration, 'analyze_library', libraryPath(configuration), | 1799 : super(configuration, 'analyze_library', libraryPath(configuration), |
1807 ['lib'], ['tests/lib/analyzer/analyze_library.status']); | 1800 ['lib'], ['tests/lib/analyzer/analyze_library.status']); |
1808 | 1801 |
1809 List<String> additionalOptions(Path filePath, {bool showSdkWarnings}) { | 1802 List<String> additionalOptions(Path filePath, {bool showSdkWarnings}) { |
1810 var options = super.additionalOptions(filePath); | 1803 var options = super.additionalOptions(filePath); |
1811 options.add('--sdk-warnings'); | 1804 options.add('--sdk-warnings'); |
1812 return options; | 1805 return options; |
1813 } | 1806 } |
1814 | 1807 |
1815 bool isTestFile(String filename) { | 1808 bool isTestFile(String filename) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 throw new Exception('Can\'t delete path $native_path. ' | 1951 throw new Exception('Can\'t delete path $native_path. ' |
1959 'This path might be too long'); | 1952 'This path might be too long'); |
1960 } | 1953 } |
1961 }); | 1954 }); |
1962 } else { | 1955 } else { |
1963 var dir = new Directory(path); | 1956 var dir = new Directory(path); |
1964 return dir.delete(recursive: true); | 1957 return dir.delete(recursive: true); |
1965 } | 1958 } |
1966 } | 1959 } |
1967 | 1960 |
1968 static void deleteTempSnapshotDirectory(Map configuration) { | 1961 static void deleteTempSnapshotDirectory(Configuration configuration) { |
1969 if (configuration['compiler'] == 'dart2app' || | 1962 if (configuration.compiler == Compiler.appJit || |
1970 configuration['compiler'] == 'dart2appjit' || | 1963 configuration.compiler == Compiler.precompiler) { |
1971 configuration['compiler'] == 'precompiler') { | 1964 var checked = configuration.isChecked ? '-checked' : ''; |
1972 var checked = (configuration['checked'] as bool) ? '-checked' : ''; | 1965 var strong = configuration.isStrong ? '-strong' : ''; |
1973 var strong = (configuration['strong'] as bool) ? '-strong' : ''; | 1966 var minified = configuration.isMinified ? '-minified' : ''; |
1974 var minified = (configuration['minified'] as bool) ? '-minified' : ''; | 1967 var csp = configuration.isCsp ? '-csp' : ''; |
1975 var csp = (configuration['csp'] as bool) ? '-csp' : ''; | 1968 var sdk = configuration.useSdk ? '-sdk' : ''; |
1976 var sdk = (configuration['use_sdk'] as bool) ? '-sdk' : ''; | 1969 var dirName = "${configuration.compiler.name}" |
1977 var dirName = "${configuration['compiler']}" | |
1978 "$checked$strong$minified$csp$sdk"; | 1970 "$checked$strong$minified$csp$sdk"; |
1979 String generatedPath = "${TestUtils.buildDir(configuration)}" | 1971 var generatedPath = |
1980 "/generated_compilations/$dirName"; | 1972 configuration.buildDirectory + "/generated_compilations/$dirName"; |
1981 TestUtils.deleteDirectory(generatedPath); | 1973 TestUtils.deleteDirectory(generatedPath); |
1982 } | 1974 } |
1983 } | 1975 } |
1984 | 1976 |
1985 static final debugLogFilePath = new Path(".debug.log"); | 1977 static final debugLogFilePath = new Path(".debug.log"); |
1986 | 1978 |
1987 /// If a flaky test did fail, infos about it (i.e. test name, stdin, stdout) | 1979 /// If a flaky test did fail, infos about it (i.e. test name, stdin, stdout) |
1988 /// will be written to this file. | 1980 /// will be written to this file. |
1989 /// | 1981 /// |
1990 /// This is useful for debugging flaky tests. When running on a buildbot, the | 1982 /// This is useful for debugging flaky tests. When running on a buildbot, the |
1991 /// file can be made visible in the waterfall UI. | 1983 /// file can be made visible in the waterfall UI. |
1992 static const flakyFileName = ".flaky.log"; | 1984 static const flakyFileName = ".flaky.log"; |
1993 | 1985 |
1994 /// If test.py was invoked with '--write-test-outcome-log it will write | 1986 /// If test.py was invoked with '--write-test-outcome-log it will write |
1995 /// test outcomes to this file. | 1987 /// test outcomes to this file. |
1996 static const testOutcomeFileName = ".test-outcome.log"; | 1988 static const testOutcomeFileName = ".test-outcome.log"; |
1997 | 1989 |
1998 static void ensureExists(String filename, Map configuration) { | 1990 static void ensureExists(String filename, Configuration configuration) { |
1999 if (!(configuration['list'] as bool) && | 1991 if (!configuration.listTests && !existsCache.doesFileExist(filename)) { |
2000 !existsCache.doesFileExist(filename)) { | |
2001 throw "'$filename' does not exist"; | 1992 throw "'$filename' does not exist"; |
2002 } | 1993 } |
2003 } | 1994 } |
2004 | 1995 |
2005 static Path absolutePath(Path path) { | 1996 static Path absolutePath(Path path) { |
2006 if (!path.isAbsolute) { | 1997 if (!path.isAbsolute) { |
2007 return currentWorkingDirectory.join(path); | 1998 return currentWorkingDirectory.join(path); |
2008 } | 1999 } |
2009 return path; | 2000 return path; |
2010 } | 2001 } |
2011 | 2002 |
2012 static String outputDir(Map configuration) { | |
2013 var result = ''; | |
2014 var system = configuration['system'] as String; | |
2015 if (system == 'fuchsia' || | |
2016 system == 'linux' || | |
2017 system == 'android' || | |
2018 system == 'windows') { | |
2019 result = 'out/'; | |
2020 } else if (system == 'macos') { | |
2021 result = 'xcodebuild/'; | |
2022 } else { | |
2023 throw new Exception('Unknown operating system: "$system"'); | |
2024 } | |
2025 return result; | |
2026 } | |
2027 | |
2028 static List<String> standardOptions(Map configuration) { | |
2029 var args = ["--ignore-unrecognized-flags"]; | |
2030 var compiler = configuration["compiler"] as String; | |
2031 if (compiler == "dart2js") { | |
2032 args = ['--generate-code-with-compile-time-errors', '--test-mode']; | |
2033 if (configuration["checked"] as bool) { | |
2034 args.add('--enable-checked-mode'); | |
2035 } | |
2036 // args.add("--verbose"); | |
2037 if (!isBrowserRuntime(configuration['runtime'] as String)) { | |
2038 args.add("--allow-mock-compilation"); | |
2039 args.add("--categories=all"); | |
2040 } | |
2041 } | |
2042 if ((compiler == "dart2js") && (configuration["minified"] as bool)) { | |
2043 args.add("--minify"); | |
2044 } | |
2045 if (compiler == "dart2js" && (configuration["csp"] as bool)) { | |
2046 args.add("--csp"); | |
2047 } | |
2048 if (compiler == "dart2js" && (configuration["fast_startup"] as bool)) { | |
2049 args.add("--fast-startup"); | |
2050 } | |
2051 if (compiler == "dart2js" && | |
2052 (configuration["dart2js_with_kernel"] as bool)) { | |
2053 args.add("--use-kernel"); | |
2054 } | |
2055 return args; | |
2056 } | |
2057 | |
2058 static bool isBrowserRuntime(String runtime) { | |
2059 const BROWSERS = const [ | |
2060 'drt', | |
2061 'dartium', | |
2062 'ie9', | |
2063 'ie10', | |
2064 'ie11', | |
2065 'safari', | |
2066 'opera', | |
2067 'chrome', | |
2068 'ff', | |
2069 'chromeOnAndroid', | |
2070 'safarimobilesim', | |
2071 'ContentShellOnAndroid', | |
2072 'DartiumOnAndroid' | |
2073 ]; | |
2074 return BROWSERS.contains(runtime); | |
2075 } | |
2076 | |
2077 static bool isJsCommandLineRuntime(String runtime) => | |
2078 const ['d8', 'jsshell'].contains(runtime); | |
2079 | |
2080 static bool isCommandLineAnalyzer(String compiler) => | |
2081 compiler == 'dart2analyzer'; | |
2082 | |
2083 static String buildDir(Map configuration) { | |
2084 // FIXME(kustermann,ricow): Our code assumes that the returned 'buildDir' | |
2085 // is relative to the current working directory. | |
2086 // Thus, if we pass in an absolute path (e.g. '--build-directory=/tmp/out') | |
2087 // we get into trouble. | |
2088 if (configuration['build_directory'] == '') { | |
2089 configuration['configuration_directory'] = | |
2090 configurationDir(configuration); | |
2091 configuration['build_directory'] = outputDir(configuration) + | |
2092 (configuration['configuration_directory'] as String); | |
2093 } | |
2094 return configuration['build_directory'] as String; | |
2095 } | |
2096 | |
2097 static String configurationDir(Map configuration) { | |
2098 // This returns the correct configuration directory (the last component | |
2099 // of the output directory path) for regular dart checkouts. | |
2100 // Dartium checkouts use the --build-directory option to pass in the | |
2101 // correct build directory explicitly. | |
2102 // We allow our code to have been cross compiled, i.e., that there | |
2103 // is an X in front of the arch. We don't allow both a cross compiled | |
2104 // and a normal version to be present (except if you specifically pass | |
2105 // in the build_directory). | |
2106 String mode; | |
2107 switch (configuration['mode'] as String) { | |
2108 case 'debug': | |
2109 mode = 'Debug'; | |
2110 break; | |
2111 case 'release': | |
2112 mode = 'Release'; | |
2113 break; | |
2114 case 'product': | |
2115 mode = 'Product'; | |
2116 break; | |
2117 default: | |
2118 throw 'Unrecognized mode configuration: ${configuration['mode']}'; | |
2119 } | |
2120 String os; | |
2121 switch (configuration['system'] as String) { | |
2122 case 'android': | |
2123 os = 'Android'; | |
2124 break; | |
2125 case 'fuchsia': | |
2126 case 'linux': | |
2127 case 'macos': | |
2128 case 'windows': | |
2129 os = ''; | |
2130 break; | |
2131 default: | |
2132 throw 'Unrecognized operating system: ${configuration['system']}'; | |
2133 } | |
2134 var arch = (configuration['arch'] as String).toUpperCase(); | |
2135 var normal = '$mode$os$arch'; | |
2136 var cross = '$mode${os}X$arch'; | |
2137 var outDir = outputDir(configuration); | |
2138 var normalDir = new Directory(new Path('$outDir$normal').toNativePath()); | |
2139 var crossDir = new Directory(new Path('$outDir$cross').toNativePath()); | |
2140 if (normalDir.existsSync() && crossDir.existsSync()) { | |
2141 throw "You can't have both $normalDir and $crossDir, we don't know which" | |
2142 " binary to use"; | |
2143 } | |
2144 if (crossDir.existsSync()) { | |
2145 return cross; | |
2146 } | |
2147 return normal; | |
2148 } | |
2149 | |
2150 /** | |
2151 * Gets extra options under [key] passed to the testing script. | |
2152 */ | |
2153 static List<String> getExtraOptions(Map configuration, String key) { | |
2154 if (configuration[key] == null) return <String>[]; | |
2155 return (configuration[key] as String) | |
2156 .split(" ") | |
2157 .map((s) => s.trim()) | |
2158 .where((s) => s.isNotEmpty) | |
2159 .toList(); | |
2160 } | |
2161 | |
2162 /** | |
2163 * Gets extra vm options passed to the testing script. | |
2164 */ | |
2165 static List<String> getExtraVmOptions(Map configuration) => | |
2166 getExtraOptions(configuration, 'vm_options'); | |
2167 | |
2168 static int shortNameCounter = 0; // Make unique short file names on Windows. | 2003 static int shortNameCounter = 0; // Make unique short file names on Windows. |
2169 | 2004 |
2170 static String getShortName(String path) { | 2005 static String getShortName(String path) { |
2171 final PATH_REPLACEMENTS = const { | 2006 final PATH_REPLACEMENTS = const { |
2172 "pkg_polymer_e2e_test_bad_import_test": "polymer_bi", | 2007 "pkg_polymer_e2e_test_bad_import_test": "polymer_bi", |
2173 "pkg_polymer_e2e_test_canonicalization_test": "polymer_c16n", | 2008 "pkg_polymer_e2e_test_canonicalization_test": "polymer_c16n", |
2174 "pkg_polymer_e2e_test_experimental_boot_test": "polymer_boot", | 2009 "pkg_polymer_e2e_test_experimental_boot_test": "polymer_boot", |
2175 "pkg_polymer_e2e_test_good_import_test": "polymer_gi", | 2010 "pkg_polymer_e2e_test_good_import_test": "polymer_gi", |
2176 "tests_co19_src_Language_12_Expressions_14_Function_Invocation_": | 2011 "tests_co19_src_Language_12_Expressions_14_Function_Invocation_": |
2177 "co19_fn_invoke_", | 2012 "co19_fn_invoke_", |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2241 } | 2076 } |
2242 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { | 2077 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { |
2243 ++shortNameCounter; | 2078 ++shortNameCounter; |
2244 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); | 2079 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); |
2245 path = "short${shortNameCounter}_$pathEnd"; | 2080 path = "short${shortNameCounter}_$pathEnd"; |
2246 } | 2081 } |
2247 } | 2082 } |
2248 return path; | 2083 return path; |
2249 } | 2084 } |
2250 } | 2085 } |
OLD | NEW |