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

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

Issue 1859973002: Autoformat tools/testing/dart (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Format whole directory Created 4 years, 8 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/record_and_replay.dart ('k') | tools/testing/dart/status_expression.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 library runtime_configuration; 5 library runtime_configuration;
6 6
7 import 'compiler_configuration.dart' show 7 import 'compiler_configuration.dart' show CommandArtifact;
8 CommandArtifact;
9 8
10 // 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
11 // from TestSuite once the refactoring is complete. 10 // from TestSuite once the refactoring is complete.
12 import 'test_suite.dart' show 11 import 'test_suite.dart' show TestSuite;
13 TestSuite;
14 12
15 import 'test_runner.dart' show 13 import 'test_runner.dart' show Command, CommandBuilder;
16 Command,
17 CommandBuilder;
18 14
19 // TODO(ahe): I expect this class will become abstract very soon. 15 // TODO(ahe): I expect this class will become abstract very soon.
20 class RuntimeConfiguration { 16 class RuntimeConfiguration {
21 // TODO(ahe): Remove this constructor and move the switch to 17 // TODO(ahe): Remove this constructor and move the switch to
22 // test_options.dart. We probably want to store an instance of 18 // test_options.dart. We probably want to store an instance of
23 // [RuntimeConfiguration] in [configuration] there. 19 // [RuntimeConfiguration] in [configuration] there.
24 factory RuntimeConfiguration(Map configuration) { 20 factory RuntimeConfiguration(Map configuration) {
25 String runtime = configuration['runtime']; 21 String runtime = configuration['runtime'];
26 switch (runtime) { 22 switch (runtime) {
27 case 'ContentShellOnAndroid': 23 case 'ContentShellOnAndroid':
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 case 'drt': 57 case 'drt':
62 return new DrtRuntimeConfiguration(); 58 return new DrtRuntimeConfiguration();
63 59
64 default: 60 default:
65 throw "Unknown runtime '$runtime'"; 61 throw "Unknown runtime '$runtime'";
66 } 62 }
67 } 63 }
68 64
69 RuntimeConfiguration._subclass(); 65 RuntimeConfiguration._subclass();
70 66
71 int computeTimeoutMultiplier({ 67 int computeTimeoutMultiplier(
72 String mode, 68 {String mode, bool isChecked: false, String arch}) {
73 bool isChecked: false,
74 String arch}) {
75 return 1; 69 return 1;
76 } 70 }
77 71
78 List<Command> computeRuntimeCommands( 72 List<Command> computeRuntimeCommands(
79 TestSuite suite, 73 TestSuite suite,
80 CommandBuilder commandBuilder, 74 CommandBuilder commandBuilder,
81 CommandArtifact artifact, 75 CommandArtifact artifact,
82 List<String> arguments, 76 List<String> arguments,
83 Map<String, String> environmentOverrides) { 77 Map<String, String> environmentOverrides) {
84 // TODO(ahe): Make this method abstract. 78 // TODO(ahe): Make this method abstract.
85 throw "Unimplemented runtime '$runtimeType'"; 79 throw "Unimplemented runtime '$runtimeType'";
86 } 80 }
87 81
88 List<String> dart2jsPreambles(Uri preambleDir) => []; 82 List<String> dart2jsPreambles(Uri preambleDir) => [];
89 } 83 }
90 84
91 /// The 'none' runtime configuration. 85 /// The 'none' runtime configuration.
92 class NoneRuntimeConfiguration extends RuntimeConfiguration { 86 class NoneRuntimeConfiguration extends RuntimeConfiguration {
93 NoneRuntimeConfiguration() 87 NoneRuntimeConfiguration() : super._subclass();
94 : super._subclass();
95 88
96 List<Command> computeRuntimeCommands( 89 List<Command> computeRuntimeCommands(
97 TestSuite suite, 90 TestSuite suite,
98 CommandBuilder commandBuilder, 91 CommandBuilder commandBuilder,
99 CommandArtifact artifact, 92 CommandArtifact artifact,
100 List<String> arguments, 93 List<String> arguments,
101 Map<String, String> environmentOverrides) { 94 Map<String, String> environmentOverrides) {
102 return <Command>[]; 95 return <Command>[];
103 } 96 }
104 } 97 }
105 98
106 class CommandLineJavaScriptRuntime extends RuntimeConfiguration { 99 class CommandLineJavaScriptRuntime extends RuntimeConfiguration {
107 final String moniker; 100 final String moniker;
108 101
109 CommandLineJavaScriptRuntime(this.moniker) 102 CommandLineJavaScriptRuntime(this.moniker) : super._subclass();
110 : super._subclass();
111 103
112 void checkArtifact(CommandArtifact artifact) { 104 void checkArtifact(CommandArtifact artifact) {
113 String type = artifact.mimeType; 105 String type = artifact.mimeType;
114 if (type != 'application/javascript') { 106 if (type != 'application/javascript') {
115 throw "Runtime '$moniker' cannot run files of type '$type'."; 107 throw "Runtime '$moniker' cannot run files of type '$type'.";
116 } 108 }
117 } 109 }
118 } 110 }
119 111
120 /// Chrome/V8-based development shell (d8). 112 /// Chrome/V8-based development shell (d8).
121 class D8RuntimeConfiguration extends CommandLineJavaScriptRuntime { 113 class D8RuntimeConfiguration extends CommandLineJavaScriptRuntime {
122 D8RuntimeConfiguration() 114 D8RuntimeConfiguration() : super('d8');
123 : super('d8');
124 115
125 List<Command> computeRuntimeCommands( 116 List<Command> computeRuntimeCommands(
126 TestSuite suite, 117 TestSuite suite,
127 CommandBuilder commandBuilder, 118 CommandBuilder commandBuilder,
128 CommandArtifact artifact, 119 CommandArtifact artifact,
129 List<String> arguments, 120 List<String> arguments,
130 Map<String, String> environmentOverrides) { 121 Map<String, String> environmentOverrides) {
131 // TODO(ahe): Avoid duplication of this method between d8 and jsshell. 122 // TODO(ahe): Avoid duplication of this method between d8 and jsshell.
132 checkArtifact(artifact); 123 checkArtifact(artifact);
133 return <Command>[ 124 return <Command>[
134 commandBuilder.getJSCommandlineCommand( 125 commandBuilder.getJSCommandlineCommand(
135 moniker, suite.d8FileName, arguments, environmentOverrides)]; 126 moniker, suite.d8FileName, arguments, environmentOverrides)
127 ];
136 } 128 }
137 129
138 List<String> dart2jsPreambles(Uri preambleDir) { 130 List<String> dart2jsPreambles(Uri preambleDir) {
139 return [preambleDir.resolve('d8.js').toFilePath()]; 131 return [preambleDir.resolve('d8.js').toFilePath()];
140 } 132 }
141 } 133 }
142 134
143 /// Firefox/SpiderMonkey-based development shell (jsshell). 135 /// Firefox/SpiderMonkey-based development shell (jsshell).
144 class JsshellRuntimeConfiguration extends CommandLineJavaScriptRuntime { 136 class JsshellRuntimeConfiguration extends CommandLineJavaScriptRuntime {
145 JsshellRuntimeConfiguration() 137 JsshellRuntimeConfiguration() : super('jsshell');
146 : super('jsshell');
147 138
148 List<Command> computeRuntimeCommands( 139 List<Command> computeRuntimeCommands(
149 TestSuite suite, 140 TestSuite suite,
150 CommandBuilder commandBuilder, 141 CommandBuilder commandBuilder,
151 CommandArtifact artifact, 142 CommandArtifact artifact,
152 List<String> arguments, 143 List<String> arguments,
153 Map<String, String> environmentOverrides) { 144 Map<String, String> environmentOverrides) {
154 checkArtifact(artifact); 145 checkArtifact(artifact);
155 return <Command>[ 146 return <Command>[
156 commandBuilder.getJSCommandlineCommand( 147 commandBuilder.getJSCommandlineCommand(
157 moniker, suite.jsShellFileName, arguments, environmentOverrides)]; 148 moniker, suite.jsShellFileName, arguments, environmentOverrides)
149 ];
158 } 150 }
159 151
160 List<String> dart2jsPreambles(Uri preambleDir) { 152 List<String> dart2jsPreambles(Uri preambleDir) {
161 return ['-f', preambleDir.resolve('jsshell.js').toFilePath(), '-f']; 153 return ['-f', preambleDir.resolve('jsshell.js').toFilePath(), '-f'];
162 } 154 }
163 } 155 }
164 156
165 /// Common runtime configuration for runtimes based on the Dart VM. 157 /// Common runtime configuration for runtimes based on the Dart VM.
166 class DartVmRuntimeConfiguration extends RuntimeConfiguration { 158 class DartVmRuntimeConfiguration extends RuntimeConfiguration {
167 DartVmRuntimeConfiguration() 159 DartVmRuntimeConfiguration() : super._subclass();
168 : super._subclass();
169 160
170 int computeTimeoutMultiplier({ 161 int computeTimeoutMultiplier(
171 String mode, 162 {String mode, bool isChecked: false, String arch}) {
172 bool isChecked: false,
173 String arch}) {
174 int multiplier = 1; 163 int multiplier = 1;
175 switch (arch) { 164 switch (arch) {
176 case 'simarm': 165 case 'simarm':
177 case 'arm': 166 case 'arm':
178 case 'simarmv6': 167 case 'simarmv6':
179 case 'armv6': 168 case 'armv6':
180 case' simarmv5te': 169 case ' simarmv5te':
181 case 'armv5te': 170 case 'armv5te':
182 case 'simmips': 171 case 'simmips':
183 case 'mips': 172 case 'mips':
184 case 'simarm64': 173 case 'simarm64':
185 multiplier *= 4; 174 multiplier *= 4;
186 break; 175 break;
187 } 176 }
188 if (mode == 'debug') { 177 if (mode == 'debug') {
189 multiplier *= 2; 178 multiplier *= 2;
190 } 179 }
191 return multiplier; 180 return multiplier;
192 } 181 }
193 } 182 }
194 183
195 /// Runtime configuration for Content Shell. We previously used a similar 184 /// Runtime configuration for Content Shell. We previously used a similar
196 /// program named Dump Render Tree, hence the name. 185 /// program named Dump Render Tree, hence the name.
197 class DrtRuntimeConfiguration extends DartVmRuntimeConfiguration { 186 class DrtRuntimeConfiguration extends DartVmRuntimeConfiguration {
198 int computeTimeoutMultiplier({ 187 int computeTimeoutMultiplier(
199 String mode, 188 {String mode, bool isChecked: false, String arch}) {
200 bool isChecked: false,
201 String arch}) {
202 return 4 // Allow additional time for browser testing to run. 189 return 4 // Allow additional time for browser testing to run.
203 // TODO(ahe): We might need to distinquish between DRT for running 190 // TODO(ahe): We might need to distinquish between DRT for running
204 // JavaScript and Dart code. I'm not convinced the inherited timeout 191 // JavaScript and Dart code. I'm not convinced the inherited timeout
205 // multiplier is relevant for JavaScript. 192 // multiplier is relevant for JavaScript.
206 * super.computeTimeoutMultiplier( 193 *
207 mode: mode, isChecked: isChecked); 194 super.computeTimeoutMultiplier(mode: mode, isChecked: isChecked);
208 } 195 }
209 } 196 }
210 197
211 /// The standalone Dart VM binary, "dart" or "dart.exe". 198 /// The standalone Dart VM binary, "dart" or "dart.exe".
212 class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration { 199 class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration {
213 List<Command> computeRuntimeCommands( 200 List<Command> computeRuntimeCommands(
214 TestSuite suite, 201 TestSuite suite,
215 CommandBuilder commandBuilder, 202 CommandBuilder commandBuilder,
216 CommandArtifact artifact, 203 CommandArtifact artifact,
217 List<String> arguments, 204 List<String> arguments,
218 Map<String, String> environmentOverrides) { 205 Map<String, String> environmentOverrides) {
219 String script = artifact.filename; 206 String script = artifact.filename;
220 String type = artifact.mimeType; 207 String type = artifact.mimeType;
221 if (script != null && type != 'application/dart') { 208 if (script != null && type != 'application/dart') {
222 throw "Dart VM cannot run files of type '$type'."; 209 throw "Dart VM cannot run files of type '$type'.";
223 } 210 }
224 String executable = suite.configuration['noopt'] 211 String executable = suite.configuration['noopt']
225 ? suite.dartVmNooptBinaryFileName 212 ? suite.dartVmNooptBinaryFileName
226 : suite.dartVmBinaryFileName; 213 : suite.dartVmBinaryFileName;
227 return <Command>[commandBuilder.getVmCommand( 214 return <Command>[
228 executable, arguments, environmentOverrides)]; 215 commandBuilder.getVmCommand(executable, arguments, environmentOverrides)
216 ];
229 } 217 }
230 } 218 }
231 219
232 class DartProductRuntimeConfiguration extends DartVmRuntimeConfiguration { 220 class DartProductRuntimeConfiguration extends DartVmRuntimeConfiguration {
233 List<Command> computeRuntimeCommands( 221 List<Command> computeRuntimeCommands(
234 TestSuite suite, 222 TestSuite suite,
235 CommandBuilder commandBuilder, 223 CommandBuilder commandBuilder,
236 CommandArtifact artifact, 224 CommandArtifact artifact,
237 List<String> arguments, 225 List<String> arguments,
238 Map<String, String> environmentOverrides) { 226 Map<String, String> environmentOverrides) {
239 String script = artifact.filename; 227 String script = artifact.filename;
240 String type = artifact.mimeType; 228 String type = artifact.mimeType;
241 if (script != null && type != 'application/dart-snapshot') { 229 if (script != null && type != 'application/dart-snapshot') {
242 throw "dart_product cannot run files of type '$type'."; 230 throw "dart_product cannot run files of type '$type'.";
243 } 231 }
244 232
245 var augmentedArgs = new List(); 233 var augmentedArgs = new List();
246 augmentedArgs.add("--run-full-snapshot=${artifact.filename}"); 234 augmentedArgs.add("--run-full-snapshot=${artifact.filename}");
247 augmentedArgs.addAll(arguments); 235 augmentedArgs.addAll(arguments);
248 236
249 return <Command>[commandBuilder.getVmCommand( 237 return <Command>[
250 suite.dartVmProductBinaryFileName, 238 commandBuilder.getVmCommand(suite.dartVmProductBinaryFileName,
251 augmentedArgs, 239 augmentedArgs, environmentOverrides)
252 environmentOverrides)]; 240 ];
253 } 241 }
254 } 242 }
255 243
256 class DartPrecompiledRuntimeConfiguration extends DartVmRuntimeConfiguration { 244 class DartPrecompiledRuntimeConfiguration extends DartVmRuntimeConfiguration {
257 List<Command> computeRuntimeCommands( 245 List<Command> computeRuntimeCommands(
258 TestSuite suite, 246 TestSuite suite,
259 CommandBuilder commandBuilder, 247 CommandBuilder commandBuilder,
260 CommandArtifact artifact, 248 CommandArtifact artifact,
261 List<String> arguments, 249 List<String> arguments,
262 Map<String, String> environmentOverrides) { 250 Map<String, String> environmentOverrides) {
263 String script = artifact.filename; 251 String script = artifact.filename;
264 String type = artifact.mimeType; 252 String type = artifact.mimeType;
265 if (script != null && type != 'application/dart-precompiled') { 253 if (script != null && type != 'application/dart-precompiled') {
266 throw "dart_precompiled cannot run files of type '$type'."; 254 throw "dart_precompiled cannot run files of type '$type'.";
267 } 255 }
268 256
269 var augmentedArgs = new List(); 257 var augmentedArgs = new List();
270 augmentedArgs.add("--run-precompiled-snapshot=${artifact.filename}"); 258 augmentedArgs.add("--run-precompiled-snapshot=${artifact.filename}");
271 augmentedArgs.addAll(arguments); 259 augmentedArgs.addAll(arguments);
272 260
273 return <Command>[commandBuilder.getVmCommand( 261 return <Command>[
274 suite.dartPrecompiledBinaryFileName, 262 commandBuilder.getVmCommand(suite.dartPrecompiledBinaryFileName,
275 augmentedArgs, 263 augmentedArgs, environmentOverrides)
276 environmentOverrides)]; 264 ];
277 } 265 }
278 } 266 }
279 267
280 /// Temporary runtime configuration for browser runtimes that haven't been 268 /// Temporary runtime configuration for browser runtimes that haven't been
281 /// migrated yet. 269 /// migrated yet.
282 // TODO(ahe): Remove this class. 270 // TODO(ahe): Remove this class.
283 class DummyRuntimeConfiguration extends DartVmRuntimeConfiguration { 271 class DummyRuntimeConfiguration extends DartVmRuntimeConfiguration {
284 List<Command> computeRuntimeCommands( 272 List<Command> computeRuntimeCommands(
285 TestSuite suite, 273 TestSuite suite,
286 CommandBuilder commandBuilder, 274 CommandBuilder commandBuilder,
287 CommandArtifact artifact, 275 CommandArtifact artifact,
288 List<String> arguments, 276 List<String> arguments,
289 Map<String, String> environmentOverrides) { 277 Map<String, String> environmentOverrides) {
290 throw "Unimplemented runtime '$runtimeType'"; 278 throw "Unimplemented runtime '$runtimeType'";
291 } 279 }
292 } 280 }
OLDNEW
« no previous file with comments | « tools/testing/dart/record_and_replay.dart ('k') | tools/testing/dart/status_expression.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698