| 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 import 'dart:io'; | 5 library runtime_configuration; |
| 6 | 6 |
| 7 import 'compiler_configuration.dart'; | 7 import 'dart:io' show Directory, File; |
| 8 import 'configuration.dart'; | 8 |
| 9 import 'compiler_configuration.dart' show CommandArtifact; |
| 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'; | 13 import 'test_suite.dart' show TestSuite, TestUtils; |
| 12 import 'test_runner.dart'; | 14 |
| 15 import 'test_runner.dart' show Command, CommandBuilder; |
| 13 | 16 |
| 14 /// Describes the commands to run a given test case or its compiled output. | 17 /// Describes the commands to run a given test case or its compiled output. |
| 15 /// | 18 /// |
| 16 /// A single runtime configuration object exists per test suite, and is thus | 19 /// A single runtime configuration object exists per test suite, and is thus |
| 17 /// shared between multiple test cases, it should not be mutated after | 20 /// shared between multiple test cases, it should not be mutated after |
| 18 /// construction. | 21 /// construction. |
| 19 abstract class RuntimeConfiguration { | 22 // |
| 20 factory RuntimeConfiguration(Configuration configuration) { | 23 // TODO(ahe): I expect this class will become abstract very soon. |
| 21 switch (configuration.runtime) { | 24 class RuntimeConfiguration { |
| 22 case Runtime.contentShellOnAndroid: | 25 // TODO(ahe): Remove this constructor and move the switch to |
| 23 case Runtime.dartiumOnAndroid: | 26 // test_options.dart. We probably want to store an instance of |
| 24 case Runtime.chrome: | 27 // [RuntimeConfiguration] in [configuration] there. |
| 25 case Runtime.chromeOnAndroid: | 28 factory RuntimeConfiguration(Map<String, dynamic> configuration) { |
| 26 case Runtime.dartium: | 29 var runtime = configuration['runtime'] as String; |
| 27 case Runtime.firefox: | 30 var useBlobs = configuration['use_blobs'] as bool; |
| 28 case Runtime.ie11: | 31 |
| 29 case Runtime.ie10: | 32 switch (runtime) { |
| 30 case Runtime.ie9: | 33 case 'ContentShellOnAndroid': |
| 31 case Runtime.opera: | 34 case 'DartiumOnAndroid': |
| 32 case Runtime.safari: | 35 case 'chrome': |
| 33 case Runtime.safariMobileSim: | 36 case 'chromeOnAndroid': |
| 37 case 'dartium': |
| 38 case 'ff': |
| 39 case 'firefox': |
| 40 case 'ie11': |
| 41 case 'ie10': |
| 42 case 'ie9': |
| 43 case 'opera': |
| 44 case 'safari': |
| 45 case 'safarimobilesim': |
| 34 // TODO(ahe): Replace this with one or more browser runtimes. | 46 // TODO(ahe): Replace this with one or more browser runtimes. |
| 35 return new DummyRuntimeConfiguration(); | 47 return new DummyRuntimeConfiguration(); |
| 36 | 48 |
| 37 case Runtime.jsshell: | 49 case 'jsshell': |
| 38 return new JsshellRuntimeConfiguration(); | 50 return new JsshellRuntimeConfiguration(); |
| 39 | 51 |
| 40 case Runtime.d8: | 52 case 'd8': |
| 41 return new D8RuntimeConfiguration(); | 53 return new D8RuntimeConfiguration(); |
| 42 | 54 |
| 43 case Runtime.none: | 55 case 'none': |
| 44 return new NoneRuntimeConfiguration(); | 56 return new NoneRuntimeConfiguration(); |
| 45 | 57 |
| 46 case Runtime.vm: | 58 case 'vm': |
| 47 return new StandaloneDartRuntimeConfiguration(); | 59 return new StandaloneDartRuntimeConfiguration(); |
| 48 | 60 |
| 49 case Runtime.flutter: | 61 case 'flutter': |
| 50 return new StandaloneFlutterEngineConfiguration(); | 62 return new StandaloneFlutterEngineConfiguration(); |
| 51 | 63 |
| 52 case Runtime.dartPrecompiled: | 64 case 'dart_precompiled': |
| 53 if (configuration.system == System.android) { | 65 if (configuration['system'] == 'android') { |
| 54 return new DartPrecompiledAdbRuntimeConfiguration( | 66 return new DartPrecompiledAdbRuntimeConfiguration(useBlobs: useBlobs); |
| 55 useBlobs: configuration.useBlobs); | |
| 56 } else { | |
| 57 return new DartPrecompiledRuntimeConfiguration( | |
| 58 useBlobs: configuration.useBlobs); | |
| 59 } | 67 } |
| 60 break; | 68 return new DartPrecompiledRuntimeConfiguration(useBlobs: useBlobs); |
| 61 | 69 |
| 62 case Runtime.drt: | 70 case 'drt': |
| 63 return new DrtRuntimeConfiguration(); | 71 return new DrtRuntimeConfiguration(); |
| 64 | 72 |
| 65 case Runtime.selfCheck: | 73 case 'self_check': |
| 66 return new SelfCheckRuntimeConfiguration(); | 74 return new SelfCheckRuntimeConfiguration(); |
| 75 |
| 76 default: |
| 77 throw "Unknown runtime '$runtime'"; |
| 67 } | 78 } |
| 68 | |
| 69 throw "unreachable"; | |
| 70 } | 79 } |
| 71 | 80 |
| 72 RuntimeConfiguration._subclass(); | 81 RuntimeConfiguration._subclass(); |
| 73 | 82 |
| 74 int timeoutMultiplier( | 83 int computeTimeoutMultiplier( |
| 75 {Mode mode, | 84 {String mode, bool isChecked: false, bool isReload: false, String arch}) { |
| 76 bool isChecked: false, | |
| 77 bool isReload: false, | |
| 78 Architecture arch}) { | |
| 79 return 1; | 85 return 1; |
| 80 } | 86 } |
| 81 | 87 |
| 82 List<Command> computeRuntimeCommands( | 88 List<Command> computeRuntimeCommands( |
| 83 TestSuite suite, | 89 TestSuite suite, |
| 84 CommandBuilder commandBuilder, | 90 CommandBuilder commandBuilder, |
| 85 CommandArtifact artifact, | 91 CommandArtifact artifact, |
| 86 List<String> arguments, | 92 List<String> arguments, |
| 87 Map<String, String> environmentOverrides) { | 93 Map<String, String> environmentOverrides) { |
| 88 // TODO(ahe): Make this method abstract. | 94 // TODO(ahe): Make this method abstract. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 169 |
| 164 List<String> dart2jsPreambles(Uri preambleDir) { | 170 List<String> dart2jsPreambles(Uri preambleDir) { |
| 165 return ['-f', preambleDir.resolve('jsshell.js').toFilePath(), '-f']; | 171 return ['-f', preambleDir.resolve('jsshell.js').toFilePath(), '-f']; |
| 166 } | 172 } |
| 167 } | 173 } |
| 168 | 174 |
| 169 /// Common runtime configuration for runtimes based on the Dart VM. | 175 /// Common runtime configuration for runtimes based on the Dart VM. |
| 170 class DartVmRuntimeConfiguration extends RuntimeConfiguration { | 176 class DartVmRuntimeConfiguration extends RuntimeConfiguration { |
| 171 DartVmRuntimeConfiguration() : super._subclass(); | 177 DartVmRuntimeConfiguration() : super._subclass(); |
| 172 | 178 |
| 173 int timeoutMultiplier( | 179 int computeTimeoutMultiplier( |
| 174 {Mode mode, | 180 {String mode, bool isChecked: false, bool isReload: false, String arch}) { |
| 175 bool isChecked: false, | 181 int multiplier = 1; |
| 176 bool isReload: false, | |
| 177 Architecture arch}) { | |
| 178 var multiplier = 1; | |
| 179 | |
| 180 switch (arch) { | 182 switch (arch) { |
| 181 case Architecture.simarm: | 183 case 'simarm': |
| 182 case Architecture.arm: | 184 case 'arm': |
| 183 case Architecture.simarmv6: | 185 case 'simarmv6': |
| 184 case Architecture.armv6: | 186 case 'armv6': |
| 185 case Architecture.simarmv5te: | 187 case ' simarmv5te': |
| 186 case Architecture.armv5te: | 188 case 'armv5te': |
| 187 case Architecture.simmips: | 189 case 'simmips': |
| 188 case Architecture.mips: | 190 case 'mips': |
| 189 case Architecture.simarm64: | 191 case 'simarm64': |
| 190 case Architecture.simdbc: | 192 case 'simdbc': |
| 191 case Architecture.simdbc64: | 193 case 'simdbc64': |
| 192 multiplier *= 4; | 194 multiplier *= 4; |
| 193 break; | 195 break; |
| 194 } | 196 } |
| 195 | 197 if (mode == 'debug') { |
| 196 if (mode.isDebug) { | |
| 197 multiplier *= 2; | 198 multiplier *= 2; |
| 198 if (isReload) { | 199 if (isReload) { |
| 199 multiplier *= 2; | 200 multiplier *= 2; |
| 200 } | 201 } |
| 201 } | 202 } |
| 202 return multiplier; | 203 return multiplier; |
| 203 } | 204 } |
| 204 } | 205 } |
| 205 | 206 |
| 206 /// Runtime configuration for Content Shell. We previously used a similar | 207 /// Runtime configuration for Content Shell. We previously used a similar |
| 207 /// program named Dump Render Tree, hence the name. | 208 /// program named Dump Render Tree, hence the name. |
| 208 class DrtRuntimeConfiguration extends DartVmRuntimeConfiguration { | 209 class DrtRuntimeConfiguration extends DartVmRuntimeConfiguration { |
| 209 int timeoutMultiplier( | 210 int computeTimeoutMultiplier( |
| 210 {Mode mode, | 211 {String mode, bool isChecked: false, bool isReload: false, String arch}) { |
| 211 bool isChecked: false, | |
| 212 bool isReload: false, | |
| 213 Architecture arch}) { | |
| 214 return 4 // Allow additional time for browser testing to run. | 212 return 4 // Allow additional time for browser testing to run. |
| 215 // TODO(ahe): We might need to distinguish between DRT for running | 213 // TODO(ahe): We might need to distinguish between DRT for running |
| 216 // JavaScript and Dart code. I'm not convinced the inherited timeout | 214 // JavaScript and Dart code. I'm not convinced the inherited timeout |
| 217 // multiplier is relevant for JavaScript. | 215 // multiplier is relevant for JavaScript. |
| 218 * | 216 * |
| 219 super.timeoutMultiplier( | 217 super.computeTimeoutMultiplier( |
| 220 mode: mode, isChecked: isChecked, isReload: isReload); | 218 mode: mode, isChecked: isChecked, isReload: isReload); |
| 221 } | 219 } |
| 222 } | 220 } |
| 223 | 221 |
| 224 /// The standalone Dart VM binary, "dart" or "dart.exe". | 222 /// The standalone Dart VM binary, "dart" or "dart.exe". |
| 225 class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration { | 223 class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration { |
| 226 List<Command> computeRuntimeCommands( | 224 List<Command> computeRuntimeCommands( |
| 227 TestSuite suite, | 225 TestSuite suite, |
| 228 CommandBuilder commandBuilder, | 226 CommandBuilder commandBuilder, |
| 229 CommandArtifact artifact, | 227 CommandArtifact artifact, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 List<Command> computeRuntimeCommands( | 336 List<Command> computeRuntimeCommands( |
| 339 TestSuite suite, | 337 TestSuite suite, |
| 340 CommandBuilder commandBuilder, | 338 CommandBuilder commandBuilder, |
| 341 CommandArtifact artifact, | 339 CommandArtifact artifact, |
| 342 List<String> arguments, | 340 List<String> arguments, |
| 343 Map<String, String> environmentOverrides) { | 341 Map<String, String> environmentOverrides) { |
| 344 String executable = suite.dartVmBinaryFileName; | 342 String executable = suite.dartVmBinaryFileName; |
| 345 return selfCheckers | 343 return selfCheckers |
| 346 .map((String tester) => commandBuilder.getVmBatchCommand( | 344 .map((String tester) => commandBuilder.getVmBatchCommand( |
| 347 executable, tester, arguments, environmentOverrides, | 345 executable, tester, arguments, environmentOverrides, |
| 348 checked: suite.configuration.isChecked)) | 346 checked: suite.configuration['checked'] as bool)) |
| 349 .toList(); | 347 .toList(); |
| 350 } | 348 } |
| 351 | 349 |
| 352 @override | 350 @override |
| 353 bool get shouldSkipNegativeTests => true; | 351 bool get shouldSkipNegativeTests => true; |
| 354 } | 352 } |
| 355 | 353 |
| 356 /// Temporary runtime configuration for browser runtimes that haven't been | 354 /// Temporary runtime configuration for browser runtimes that haven't been |
| 357 /// migrated yet. | 355 /// migrated yet. |
| 358 // TODO(ahe): Remove this class. | 356 // TODO(ahe): Remove this class. |
| 359 class DummyRuntimeConfiguration extends DartVmRuntimeConfiguration { | 357 class DummyRuntimeConfiguration extends DartVmRuntimeConfiguration { |
| 360 List<Command> computeRuntimeCommands( | 358 List<Command> computeRuntimeCommands( |
| 361 TestSuite suite, | 359 TestSuite suite, |
| 362 CommandBuilder commandBuilder, | 360 CommandBuilder commandBuilder, |
| 363 CommandArtifact artifact, | 361 CommandArtifact artifact, |
| 364 List<String> arguments, | 362 List<String> arguments, |
| 365 Map<String, String> environmentOverrides) { | 363 Map<String, String> environmentOverrides) { |
| 366 throw "Unimplemented runtime '$runtimeType'"; | 364 throw "Unimplemented runtime '$runtimeType'"; |
| 367 } | 365 } |
| 368 } | 366 } |
| OLD | NEW |