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

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

Issue 2933973002: Simplify Command classes. (Closed)
Patch Set: Rename class. 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
« no previous file with comments | « tools/testing/dart/compiler_configuration.dart ('k') | tools/testing/dart/test_progress.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'dart:io'; 5 import 'dart:io';
6 6
7 import 'command.dart';
7 import 'compiler_configuration.dart'; 8 import 'compiler_configuration.dart';
8 import 'configuration.dart'; 9 import 'configuration.dart';
9 // TODO(ahe): Remove this import, we can precompute all the values required 10 // TODO(ahe): Remove this import, we can precompute all the values required
10 // from TestSuite once the refactoring is complete. 11 // from TestSuite once the refactoring is complete.
11 import 'test_suite.dart'; 12 import 'test_suite.dart';
12 import 'test_runner.dart';
13 import 'utils.dart'; 13 import 'utils.dart';
14 14
15 /// Describes the commands to run a given test case or its compiled output. 15 /// Describes the commands to run a given test case or its compiled output.
16 /// 16 ///
17 /// A single runtime configuration object exists per test suite, and is thus 17 /// A single runtime configuration object exists per test suite, and is thus
18 /// shared between multiple test cases, it should not be mutated after 18 /// shared between multiple test cases, it should not be mutated after
19 /// construction. 19 /// construction.
20 abstract class RuntimeConfiguration { 20 abstract class RuntimeConfiguration {
21 factory RuntimeConfiguration(Configuration configuration) { 21 factory RuntimeConfiguration(Configuration configuration) {
22 switch (configuration.runtime) { 22 switch (configuration.runtime) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 int timeoutMultiplier( 75 int timeoutMultiplier(
76 {Mode mode, 76 {Mode mode,
77 bool isChecked: false, 77 bool isChecked: false,
78 bool isReload: false, 78 bool isReload: false,
79 Architecture arch}) { 79 Architecture arch}) {
80 return 1; 80 return 1;
81 } 81 }
82 82
83 List<Command> computeRuntimeCommands( 83 List<Command> computeRuntimeCommands(
84 TestSuite suite, 84 TestSuite suite,
85 CommandBuilder commandBuilder,
86 CommandArtifact artifact, 85 CommandArtifact artifact,
87 List<String> arguments, 86 List<String> arguments,
88 Map<String, String> environmentOverrides) { 87 Map<String, String> environmentOverrides) {
89 // TODO(ahe): Make this method abstract. 88 // TODO(ahe): Make this method abstract.
90 throw "Unimplemented runtime '$runtimeType'"; 89 throw "Unimplemented runtime '$runtimeType'";
91 } 90 }
92 91
93 List<String> dart2jsPreambles(Uri preambleDir) => []; 92 List<String> dart2jsPreambles(Uri preambleDir) => [];
94 93
95 bool get shouldSkipNegativeTests => false; 94 bool get shouldSkipNegativeTests => false;
96 } 95 }
97 96
98 /// The 'none' runtime configuration. 97 /// The 'none' runtime configuration.
99 class NoneRuntimeConfiguration extends RuntimeConfiguration { 98 class NoneRuntimeConfiguration extends RuntimeConfiguration {
100 NoneRuntimeConfiguration() : super._subclass(); 99 NoneRuntimeConfiguration() : super._subclass();
101 100
102 List<Command> computeRuntimeCommands( 101 List<Command> computeRuntimeCommands(
103 TestSuite suite, 102 TestSuite suite,
104 CommandBuilder commandBuilder,
105 CommandArtifact artifact, 103 CommandArtifact artifact,
106 List<String> arguments, 104 List<String> arguments,
107 Map<String, String> environmentOverrides) { 105 Map<String, String> environmentOverrides) {
108 return <Command>[]; 106 return <Command>[];
109 } 107 }
110 } 108 }
111 109
112 class CommandLineJavaScriptRuntime extends RuntimeConfiguration { 110 class CommandLineJavaScriptRuntime extends RuntimeConfiguration {
113 final String moniker; 111 final String moniker;
114 112
115 CommandLineJavaScriptRuntime(this.moniker) : super._subclass(); 113 CommandLineJavaScriptRuntime(this.moniker) : super._subclass();
116 114
117 void checkArtifact(CommandArtifact artifact) { 115 void checkArtifact(CommandArtifact artifact) {
118 String type = artifact.mimeType; 116 String type = artifact.mimeType;
119 if (type != 'application/javascript') { 117 if (type != 'application/javascript') {
120 throw "Runtime '$moniker' cannot run files of type '$type'."; 118 throw "Runtime '$moniker' cannot run files of type '$type'.";
121 } 119 }
122 } 120 }
123 } 121 }
124 122
125 /// Chrome/V8-based development shell (d8). 123 /// Chrome/V8-based development shell (d8).
126 class D8RuntimeConfiguration extends CommandLineJavaScriptRuntime { 124 class D8RuntimeConfiguration extends CommandLineJavaScriptRuntime {
127 D8RuntimeConfiguration() : super('d8'); 125 D8RuntimeConfiguration() : super('d8');
128 126
129 List<Command> computeRuntimeCommands( 127 List<Command> computeRuntimeCommands(
130 TestSuite suite, 128 TestSuite suite,
131 CommandBuilder commandBuilder,
132 CommandArtifact artifact, 129 CommandArtifact artifact,
133 List<String> arguments, 130 List<String> arguments,
134 Map<String, String> environmentOverrides) { 131 Map<String, String> environmentOverrides) {
135 // TODO(ahe): Avoid duplication of this method between d8 and jsshell. 132 // TODO(ahe): Avoid duplication of this method between d8 and jsshell.
136 checkArtifact(artifact); 133 checkArtifact(artifact);
137 return <Command>[ 134 return [
138 commandBuilder.getJSCommandlineCommand( 135 Command.jsCommandLine(
139 moniker, suite.d8FileName, arguments, environmentOverrides) 136 moniker, suite.d8FileName, arguments, environmentOverrides)
140 ]; 137 ];
141 } 138 }
142 139
143 List<String> dart2jsPreambles(Uri preambleDir) { 140 List<String> dart2jsPreambles(Uri preambleDir) {
144 return [preambleDir.resolve('d8.js').toFilePath()]; 141 return [preambleDir.resolve('d8.js').toFilePath()];
145 } 142 }
146 } 143 }
147 144
148 /// Firefox/SpiderMonkey-based development shell (jsshell). 145 /// Firefox/SpiderMonkey-based development shell (jsshell).
149 class JsshellRuntimeConfiguration extends CommandLineJavaScriptRuntime { 146 class JsshellRuntimeConfiguration extends CommandLineJavaScriptRuntime {
150 JsshellRuntimeConfiguration() : super('jsshell'); 147 JsshellRuntimeConfiguration() : super('jsshell');
151 148
152 List<Command> computeRuntimeCommands( 149 List<Command> computeRuntimeCommands(
153 TestSuite suite, 150 TestSuite suite,
154 CommandBuilder commandBuilder,
155 CommandArtifact artifact, 151 CommandArtifact artifact,
156 List<String> arguments, 152 List<String> arguments,
157 Map<String, String> environmentOverrides) { 153 Map<String, String> environmentOverrides) {
158 checkArtifact(artifact); 154 checkArtifact(artifact);
159 return <Command>[ 155 return [
160 commandBuilder.getJSCommandlineCommand( 156 Command.jsCommandLine(
161 moniker, suite.jsShellFileName, arguments, environmentOverrides) 157 moniker, suite.jsShellFileName, arguments, environmentOverrides)
162 ]; 158 ];
163 } 159 }
164 160
165 List<String> dart2jsPreambles(Uri preambleDir) { 161 List<String> dart2jsPreambles(Uri preambleDir) {
166 return ['-f', preambleDir.resolve('jsshell.js').toFilePath(), '-f']; 162 return ['-f', preambleDir.resolve('jsshell.js').toFilePath(), '-f'];
167 } 163 }
168 } 164 }
169 165
170 /// Common runtime configuration for runtimes based on the Dart VM. 166 /// Common runtime configuration for runtimes based on the Dart VM.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 * 215 *
220 super.timeoutMultiplier( 216 super.timeoutMultiplier(
221 mode: mode, isChecked: isChecked, isReload: isReload); 217 mode: mode, isChecked: isChecked, isReload: isReload);
222 } 218 }
223 } 219 }
224 220
225 /// The standalone Dart VM binary, "dart" or "dart.exe". 221 /// The standalone Dart VM binary, "dart" or "dart.exe".
226 class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration { 222 class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration {
227 List<Command> computeRuntimeCommands( 223 List<Command> computeRuntimeCommands(
228 TestSuite suite, 224 TestSuite suite,
229 CommandBuilder commandBuilder,
230 CommandArtifact artifact, 225 CommandArtifact artifact,
231 List<String> arguments, 226 List<String> arguments,
232 Map<String, String> environmentOverrides) { 227 Map<String, String> environmentOverrides) {
233 String script = artifact.filename; 228 String script = artifact.filename;
234 String type = artifact.mimeType; 229 String type = artifact.mimeType;
235 if (script != null && 230 if (script != null &&
236 type != 'application/dart' && 231 type != 'application/dart' &&
237 type != 'application/dart-snapshot') { 232 type != 'application/dart-snapshot') {
238 throw "Dart VM cannot run files of type '$type'."; 233 throw "Dart VM cannot run files of type '$type'.";
239 } 234 }
240 String executable = suite.dartVmBinaryFileName; 235 String executable = suite.dartVmBinaryFileName;
241 return <Command>[ 236 return [Command.vm(executable, arguments, environmentOverrides)];
242 commandBuilder.getVmCommand(executable, arguments, environmentOverrides)
243 ];
244 } 237 }
245 } 238 }
246 239
247 /// The flutter engine binary, "sky_shell". 240 /// The flutter engine binary, "sky_shell".
248 class StandaloneFlutterEngineConfiguration extends DartVmRuntimeConfiguration { 241 class StandaloneFlutterEngineConfiguration extends DartVmRuntimeConfiguration {
249 List<Command> computeRuntimeCommands( 242 List<Command> computeRuntimeCommands(
250 TestSuite suite, 243 TestSuite suite,
251 CommandBuilder commandBuilder,
252 CommandArtifact artifact, 244 CommandArtifact artifact,
253 List<String> arguments, 245 List<String> arguments,
254 Map<String, String> environmentOverrides) { 246 Map<String, String> environmentOverrides) {
255 String script = artifact.filename; 247 String script = artifact.filename;
256 String type = artifact.mimeType; 248 String type = artifact.mimeType;
257 if (script != null && 249 if (script != null &&
258 type != 'application/dart' && 250 type != 'application/dart' &&
259 type != 'application/dart-snapshot') { 251 type != 'application/dart-snapshot') {
260 throw "Flutter Engine cannot run files of type '$type'."; 252 throw "Flutter Engine cannot run files of type '$type'.";
261 } 253 }
262 String executable = suite.flutterEngineBinaryFileName; 254 String executable = suite.flutterEngineBinaryFileName;
263 var args = <String>['--non-interactive']..addAll(arguments); 255 var args = <String>['--non-interactive']..addAll(arguments);
264 return <Command>[ 256 return [Command.vm(executable, args, environmentOverrides)];
265 commandBuilder.getVmCommand(executable, args, environmentOverrides)
266 ];
267 } 257 }
268 } 258 }
269 259
270 class DartPrecompiledRuntimeConfiguration extends DartVmRuntimeConfiguration { 260 class DartPrecompiledRuntimeConfiguration extends DartVmRuntimeConfiguration {
271 final bool useBlobs; 261 final bool useBlobs;
272 DartPrecompiledRuntimeConfiguration({bool useBlobs}) : useBlobs = useBlobs; 262 DartPrecompiledRuntimeConfiguration({bool useBlobs}) : useBlobs = useBlobs;
273 263
274 List<Command> computeRuntimeCommands( 264 List<Command> computeRuntimeCommands(
275 TestSuite suite, 265 TestSuite suite,
276 CommandBuilder commandBuilder,
277 CommandArtifact artifact, 266 CommandArtifact artifact,
278 List<String> arguments, 267 List<String> arguments,
279 Map<String, String> environmentOverrides) { 268 Map<String, String> environmentOverrides) {
280 String script = artifact.filename; 269 String script = artifact.filename;
281 String type = artifact.mimeType; 270 String type = artifact.mimeType;
282 if (script != null && type != 'application/dart-precompiled') { 271 if (script != null && type != 'application/dart-precompiled') {
283 throw "dart_precompiled cannot run files of type '$type'."; 272 throw "dart_precompiled cannot run files of type '$type'.";
284 } 273 }
285 274
286 return <Command>[ 275 return [
287 commandBuilder.getVmCommand( 276 Command.vm(
288 suite.dartPrecompiledBinaryFileName, arguments, environmentOverrides) 277 suite.dartPrecompiledBinaryFileName, arguments, environmentOverrides)
289 ]; 278 ];
290 } 279 }
291 } 280 }
292 281
293 class DartPrecompiledAdbRuntimeConfiguration 282 class DartPrecompiledAdbRuntimeConfiguration
294 extends DartVmRuntimeConfiguration { 283 extends DartVmRuntimeConfiguration {
295 static const String DeviceDir = '/data/local/tmp/precompilation-testing'; 284 static const String DeviceDir = '/data/local/tmp/precompilation-testing';
296 static const String DeviceTestDir = 285 static const String DeviceTestDir =
297 '/data/local/tmp/precompilation-testing/test'; 286 '/data/local/tmp/precompilation-testing/test';
298 287
299 final bool useBlobs; 288 final bool useBlobs;
300 DartPrecompiledAdbRuntimeConfiguration({bool useBlobs}) : useBlobs = useBlobs; 289 DartPrecompiledAdbRuntimeConfiguration({bool useBlobs}) : useBlobs = useBlobs;
301 290
302 List<Command> computeRuntimeCommands( 291 List<Command> computeRuntimeCommands(
303 TestSuite suite, 292 TestSuite suite,
304 CommandBuilder commandBuilder,
305 CommandArtifact artifact, 293 CommandArtifact artifact,
306 List<String> arguments, 294 List<String> arguments,
307 Map<String, String> environmentOverrides) { 295 Map<String, String> environmentOverrides) {
308 String script = artifact.filename; 296 String script = artifact.filename;
309 String type = artifact.mimeType; 297 String type = artifact.mimeType;
310 if (script != null && type != 'application/dart-precompiled') { 298 if (script != null && type != 'application/dart-precompiled') {
311 throw "dart_precompiled cannot run files of type '$type'."; 299 throw "dart_precompiled cannot run files of type '$type'.";
312 } 300 }
313 301
314 String precompiledRunner = suite.dartPrecompiledBinaryFileName; 302 String precompiledRunner = suite.dartPrecompiledBinaryFileName;
315 String processTest = suite.processTestBinaryFileName; 303 String processTest = suite.processTestBinaryFileName;
316 return <Command>[ 304 return [
317 commandBuilder.getAdbPrecompiledCommand( 305 Command.adbPrecompiled(
318 precompiledRunner, processTest, script, arguments, useBlobs) 306 precompiledRunner, processTest, script, arguments, useBlobs)
319 ]; 307 ];
320 } 308 }
321 } 309 }
322 310
323 class SelfCheckRuntimeConfiguration extends DartVmRuntimeConfiguration { 311 class SelfCheckRuntimeConfiguration extends DartVmRuntimeConfiguration {
324 final List<String> selfCheckers = <String>[]; 312 final List<String> selfCheckers = <String>[];
325 313
326 SelfCheckRuntimeConfiguration() { 314 SelfCheckRuntimeConfiguration() {
327 searchForSelfCheckers(); 315 searchForSelfCheckers();
328 } 316 }
329 317
330 void searchForSelfCheckers() { 318 void searchForSelfCheckers() {
331 Uri pkg = TestUtils.dartDirUri.resolve('pkg'); 319 Uri pkg = TestUtils.dartDirUri.resolve('pkg');
332 for (var entry in new Directory.fromUri(pkg).listSync(recursive: true)) { 320 for (var entry in new Directory.fromUri(pkg).listSync(recursive: true)) {
333 if (entry is File && entry.path.endsWith('_self_check.dart')) { 321 if (entry is File && entry.path.endsWith('_self_check.dart')) {
334 selfCheckers.add(entry.path); 322 selfCheckers.add(entry.path);
335 } 323 }
336 } 324 }
337 } 325 }
338 326
339 List<Command> computeRuntimeCommands( 327 List<Command> computeRuntimeCommands(
340 TestSuite suite, 328 TestSuite suite,
341 CommandBuilder commandBuilder,
342 CommandArtifact artifact, 329 CommandArtifact artifact,
343 List<String> arguments, 330 List<String> arguments,
344 Map<String, String> environmentOverrides) { 331 Map<String, String> environmentOverrides) {
345 String executable = suite.dartVmBinaryFileName; 332 String executable = suite.dartVmBinaryFileName;
346 return selfCheckers 333 return selfCheckers
347 .map((String tester) => commandBuilder.getVmBatchCommand( 334 .map((String tester) => Command.vmBatch(
348 executable, tester, arguments, environmentOverrides, 335 executable, tester, arguments, environmentOverrides,
349 checked: suite.configuration.isChecked)) 336 checked: suite.configuration.isChecked))
350 .toList(); 337 .toList();
351 } 338 }
352 339
353 @override 340 @override
354 bool get shouldSkipNegativeTests => true; 341 bool get shouldSkipNegativeTests => true;
355 } 342 }
356 343
357 /// Temporary runtime configuration for browser runtimes that haven't been 344 /// Temporary runtime configuration for browser runtimes that haven't been
358 /// migrated yet. 345 /// migrated yet.
359 // TODO(ahe): Remove this class. 346 // TODO(ahe): Remove this class.
360 class DummyRuntimeConfiguration extends DartVmRuntimeConfiguration { 347 class DummyRuntimeConfiguration extends DartVmRuntimeConfiguration {
361 List<Command> computeRuntimeCommands( 348 List<Command> computeRuntimeCommands(
362 TestSuite suite, 349 TestSuite suite,
363 CommandBuilder commandBuilder,
364 CommandArtifact artifact, 350 CommandArtifact artifact,
365 List<String> arguments, 351 List<String> arguments,
366 Map<String, String> environmentOverrides) { 352 Map<String, String> environmentOverrides) {
367 throw "Unimplemented runtime '$runtimeType'"; 353 throw "Unimplemented runtime '$runtimeType'";
368 } 354 }
369 } 355 }
OLDNEW
« no previous file with comments | « tools/testing/dart/compiler_configuration.dart ('k') | tools/testing/dart/test_progress.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698