| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library runtime_configuration; | 5 library runtime_configuration; |
| 6 | 6 |
| 7 import 'dart:io' show Directory, File; |
| 8 |
| 7 import 'compiler_configuration.dart' show CommandArtifact; | 9 import 'compiler_configuration.dart' show CommandArtifact; |
| 8 | 10 |
| 9 // TODO(ahe): Remove this import, we can precompute all the values required | 11 // TODO(ahe): Remove this import, we can precompute all the values required |
| 10 // from TestSuite once the refactoring is complete. | 12 // from TestSuite once the refactoring is complete. |
| 11 import 'test_suite.dart' show TestSuite; | 13 import 'test_suite.dart' show TestSuite, TestUtils; |
| 12 | 14 |
| 13 import 'test_runner.dart' show Command, CommandBuilder; | 15 import 'test_runner.dart' show Command, CommandBuilder; |
| 14 | 16 |
| 17 /// Describes the commands to run a given test case or its compiled output. |
| 18 /// |
| 19 /// A single runtime configuration object exists per test suite, and is thus |
| 20 /// shared between multiple test cases, it should not be mutated after |
| 21 /// construction. |
| 22 // |
| 15 // TODO(ahe): I expect this class will become abstract very soon. | 23 // TODO(ahe): I expect this class will become abstract very soon. |
| 16 class RuntimeConfiguration { | 24 class RuntimeConfiguration { |
| 17 // TODO(ahe): Remove this constructor and move the switch to | 25 // TODO(ahe): Remove this constructor and move the switch to |
| 18 // test_options.dart. We probably want to store an instance of | 26 // test_options.dart. We probably want to store an instance of |
| 19 // [RuntimeConfiguration] in [configuration] there. | 27 // [RuntimeConfiguration] in [configuration] there. |
| 20 factory RuntimeConfiguration(Map configuration) { | 28 factory RuntimeConfiguration(Map configuration) { |
| 21 String runtime = configuration['runtime']; | 29 String runtime = configuration['runtime']; |
| 22 bool useBlobs = configuration['use_blobs']; | 30 bool useBlobs = configuration['use_blobs']; |
| 23 | 31 |
| 24 switch (runtime) { | 32 switch (runtime) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 52 | 60 |
| 53 case 'dart_precompiled': | 61 case 'dart_precompiled': |
| 54 if (configuration['system'] == 'android') { | 62 if (configuration['system'] == 'android') { |
| 55 return new DartPrecompiledAdbRuntimeConfiguration(useBlobs: useBlobs); | 63 return new DartPrecompiledAdbRuntimeConfiguration(useBlobs: useBlobs); |
| 56 } | 64 } |
| 57 return new DartPrecompiledRuntimeConfiguration(useBlobs: useBlobs); | 65 return new DartPrecompiledRuntimeConfiguration(useBlobs: useBlobs); |
| 58 | 66 |
| 59 case 'drt': | 67 case 'drt': |
| 60 return new DrtRuntimeConfiguration(); | 68 return new DrtRuntimeConfiguration(); |
| 61 | 69 |
| 70 case 'self_check': |
| 71 return new SelfCheckRuntimeConfiguration(); |
| 72 |
| 62 default: | 73 default: |
| 63 throw "Unknown runtime '$runtime'"; | 74 throw "Unknown runtime '$runtime'"; |
| 64 } | 75 } |
| 65 } | 76 } |
| 66 | 77 |
| 67 RuntimeConfiguration._subclass(); | 78 RuntimeConfiguration._subclass(); |
| 68 | 79 |
| 69 int computeTimeoutMultiplier( | 80 int computeTimeoutMultiplier( |
| 70 {String mode, bool isChecked: false, bool isReload: false, String arch}) { | 81 {String mode, bool isChecked: false, bool isReload: false, String arch}) { |
| 71 return 1; | 82 return 1; |
| 72 } | 83 } |
| 73 | 84 |
| 74 List<Command> computeRuntimeCommands( | 85 List<Command> computeRuntimeCommands( |
| 75 TestSuite suite, | 86 TestSuite suite, |
| 76 CommandBuilder commandBuilder, | 87 CommandBuilder commandBuilder, |
| 77 CommandArtifact artifact, | 88 CommandArtifact artifact, |
| 78 List<String> arguments, | 89 List<String> arguments, |
| 79 Map<String, String> environmentOverrides) { | 90 Map<String, String> environmentOverrides) { |
| 80 // TODO(ahe): Make this method abstract. | 91 // TODO(ahe): Make this method abstract. |
| 81 throw "Unimplemented runtime '$runtimeType'"; | 92 throw "Unimplemented runtime '$runtimeType'"; |
| 82 } | 93 } |
| 83 | 94 |
| 84 List<String> dart2jsPreambles(Uri preambleDir) => []; | 95 List<String> dart2jsPreambles(Uri preambleDir) => []; |
| 96 |
| 97 bool get shouldSkipNegativeTests => false; |
| 85 } | 98 } |
| 86 | 99 |
| 87 /// The 'none' runtime configuration. | 100 /// The 'none' runtime configuration. |
| 88 class NoneRuntimeConfiguration extends RuntimeConfiguration { | 101 class NoneRuntimeConfiguration extends RuntimeConfiguration { |
| 89 NoneRuntimeConfiguration() : super._subclass(); | 102 NoneRuntimeConfiguration() : super._subclass(); |
| 90 | 103 |
| 91 List<Command> computeRuntimeCommands( | 104 List<Command> computeRuntimeCommands( |
| 92 TestSuite suite, | 105 TestSuite suite, |
| 93 CommandBuilder commandBuilder, | 106 CommandBuilder commandBuilder, |
| 94 CommandArtifact artifact, | 107 CommandArtifact artifact, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 return <Command>[ | 293 return <Command>[ |
| 281 commandBuilder.getAdbPrecompiledCommand(precompiledRunner, | 294 commandBuilder.getAdbPrecompiledCommand(precompiledRunner, |
| 282 processTest, | 295 processTest, |
| 283 script, | 296 script, |
| 284 arguments, | 297 arguments, |
| 285 useBlobs) | 298 useBlobs) |
| 286 ]; | 299 ]; |
| 287 } | 300 } |
| 288 } | 301 } |
| 289 | 302 |
| 303 class SelfCheckRuntimeConfiguration extends DartVmRuntimeConfiguration { |
| 304 final List<String> selfCheckers = <String>[]; |
| 305 |
| 306 SelfCheckRuntimeConfiguration() { |
| 307 searchForSelfCheckers(); |
| 308 } |
| 309 |
| 310 void searchForSelfCheckers() { |
| 311 Uri pkg = TestUtils.dartDirUri.resolve('pkg'); |
| 312 for (var entry in new Directory.fromUri(pkg).listSync(recursive: true)) { |
| 313 if (entry is File && entry.path.endsWith('_self_check.dart')) { |
| 314 selfCheckers.add(entry.path); |
| 315 } |
| 316 } |
| 317 } |
| 318 |
| 319 List<Command> computeRuntimeCommands( |
| 320 TestSuite suite, |
| 321 CommandBuilder commandBuilder, |
| 322 CommandArtifact artifact, |
| 323 List<String> arguments, |
| 324 Map<String, String> environmentOverrides) { |
| 325 String executable = suite.dartVmBinaryFileName; |
| 326 return selfCheckers |
| 327 .map((String tester) => commandBuilder.getVmBatchCommand( |
| 328 executable, tester, arguments, environmentOverrides, |
| 329 checked: suite.configuration['checked'])) |
| 330 .toList(); |
| 331 } |
| 332 |
| 333 @override |
| 334 bool get shouldSkipNegativeTests => true; |
| 335 } |
| 336 |
| 290 /// Temporary runtime configuration for browser runtimes that haven't been | 337 /// Temporary runtime configuration for browser runtimes that haven't been |
| 291 /// migrated yet. | 338 /// migrated yet. |
| 292 // TODO(ahe): Remove this class. | 339 // TODO(ahe): Remove this class. |
| 293 class DummyRuntimeConfiguration extends DartVmRuntimeConfiguration { | 340 class DummyRuntimeConfiguration extends DartVmRuntimeConfiguration { |
| 294 List<Command> computeRuntimeCommands( | 341 List<Command> computeRuntimeCommands( |
| 295 TestSuite suite, | 342 TestSuite suite, |
| 296 CommandBuilder commandBuilder, | 343 CommandBuilder commandBuilder, |
| 297 CommandArtifact artifact, | 344 CommandArtifact artifact, |
| 298 List<String> arguments, | 345 List<String> arguments, |
| 299 Map<String, String> environmentOverrides) { | 346 Map<String, String> environmentOverrides) { |
| 300 throw "Unimplemented runtime '$runtimeType'"; | 347 throw "Unimplemented runtime '$runtimeType'"; |
| 301 } | 348 } |
| 302 } | 349 } |
| OLD | NEW |