Chromium Code Reviews| 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 import 'dart:io'; |
| 6 | 6 |
| 7 import 'dart:io' show Directory, File; | 7 import 'compiler_configuration.dart'; |
| 8 | 8 import 'configuration.dart'; |
| 9 import 'compiler_configuration.dart' show CommandArtifact; | |
| 10 | |
| 11 // TODO(ahe): Remove this import, we can precompute all the values required | 9 // TODO(ahe): Remove this import, we can precompute all the values required |
| 12 // from TestSuite once the refactoring is complete. | 10 // from TestSuite once the refactoring is complete. |
| 13 import 'test_suite.dart' show TestSuite, TestUtils; | 11 import 'test_suite.dart'; |
| 14 | 12 import 'test_runner.dart'; |
| 15 import 'test_runner.dart' show Command, CommandBuilder; | |
| 16 | 13 |
| 17 /// Describes the commands to run a given test case or its compiled output. | 14 /// Describes the commands to run a given test case or its compiled output. |
| 18 /// | 15 /// |
| 19 /// A single runtime configuration object exists per test suite, and is thus | 16 /// A single runtime configuration object exists per test suite, and is thus |
| 20 /// shared between multiple test cases, it should not be mutated after | 17 /// shared between multiple test cases, it should not be mutated after |
| 21 /// construction. | 18 /// construction. |
| 22 // | 19 abstract class RuntimeConfiguration { |
| 23 // TODO(ahe): I expect this class will become abstract very soon. | |
| 24 class RuntimeConfiguration { | |
| 25 // TODO(ahe): Remove this constructor and move the switch to | |
|
Bill Hesse
2017/05/29 13:08:28
I agree this could be made a static method, not a
Bob Nystrom
2017/05/30 23:29:31
Moved it back.
| |
| 26 // test_options.dart. We probably want to store an instance of | |
| 27 // [RuntimeConfiguration] in [configuration] there. | |
| 28 factory RuntimeConfiguration(Map<String, dynamic> configuration) { | |
| 29 var runtime = configuration['runtime'] as String; | |
| 30 var useBlobs = configuration['use_blobs'] as bool; | |
| 31 | |
| 32 switch (runtime) { | |
| 33 case 'ContentShellOnAndroid': | |
| 34 case 'DartiumOnAndroid': | |
| 35 case 'chrome': | |
| 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': | |
| 46 // TODO(ahe): Replace this with one or more browser runtimes. | |
| 47 return new DummyRuntimeConfiguration(); | |
| 48 | |
| 49 case 'jsshell': | |
| 50 return new JsshellRuntimeConfiguration(); | |
| 51 | |
| 52 case 'd8': | |
| 53 return new D8RuntimeConfiguration(); | |
| 54 | |
| 55 case 'none': | |
| 56 return new NoneRuntimeConfiguration(); | |
| 57 | |
| 58 case 'vm': | |
| 59 return new StandaloneDartRuntimeConfiguration(); | |
| 60 | |
| 61 case 'flutter': | |
| 62 return new StandaloneFlutterEngineConfiguration(); | |
| 63 | |
| 64 case 'dart_precompiled': | |
| 65 if (configuration['system'] == 'android') { | |
| 66 return new DartPrecompiledAdbRuntimeConfiguration(useBlobs: useBlobs); | |
| 67 } | |
| 68 return new DartPrecompiledRuntimeConfiguration(useBlobs: useBlobs); | |
| 69 | |
| 70 case 'drt': | |
| 71 return new DrtRuntimeConfiguration(); | |
| 72 | |
| 73 case 'self_check': | |
| 74 return new SelfCheckRuntimeConfiguration(); | |
| 75 | |
| 76 default: | |
| 77 throw "Unknown runtime '$runtime'"; | |
| 78 } | |
| 79 } | |
| 80 | |
| 81 RuntimeConfiguration._subclass(); | 20 RuntimeConfiguration._subclass(); |
| 82 | 21 |
| 83 int computeTimeoutMultiplier( | 22 int timeoutMultiplier( |
| 84 {String mode, bool isChecked: false, bool isReload: false, String arch}) { | 23 {Mode mode, |
| 24 bool isChecked: false, | |
| 25 bool isReload: false, | |
| 26 Architecture arch}) { | |
| 85 return 1; | 27 return 1; |
| 86 } | 28 } |
| 87 | 29 |
| 88 List<Command> computeRuntimeCommands( | 30 List<Command> computeRuntimeCommands( |
| 89 TestSuite suite, | 31 TestSuite suite, |
| 90 CommandBuilder commandBuilder, | 32 CommandBuilder commandBuilder, |
| 91 CommandArtifact artifact, | 33 CommandArtifact artifact, |
| 92 List<String> arguments, | 34 List<String> arguments, |
| 93 Map<String, String> environmentOverrides) { | 35 Map<String, String> environmentOverrides) { |
| 94 // TODO(ahe): Make this method abstract. | 36 // TODO(ahe): Make this method abstract. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 | 111 |
| 170 List<String> dart2jsPreambles(Uri preambleDir) { | 112 List<String> dart2jsPreambles(Uri preambleDir) { |
| 171 return ['-f', preambleDir.resolve('jsshell.js').toFilePath(), '-f']; | 113 return ['-f', preambleDir.resolve('jsshell.js').toFilePath(), '-f']; |
| 172 } | 114 } |
| 173 } | 115 } |
| 174 | 116 |
| 175 /// Common runtime configuration for runtimes based on the Dart VM. | 117 /// Common runtime configuration for runtimes based on the Dart VM. |
| 176 class DartVmRuntimeConfiguration extends RuntimeConfiguration { | 118 class DartVmRuntimeConfiguration extends RuntimeConfiguration { |
| 177 DartVmRuntimeConfiguration() : super._subclass(); | 119 DartVmRuntimeConfiguration() : super._subclass(); |
| 178 | 120 |
| 179 int computeTimeoutMultiplier( | 121 int timeoutMultiplier( |
| 180 {String mode, bool isChecked: false, bool isReload: false, String arch}) { | 122 {Mode mode, |
| 181 int multiplier = 1; | 123 bool isChecked: false, |
| 124 bool isReload: false, | |
| 125 Architecture arch}) { | |
| 126 var multiplier = 1; | |
| 127 | |
| 182 switch (arch) { | 128 switch (arch) { |
| 183 case 'simarm': | 129 case Architecture.simarm: |
| 184 case 'arm': | 130 case Architecture.arm: |
| 185 case 'simarmv6': | 131 case Architecture.simarmv6: |
| 186 case 'armv6': | 132 case Architecture.armv6: |
| 187 case ' simarmv5te': | 133 case Architecture.simarmv5te: |
| 188 case 'armv5te': | 134 case Architecture.armv5te: |
| 189 case 'simmips': | 135 case Architecture.simmips: |
| 190 case 'mips': | 136 case Architecture.mips: |
| 191 case 'simarm64': | 137 case Architecture.simarm64: |
| 192 case 'simdbc': | 138 case Architecture.simdbc: |
| 193 case 'simdbc64': | 139 case Architecture.simdbc64: |
| 194 multiplier *= 4; | 140 multiplier *= 4; |
| 195 break; | 141 break; |
| 196 } | 142 } |
| 197 if (mode == 'debug') { | 143 |
| 144 if (mode.isDebug) { | |
| 198 multiplier *= 2; | 145 multiplier *= 2; |
| 199 if (isReload) { | 146 if (isReload) { |
| 200 multiplier *= 2; | 147 multiplier *= 2; |
| 201 } | 148 } |
| 202 } | 149 } |
| 203 return multiplier; | 150 return multiplier; |
| 204 } | 151 } |
| 205 } | 152 } |
| 206 | 153 |
| 207 /// Runtime configuration for Content Shell. We previously used a similar | 154 /// Runtime configuration for Content Shell. We previously used a similar |
| 208 /// program named Dump Render Tree, hence the name. | 155 /// program named Dump Render Tree, hence the name. |
| 209 class DrtRuntimeConfiguration extends DartVmRuntimeConfiguration { | 156 class DrtRuntimeConfiguration extends DartVmRuntimeConfiguration { |
| 210 int computeTimeoutMultiplier( | 157 int timeoutMultiplier( |
| 211 {String mode, bool isChecked: false, bool isReload: false, String arch}) { | 158 {Mode mode, |
| 159 bool isChecked: false, | |
| 160 bool isReload: false, | |
| 161 Architecture arch}) { | |
| 212 return 4 // Allow additional time for browser testing to run. | 162 return 4 // Allow additional time for browser testing to run. |
| 213 // TODO(ahe): We might need to distinguish between DRT for running | 163 // TODO(ahe): We might need to distinguish between DRT for running |
| 214 // JavaScript and Dart code. I'm not convinced the inherited timeout | 164 // JavaScript and Dart code. I'm not convinced the inherited timeout |
| 215 // multiplier is relevant for JavaScript. | 165 // multiplier is relevant for JavaScript. |
| 216 * | 166 * |
| 217 super.computeTimeoutMultiplier( | 167 super.timeoutMultiplier( |
| 218 mode: mode, isChecked: isChecked, isReload: isReload); | 168 mode: mode, isChecked: isChecked, isReload: isReload); |
| 219 } | 169 } |
| 220 } | 170 } |
| 221 | 171 |
| 222 /// The standalone Dart VM binary, "dart" or "dart.exe". | 172 /// The standalone Dart VM binary, "dart" or "dart.exe". |
| 223 class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration { | 173 class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration { |
| 224 List<Command> computeRuntimeCommands( | 174 List<Command> computeRuntimeCommands( |
| 225 TestSuite suite, | 175 TestSuite suite, |
| 226 CommandBuilder commandBuilder, | 176 CommandBuilder commandBuilder, |
| 227 CommandArtifact artifact, | 177 CommandArtifact artifact, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 List<Command> computeRuntimeCommands( | 286 List<Command> computeRuntimeCommands( |
| 337 TestSuite suite, | 287 TestSuite suite, |
| 338 CommandBuilder commandBuilder, | 288 CommandBuilder commandBuilder, |
| 339 CommandArtifact artifact, | 289 CommandArtifact artifact, |
| 340 List<String> arguments, | 290 List<String> arguments, |
| 341 Map<String, String> environmentOverrides) { | 291 Map<String, String> environmentOverrides) { |
| 342 String executable = suite.dartVmBinaryFileName; | 292 String executable = suite.dartVmBinaryFileName; |
| 343 return selfCheckers | 293 return selfCheckers |
| 344 .map((String tester) => commandBuilder.getVmBatchCommand( | 294 .map((String tester) => commandBuilder.getVmBatchCommand( |
| 345 executable, tester, arguments, environmentOverrides, | 295 executable, tester, arguments, environmentOverrides, |
| 346 checked: suite.configuration['checked'] as bool)) | 296 checked: suite.configuration.isChecked)) |
| 347 .toList(); | 297 .toList(); |
| 348 } | 298 } |
| 349 | 299 |
| 350 @override | 300 @override |
| 351 bool get shouldSkipNegativeTests => true; | 301 bool get shouldSkipNegativeTests => true; |
| 352 } | 302 } |
| 353 | 303 |
| 354 /// Temporary runtime configuration for browser runtimes that haven't been | 304 /// Temporary runtime configuration for browser runtimes that haven't been |
| 355 /// migrated yet. | 305 /// migrated yet. |
| 356 // TODO(ahe): Remove this class. | 306 // TODO(ahe): Remove this class. |
| 357 class DummyRuntimeConfiguration extends DartVmRuntimeConfiguration { | 307 class DummyRuntimeConfiguration extends DartVmRuntimeConfiguration { |
| 358 List<Command> computeRuntimeCommands( | 308 List<Command> computeRuntimeCommands( |
| 359 TestSuite suite, | 309 TestSuite suite, |
| 360 CommandBuilder commandBuilder, | 310 CommandBuilder commandBuilder, |
| 361 CommandArtifact artifact, | 311 CommandArtifact artifact, |
| 362 List<String> arguments, | 312 List<String> arguments, |
| 363 Map<String, String> environmentOverrides) { | 313 Map<String, String> environmentOverrides) { |
| 364 throw "Unimplemented runtime '$runtimeType'"; | 314 throw "Unimplemented runtime '$runtimeType'"; |
| 365 } | 315 } |
| 366 } | 316 } |
| OLD | NEW |