Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: tools/testing/dart/runtime_configuration.dart

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

Powered by Google App Engine
This is Rietveld 408576698