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

Side by Side Diff: tools/testing/dart/test_options.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/test_configurations.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 test_options_parser; 5 library test_options_parser;
6 6
7 import "dart:io"; 7 import "dart:io";
8 import "drt_updater.dart"; 8 import "drt_updater.dart";
9 import "test_suite.dart"; 9 import "test_suite.dart";
10 import "path.dart"; 10 import "path.dart";
11 import "compiler_configuration.dart" show CompilerConfiguration; 11 import "compiler_configuration.dart" show CompilerConfiguration;
12 import "runtime_configuration.dart" show RuntimeConfiguration; 12 import "runtime_configuration.dart" show RuntimeConfiguration;
13 13
14 const List<String> defaultTestSelectors = 14 const List<String> defaultTestSelectors = const [
15 const ['samples', 'standalone', 'corelib', 'co19', 'language', 15 'samples',
16 'isolate', 'vm', 'html', 'benchmark_smoke', 16 'standalone',
17 'utils', 'lib', 'pkg', 'analyze_library', 'service']; 17 'corelib',
18 'co19',
19 'language',
20 'isolate',
21 'vm',
22 'html',
23 'benchmark_smoke',
24 'utils',
25 'lib',
26 'pkg',
27 'analyze_library',
28 'service'
29 ];
18 30
19 /** 31 /**
20 * Specification of a single test option. 32 * Specification of a single test option.
21 * 33 *
22 * The name of the specification is used as the key for the option in 34 * The name of the specification is used as the key for the option in
23 * the Map returned from the [TestOptionParser] parse method. 35 * the Map returned from the [TestOptionParser] parse method.
24 */ 36 */
25 class _TestOptionSpecification { 37 class _TestOptionSpecification {
26 _TestOptionSpecification(this.name, 38 _TestOptionSpecification(
27 this.description, 39 this.name, this.description, this.keys, this.values, this.defaultValue,
28 this.keys, 40 {this.type: 'string'});
29 this.values,
30 this.defaultValue,
31 {this.type : 'string'});
32 String name; 41 String name;
33 String description; 42 String description;
34 List<String> keys; 43 List<String> keys;
35 List<String> values; 44 List<String> values;
36 var defaultValue; 45 var defaultValue;
37 String type; 46 String type;
38 } 47 }
39 48
40 /** 49 /**
41 * Parser of test options. 50 * Parser of test options.
42 */ 51 */
43 class TestOptionsParser { 52 class TestOptionsParser {
44 /** 53 /**
45 * Creates a test options parser initialized with the known options. 54 * Creates a test options parser initialized with the known options.
46 */ 55 */
47 TestOptionsParser() { 56 TestOptionsParser() {
48 _options = 57 _options = [
49 [ new _TestOptionSpecification( 58 new _TestOptionSpecification('mode', 'Mode in which to run the tests',
50 'mode', 59 ['-m', '--mode'], ['all', 'debug', 'release', 'product'], 'debug'),
51 'Mode in which to run the tests', 60 new _TestOptionSpecification(
52 ['-m', '--mode'], 61 'compiler',
53 ['all', 'debug', 'release', 'product'], 62 '''Specify any compilation step (if needed).
54 'debug'),
55 new _TestOptionSpecification(
56 'compiler',
57 '''Specify any compilation step (if needed).
58 63
59 none: Do not compile the Dart code (run native Dart code on the VM). 64 none: Do not compile the Dart code (run native Dart code on the VM).
60 (only valid with the following runtimes: vm, drt) 65 (only valid with the following runtimes: vm, drt)
61 66
62 dart2js: Compile dart code to JavaScript by running dart2js. 67 dart2js: Compile dart code to JavaScript by running dart2js.
63 (only valid with the following runtimes: d8, drt, chrome, 68 (only valid with the following runtimes: d8, drt, chrome,
64 safari, ie9, ie10, ie11, firefox, opera, chromeOnAndroid, 69 safari, ie9, ie10, ie11, firefox, opera, chromeOnAndroid,
65 none (compile only)), 70 none (compile only)),
66 71
67 dart2analyzer: Perform static analysis on Dart code by running the analyzer 72 dart2analyzer: Perform static analysis on Dart code by running the analyzer
68 (only valid with the following runtimes: none) 73 (only valid with the following runtimes: none)
69 74
70 dart2app: Compile the Dart code into an app snapshot before running the test 75 dart2app: Compile the Dart code into an app snapshot before running the test
71 (only valid with the following runtimes: dart_product)''', 76 (only valid with the following runtimes: dart_product)''',
72 ['-c', '--compiler'], 77 ['-c', '--compiler'],
73 ['none', 'precompiler', 'dart2js', 'dart2analyzer', 78 ['none', 'precompiler', 'dart2js', 'dart2analyzer', 'dart2app'],
74 'dart2app'], 79 'none'),
75 'none'), 80 // TODO(antonm): fix the option drt.
76 // TODO(antonm): fix the option drt. 81 new _TestOptionSpecification(
77 new _TestOptionSpecification( 82 'runtime',
78 'runtime', 83 '''Where the tests should be run.
79 '''Where the tests should be run.
80 vm: Run Dart code on the standalone dart vm. 84 vm: Run Dart code on the standalone dart vm.
81 85
82 dart_precompiled: Run a precompiled snapshot on a variant of the standalone 86 dart_precompiled: Run a precompiled snapshot on a variant of the standalone
83 dart vm lacking a JIT. 87 dart vm lacking a JIT.
84 88
85 dart_product: Run a full app snapshot in product mode. 89 dart_product: Run a full app snapshot in product mode.
86 90
87 d8: Run JavaScript from the command line using v8. 91 d8: Run JavaScript from the command line using v8.
88 92
89 jsshell: Run JavaScript from the command line using firefox js-shell. 93 jsshell: Run JavaScript from the command line using firefox js-shell.
90 94
91 drt: Run Dart or JavaScript in the headless version of Chrome, 95 drt: Run Dart or JavaScript in the headless version of Chrome,
92 Content shell. 96 Content shell.
93 97
94 dartium: Run Dart or JavaScript in Dartium. 98 dartium: Run Dart or JavaScript in Dartium.
95 99
96 ContentShellOnAndroid: Run Dart or JavaScript in Dartium content shell 100 ContentShellOnAndroid: Run Dart or JavaScript in Dartium content shell
97 on Android. 101 on Android.
98 102
99 DartiumOnAndroid: Run Dart or Javascript in Dartium on Android. 103 DartiumOnAndroid: Run Dart or Javascript in Dartium on Android.
100 104
101 [ff | chrome | safari | ie9 | ie10 | ie11 | opera | chromeOnAndroid]: 105 [ff | chrome | safari | ie9 | ie10 | ie11 | opera | chromeOnAndroid]:
102 Run JavaScript in the specified browser. 106 Run JavaScript in the specified browser.
103 107
104 none: No runtime, compile only (for example, used for dart2analyzer static 108 none: No runtime, compile only (for example, used for dart2analyzer static
105 analysis tests).''', 109 analysis tests).''',
106 ['-r', '--runtime'], 110 ['-r', '--runtime'],
107 ['vm', 'dart_precompiled', 'dart_product', 111 [
108 'd8', 'jsshell', 'drt', 'dartium', 112 'vm',
109 'ff', 'firefox', 113 'dart_precompiled',
110 'chrome', 'safari', 'ie9', 'ie10', 'ie11', 'opera', 114 'dart_product',
111 'chromeOnAndroid', 'safarimobilesim', 115 'd8',
112 'ContentShellOnAndroid', 'DartiumOnAndroid', 'none'], 116 'jsshell',
113 'vm'), 117 'drt',
114 new _TestOptionSpecification( 118 'dartium',
115 'arch', 119 'ff',
116 'The architecture to run tests for', 120 'firefox',
117 ['-a', '--arch'], 121 'chrome',
118 ['all', 'ia32', 'x64', 'arm', 'armv6', 'armv5te', 'arm64', 'mips', 122 'safari',
119 'simarm', 'simarmv6', 'simarmv5te', 'simarm64', 'simmips'], 123 'ie9',
120 'x64'), 124 'ie10',
121 new _TestOptionSpecification( 125 'ie11',
122 'system', 126 'opera',
123 'The operating system to run tests on', 127 'chromeOnAndroid',
124 ['-s', '--system'], 128 'safarimobilesim',
125 ['linux', 'macos', 'windows'], 129 'ContentShellOnAndroid',
126 Platform.operatingSystem), 130 'DartiumOnAndroid',
127 new _TestOptionSpecification( 131 'none'
128 'checked', 132 ],
129 'Run tests in checked mode', 133 'vm'),
130 ['--checked'], 134 new _TestOptionSpecification(
131 [], 135 'arch',
132 false, 136 'The architecture to run tests for',
133 type: 'bool'), 137 ['-a', '--arch'],
134 new _TestOptionSpecification( 138 [
135 'host_checked', 139 'all',
136 'Run compiler in checked mode', 140 'ia32',
137 ['--host-checked'], 141 'x64',
138 [], 142 'arm',
139 false, 143 'armv6',
140 type: 'bool'), 144 'armv5te',
141 new _TestOptionSpecification( 145 'arm64',
142 'minified', 146 'mips',
143 'Enable minification in the compiler', 147 'simarm',
144 ['--minified'], 148 'simarmv6',
145 [], 149 'simarmv5te',
146 false, 150 'simarm64',
147 type: 'bool'), 151 'simmips'
148 new _TestOptionSpecification( 152 ],
149 'csp', 153 'x64'),
150 'Run tests under Content Security Policy restrictions', 154 new _TestOptionSpecification(
151 ['--csp'], 155 'system',
152 [], 156 'The operating system to run tests on',
153 false, 157 ['-s', '--system'],
154 type: 'bool'), 158 ['linux', 'macos', 'windows'],
155 new _TestOptionSpecification( 159 Platform.operatingSystem),
156 'cps_ir', 160 new _TestOptionSpecification(
157 'Run the compiler with the cps based backend', 161 'checked', 'Run tests in checked mode', ['--checked'], [], false,
158 ['--cps-ir'], 162 type: 'bool'),
159 [], 163 new _TestOptionSpecification('host_checked',
160 false, 164 'Run compiler in checked mode', ['--host-checked'], [], false,
161 type: 'bool'), 165 type: 'bool'),
162 new _TestOptionSpecification( 166 new _TestOptionSpecification('minified',
163 'noopt', 167 'Enable minification in the compiler', ['--minified'], [], false,
164 'Run an in-place precompilation', 168 type: 'bool'),
165 ['--noopt'], 169 new _TestOptionSpecification(
166 [], 170 'csp',
167 false, 171 'Run tests under Content Security Policy restrictions',
168 type: 'bool'), 172 ['--csp'],
169 new _TestOptionSpecification( 173 [],
170 'timeout', 174 false,
171 'Timeout in seconds', 175 type: 'bool'),
172 ['-t', '--timeout'], 176 new _TestOptionSpecification(
173 [], 177 'cps_ir',
174 -1, 178 'Run the compiler with the cps based backend',
175 type: 'int'), 179 ['--cps-ir'],
176 new _TestOptionSpecification( 180 [],
177 'progress', 181 false,
178 'Progress indication mode', 182 type: 'bool'),
179 ['-p', '--progress'], 183 new _TestOptionSpecification(
180 ['compact', 'color', 'line', 'verbose', 184 'noopt', 'Run an in-place precompilation', ['--noopt'], [], false,
181 'silent', 'status', 'buildbot', 'diff'], 185 type: 'bool'),
182 'compact'), 186 new _TestOptionSpecification(
183 new _TestOptionSpecification( 187 'timeout', 'Timeout in seconds', ['-t', '--timeout'], [], -1,
184 'failure-summary', 188 type: 'int'),
185 'Print failure summary at the end', 189 new _TestOptionSpecification(
186 ['--failure-summary'], 190 'progress',
187 [], 191 'Progress indication mode',
188 false, 192 ['-p', '--progress'],
189 type: 'bool'), 193 [
190 new _TestOptionSpecification( 194 'compact',
191 'step_name', 195 'color',
192 'Step name for use by -pbuildbot', 196 'line',
193 ['--step_name'], 197 'verbose',
194 [], 198 'silent',
195 null), 199 'status',
196 new _TestOptionSpecification( 200 'buildbot',
197 'report', 201 'diff'
198 'Print a summary report of the number of tests, by expectation', 202 ],
199 ['--report'], 203 'compact'),
200 [], 204 new _TestOptionSpecification('failure-summary',
201 false, 205 'Print failure summary at the end', ['--failure-summary'], [], false,
202 type: 'bool'), 206 type: 'bool'),
203 new _TestOptionSpecification( 207 new _TestOptionSpecification('step_name',
204 'tasks', 208 'Step name for use by -pbuildbot', ['--step_name'], [], null),
205 'The number of parallel tasks to run', 209 new _TestOptionSpecification(
206 ['-j', '--tasks'], 210 'report',
207 [], 211 'Print a summary report of the number of tests, by expectation',
208 Platform.numberOfProcessors, 212 ['--report'],
209 type: 'int'), 213 [],
210 new _TestOptionSpecification( 214 false,
211 'shards', 215 type: 'bool'),
212 'The number of instances that the tests will be sharded over', 216 new _TestOptionSpecification(
213 ['--shards'], 217 'tasks',
214 [], 218 'The number of parallel tasks to run',
215 1, 219 ['-j', '--tasks'],
216 type: 'int'), 220 [],
217 new _TestOptionSpecification( 221 Platform.numberOfProcessors,
218 'shard', 222 type: 'int'),
219 'The index of this instance when running in sharded mode', 223 new _TestOptionSpecification(
220 ['--shard'], 224 'shards',
221 [], 225 'The number of instances that the tests will be sharded over',
222 1, 226 ['--shards'],
223 type: 'int'), 227 [],
224 new _TestOptionSpecification( 228 1,
225 'help', 229 type: 'int'),
226 'Print list of options', 230 new _TestOptionSpecification(
227 ['-h', '--help'], 231 'shard',
228 [], 232 'The index of this instance when running in sharded mode',
229 false, 233 ['--shard'],
230 type: 'bool'), 234 [],
231 new _TestOptionSpecification( 235 1,
232 'verbose', 236 type: 'int'),
233 'Verbose output', 237 new _TestOptionSpecification(
234 ['-v', '--verbose'], 238 'help', 'Print list of options', ['-h', '--help'], [], false,
235 [], 239 type: 'bool'),
236 false, 240 new _TestOptionSpecification(
237 type: 'bool'), 241 'verbose', 'Verbose output', ['-v', '--verbose'], [], false,
238 new _TestOptionSpecification( 242 type: 'bool'),
239 'list', 243 new _TestOptionSpecification(
240 'List tests only, do not run them', 244 'list', 'List tests only, do not run them', ['--list'], [], false,
241 ['--list'], 245 type: 'bool'),
242 [], 246 new _TestOptionSpecification(
243 false, 247 'report_in_json',
244 type: 'bool'), 248 'When doing list, output result summary in json only.',
245 new _TestOptionSpecification( 249 ['--report-in-json'],
246 'report_in_json', 250 [],
247 'When doing list, output result summary in json only.', 251 false,
248 ['--report-in-json'], 252 type: 'bool'),
249 [], 253 new _TestOptionSpecification('time',
250 false, 254 'Print timing information after running tests', ['--time'], [], false,
251 type: 'bool'), 255 type: 'bool'),
252 new _TestOptionSpecification( 256 new _TestOptionSpecification(
253 'time', 257 'dart', 'Path to dart executable', ['--dart'], [], ''),
254 'Print timing information after running tests', 258 new _TestOptionSpecification(
255 ['--time'], 259 'drt', // TODO(antonm): fix the option name.
256 [], 260 'Path to content shell executable',
257 false, 261 ['--drt'],
258 type: 'bool'), 262 [],
259 new _TestOptionSpecification( 263 ''),
260 'dart', 264 new _TestOptionSpecification('dartium',
261 'Path to dart executable', 265 'Path to Dartium Chrome executable', ['--dartium'], [], ''),
262 ['--dart'], 266 new _TestOptionSpecification('firefox',
263 [], 267 'Path to firefox browser executable', ['--firefox'], [], ''),
264 ''), 268 new _TestOptionSpecification(
265 new _TestOptionSpecification( 269 'chrome', 'Path to chrome browser executable', ['--chrome'], [], ''),
266 'drt', // TODO(antonm): fix the option name. 270 new _TestOptionSpecification(
267 'Path to content shell executable', 271 'safari', 'Path to safari browser executable', ['--safari'], [], ''),
268 ['--drt'], 272 new _TestOptionSpecification(
269 [], 273 'use_sdk',
270 ''), 274 '''Use compiler or runtime from the SDK.
271 new _TestOptionSpecification(
272 'dartium',
273 'Path to Dartium Chrome executable',
274 ['--dartium'],
275 [],
276 ''),
277 new _TestOptionSpecification(
278 'firefox',
279 'Path to firefox browser executable',
280 ['--firefox'],
281 [],
282 ''),
283 new _TestOptionSpecification(
284 'chrome',
285 'Path to chrome browser executable',
286 ['--chrome'],
287 [],
288 ''),
289 new _TestOptionSpecification(
290 'safari',
291 'Path to safari browser executable',
292 ['--safari'],
293 [],
294 ''),
295 new _TestOptionSpecification(
296 'use_sdk',
297 '''Use compiler or runtime from the SDK.
298 275
299 Normally, the compiler or runtimes in PRODUCT_DIR is tested, with this 276 Normally, the compiler or runtimes in PRODUCT_DIR is tested, with this
300 option, the compiler or runtime in PRODUCT_DIR/dart-sdk/bin is tested. 277 option, the compiler or runtime in PRODUCT_DIR/dart-sdk/bin is tested.
301 278
302 Note: currently only implemented for dart2js.''', 279 Note: currently only implemented for dart2js.''',
303 ['--use-sdk'], 280 ['--use-sdk'],
304 [], 281 [],
305 false, 282 false,
306 type: 'bool'), 283 type: 'bool'),
307 new _TestOptionSpecification( 284 new _TestOptionSpecification(
308 'use_public_packages', 285 'use_public_packages',
309 'For tests using packages: Use pub.dartlang.org packages ' 286 'For tests using packages: Use pub.dartlang.org packages '
310 'instead the ones in the repository.', 287 'instead the ones in the repository.',
311 ['--use-public-packages'], 288 ['--use-public-packages'],
312 [], 289 [],
313 false, 290 false,
314 type: 'bool'), 291 type: 'bool'),
315 new _TestOptionSpecification( 292 new _TestOptionSpecification(
316 'use_repository_packages', 293 'use_repository_packages',
317 'For tests using packages: Use pub.dartlang.org packages ' 294 'For tests using packages: Use pub.dartlang.org packages '
318 'but use overrides for the packages available in the ' 295 'but use overrides for the packages available in the '
319 'repository.', 296 'repository.',
320 ['--use-repository-packages'], 297 ['--use-repository-packages'],
321 [], 298 [],
322 false, 299 false,
323 type: 'bool'), 300 type: 'bool'),
324 new _TestOptionSpecification( 301 new _TestOptionSpecification(
325 'build_directory', 302 'build_directory',
326 'The name of the build directory, where products are placed.', 303 'The name of the build directory, where products are placed.',
327 ['--build-directory'], 304 ['--build-directory'],
328 [], 305 [],
329 ''), 306 ''),
330 new _TestOptionSpecification( 307 new _TestOptionSpecification('noBatch', 'Do not run tests in batch mode',
331 'noBatch', 308 ['-n', '--nobatch'], [], false,
332 'Do not run tests in batch mode', 309 type: 'bool'),
333 ['-n', '--nobatch'], 310 new _TestOptionSpecification('dart2js_batch',
334 [], 311 'Run dart2js tests in batch mode', ['--dart2js-batch'], [], false,
335 false, 312 type: 'bool'),
336 type: 'bool'), 313 new _TestOptionSpecification(
337 new _TestOptionSpecification( 314 'append_logs',
338 'dart2js_batch', 315 'Do not delete old logs but rather append to them.',
339 'Run dart2js tests in batch mode', 316 ['--append_logs'],
340 ['--dart2js-batch'], 317 [],
341 [], 318 false,
342 false, 319 type: 'bool'),
343 type: 'bool'), 320 new _TestOptionSpecification(
344 new _TestOptionSpecification( 321 'write_debug_log',
345 'append_logs', 322 'Don\'t write debug messages to stdout but rather to a logfile.',
346 'Do not delete old logs but rather append to them.', 323 ['--write-debug-log'],
347 ['--append_logs'], 324 [],
348 [], 325 false,
349 false, 326 type: 'bool'),
350 type: 'bool'), 327 new _TestOptionSpecification(
351 new _TestOptionSpecification( 328 'write_test_outcome_log',
352 'write_debug_log', 329 'Write the outcome of all tests executed to a '
353 'Don\'t write debug messages to stdout but rather to a logfile.', 330 '"${TestUtils.flakyFileName()}" file.',
354 ['--write-debug-log'], 331 ['--write-test-outcome-log'],
355 [], 332 [],
356 false, 333 false,
357 type: 'bool'), 334 type: 'bool'),
358 new _TestOptionSpecification( 335 new _TestOptionSpecification(
359 'write_test_outcome_log', 336 'clear_browser_cache',
360 'Write the outcome of all tests executed to a ' 337 'Browser specific clearing of caches(i.e., delete it).',
361 '"${TestUtils.flakyFileName()}" file.', 338 ['--clear_browser_cache'],
362 ['--write-test-outcome-log'], 339 [],
363 [], 340 false,
364 false, 341 type: 'bool'),
365 type: 'bool'), 342 new _TestOptionSpecification(
366 new _TestOptionSpecification( 343 'copy_coredumps',
367 'clear_browser_cache', 344 'If we see a crash that we did not expect, copy the core dumps. '
368 'Browser specific clearing of caches(i.e., delete it).', 345 'to /tmp',
369 ['--clear_browser_cache'], 346 ['--copy-coredumps'],
370 [], 347 [],
371 false, 348 false,
372 type: 'bool'), 349 type: 'bool'),
373 new _TestOptionSpecification( 350 new _TestOptionSpecification(
374 'copy_coredumps', 351 'local_ip',
375 'If we see a crash that we did not expect, copy the core dumps. ' 352 'IP address the http servers should listen on.'
376 'to /tmp', 353 'This address is also used for browsers to connect.',
377 ['--copy-coredumps'], 354 ['--local_ip'],
378 [], 355 [],
379 false, 356 '127.0.0.1'),
380 type: 'bool'), 357 new _TestOptionSpecification('test_server_port',
381 new _TestOptionSpecification( 358 'Port for test http server.', ['--test_server_port'], [], 0,
382 'local_ip', 359 type: 'int'),
383 'IP address the http servers should listen on.' 360 new _TestOptionSpecification(
384 'This address is also used for browsers to connect.', 361 'test_server_cross_origin_port',
385 ['--local_ip'], 362 'Port for test http server cross origin.',
386 [], 363 ['--test_server_cross_origin_port'],
387 '127.0.0.1'), 364 [],
388 new _TestOptionSpecification( 365 0,
389 'test_server_port', 366 type: 'int'),
390 'Port for test http server.', 367 new _TestOptionSpecification('test_driver_port',
391 ['--test_server_port'], 368 'Port for http test driver server.', ['--test_driver_port'], [], 0,
392 [], 369 type: 'int'),
393 0, 370 new _TestOptionSpecification(
394 type: 'int'), 371 'test_driver_error_port',
395 new _TestOptionSpecification( 372 'Port for http test driver server errors.',
396 'test_server_cross_origin_port', 373 ['--test_driver_error_port'],
397 'Port for test http server cross origin.', 374 [],
398 ['--test_server_cross_origin_port'], 375 0,
399 [], 376 type: 'int'),
400 0, 377 new _TestOptionSpecification(
401 type: 'int'), 378 'record_to_file',
402 new _TestOptionSpecification( 379 'Records all the commands that need to be executed and writes it '
403 'test_driver_port', 380 'out to a file.',
404 'Port for http test driver server.', 381 ['--record_to_file'],
405 ['--test_driver_port'], 382 [],
406 [], 383 null),
407 0, 384 new _TestOptionSpecification(
408 type: 'int'), 385 'replay_from_file',
409 new _TestOptionSpecification( 386 'Records all the commands that need to be executed and writes it '
410 'test_driver_error_port', 387 'out to a file.',
411 'Port for http test driver server errors.', 388 ['--replay_from_file'],
412 ['--test_driver_error_port'], 389 [],
413 [], 390 null),
414 0, 391 new _TestOptionSpecification(
415 type: 'int'), 392 'builder_tag',
416 new _TestOptionSpecification( 393 'Machine specific options that is not captured by the regular '
417 'record_to_file', 394 'test options. Used to be able to make sane updates to the '
418 'Records all the commands that need to be executed and writes it ' 395 'status files.',
419 'out to a file.', 396 ['--builder-tag'],
420 ['--record_to_file'], 397 [],
421 [], 398 ''),
422 null), 399 new _TestOptionSpecification(
423 new _TestOptionSpecification( 400 'vm_options',
424 'replay_from_file', 401 'Extra options to send to the vm when running',
425 'Records all the commands that need to be executed and writes it ' 402 ['--vm-options'],
426 'out to a file.', 403 [],
427 ['--replay_from_file'], 404 null),
428 [], 405 new _TestOptionSpecification(
429 null), 406 'dart2js_options',
430 new _TestOptionSpecification( 407 'Extra options for dart2js compilation step',
431 'builder_tag', 408 ['--dart2js-options'],
432 'Machine specific options that is not captured by the regular ' 409 [],
433 'test options. Used to be able to make sane updates to the ' 410 null),
434 'status files.', 411 new _TestOptionSpecification(
435 ['--builder-tag'], 412 'suite_dir',
436 [], 413 'Additional directory to add to the testing matrix',
437 ''), 414 ['--suite-dir'],
438 new _TestOptionSpecification( 415 [],
439 'vm_options', 416 null),
440 'Extra options to send to the vm when running', 417 new _TestOptionSpecification('package_root',
441 ['--vm-options'], 418 'The package root to use for testing.', ['--package-root'], [], null),
442 [], 419 new _TestOptionSpecification(
443 null), 420 'exclude_suite',
444 new _TestOptionSpecification( 421 'Exclude suites from default selector, only works when no'
445 'dart2js_options', 422 ' selector has been specified on the command line',
446 'Extra options for dart2js compilation step', 423 ['--exclude-suite'],
447 ['--dart2js-options'], 424 defaultTestSelectors,
448 [], 425 null),
449 null), 426 ];
450 new _TestOptionSpecification(
451 'suite_dir',
452 'Additional directory to add to the testing matrix',
453 ['--suite-dir'],
454 [],
455 null),
456 new _TestOptionSpecification(
457 'package_root',
458 'The package root to use for testing.',
459 ['--package-root'],
460 [],
461 null),
462 new _TestOptionSpecification(
463 'exclude_suite',
464 'Exclude suites from default selector, only works when no'
465 ' selector has been specified on the command line',
466 ['--exclude-suite'],
467 defaultTestSelectors,
468 null),];
469 } 427 }
470 428
471
472 /** 429 /**
473 * Parse a list of strings as test options. 430 * Parse a list of strings as test options.
474 * 431 *
475 * Returns a list of configurations in which to run the 432 * Returns a list of configurations in which to run the
476 * tests. Configurations are maps mapping from option keys to 433 * tests. Configurations are maps mapping from option keys to
477 * values. When encountering the first non-option string, the rest 434 * values. When encountering the first non-option string, the rest
478 * of the arguments are stored in the returned Map under the 'rest' 435 * of the arguments are stored in the returned Map under the 'rest'
479 * key. 436 * key.
480 */ 437 */
481 List<Map> parse(List<String> arguments) { 438 List<Map> parse(List<String> arguments) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } else { 491 } else {
535 // The argument does not start with '-' or '--' and is 492 // The argument does not start with '-' or '--' and is
536 // therefore not an option. We use it as a test selection 493 // therefore not an option. We use it as a test selection
537 // pattern. 494 // pattern.
538 configuration.putIfAbsent('selectors', () => []); 495 configuration.putIfAbsent('selectors', () => []);
539 var patterns = configuration['selectors']; 496 var patterns = configuration['selectors'];
540 patterns.add(arg); 497 patterns.add(arg);
541 continue; 498 continue;
542 } 499 }
543 500
544
545 // Multiple uses of a flag are an error, because there is no 501 // Multiple uses of a flag are an error, because there is no
546 // naturally correct way to handle conflicting options. 502 // naturally correct way to handle conflicting options.
547 if (configuration.containsKey(spec.name)) { 503 if (configuration.containsKey(spec.name)) {
548 print('Error: test.dart disallows multiple "--${spec.name}" flags'); 504 print('Error: test.dart disallows multiple "--${spec.name}" flags');
549 exit(1); 505 exit(1);
550 } 506 }
551 // Parse the value for the option. 507 // Parse the value for the option.
552 if (spec.type == 'bool') { 508 if (spec.type == 'bool') {
553 if (!value.isEmpty) { 509 if (!value.isEmpty) {
554 print('No value expected for bool option $name'); 510 print('No value expected for bool option $name');
(...skipping 24 matching lines...) Expand all
579 // Apply default values for unspecified options. 535 // Apply default values for unspecified options.
580 for (var option in _options) { 536 for (var option in _options) {
581 if (!configuration.containsKey(option.name)) { 537 if (!configuration.containsKey(option.name)) {
582 configuration[option.name] = option.defaultValue; 538 configuration[option.name] = option.defaultValue;
583 } 539 }
584 } 540 }
585 541
586 List<Map> expandedConfigs = _expandConfigurations(configuration); 542 List<Map> expandedConfigs = _expandConfigurations(configuration);
587 List<Map> result = expandedConfigs.where(_isValidConfig).toList(); 543 List<Map> result = expandedConfigs.where(_isValidConfig).toList();
588 for (var config in result) { 544 for (var config in result) {
589 config['_reproducing_arguments_'] = 545 config['_reproducing_arguments_'] =
590 _constructReproducingCommandArguments(config); 546 _constructReproducingCommandArguments(config);
591 } 547 }
592 return result.isEmpty ? null : result; 548 return result.isEmpty ? null : result;
593 } 549 }
594 550
595 // For printing out reproducing command lines, we don't want to add these 551 // For printing out reproducing command lines, we don't want to add these
596 // options. 552 // options.
597 Set<String> _blacklistedOptions = new Set<String>.from([ 553 Set<String> _blacklistedOptions = new Set<String>.from([
598 'progress', 'failure-summary', 'step_name', 'report', 'tasks', 'verbose', 554 'progress',
599 'time', 'dart', 'drt', 'dartium', 'firefox', 'chrome', 'safari', 555 'failure-summary',
600 'build_directory', 'append_logs', 'local_ip', 'shard', 'shards', 556 'step_name',
557 'report',
558 'tasks',
559 'verbose',
560 'time',
561 'dart',
562 'drt',
563 'dartium',
564 'firefox',
565 'chrome',
566 'safari',
567 'build_directory',
568 'append_logs',
569 'local_ip',
570 'shard',
571 'shards',
601 ]); 572 ]);
602 573
603 List<String> _constructReproducingCommandArguments(Map config) { 574 List<String> _constructReproducingCommandArguments(Map config) {
604 var arguments = new List<String>(); 575 var arguments = new List<String>();
605 for (var configKey in config.keys) { 576 for (var configKey in config.keys) {
606 if (!_blacklistedOptions.contains(configKey)) { 577 if (!_blacklistedOptions.contains(configKey)) {
607 for (var option in _options) { 578 for (var option in _options) {
608 var configValue = config[configKey]; 579 var configValue = config[configKey];
609 // We only include entries of [conf] if we find an option for it. 580 // We only include entries of [conf] if we find an option for it.
610 if (configKey == option.name && configValue != option.defaultValue) { 581 if (configKey == option.name && configValue != option.defaultValue) {
(...skipping 30 matching lines...) Expand all
641 */ 612 */
642 bool _isValidConfig(Map config) { 613 bool _isValidConfig(Map config) {
643 bool isValid = true; 614 bool isValid = true;
644 List<String> validRuntimes; 615 List<String> validRuntimes;
645 switch (config['compiler']) { 616 switch (config['compiler']) {
646 case 'dart2js': 617 case 'dart2js':
647 // Note: by adding 'none' as a configuration, if the user 618 // Note: by adding 'none' as a configuration, if the user
648 // runs test.py -c dart2js -r drt,none the dart2js_none and 619 // runs test.py -c dart2js -r drt,none the dart2js_none and
649 // dart2js_drt will be duplicating work. If later we don't need 'none' 620 // dart2js_drt will be duplicating work. If later we don't need 'none'
650 // with dart2js, we should remove it from here. 621 // with dart2js, we should remove it from here.
651 validRuntimes = const ['d8', 'jsshell', 'drt', 'none', 'dartium', 622 validRuntimes = const [
652 'ff', 'chrome', 'safari', 'ie9', 'ie10', 'ie11', 623 'd8',
653 'opera', 'chromeOnAndroid', 'safarimobilesim']; 624 'jsshell',
625 'drt',
626 'none',
627 'dartium',
628 'ff',
629 'chrome',
630 'safari',
631 'ie9',
632 'ie10',
633 'ie11',
634 'opera',
635 'chromeOnAndroid',
636 'safarimobilesim'
637 ];
654 break; 638 break;
655 case 'dart2analyzer': 639 case 'dart2analyzer':
656 validRuntimes = const ['none']; 640 validRuntimes = const ['none'];
657 break; 641 break;
658 case 'dart2app': 642 case 'dart2app':
659 validRuntimes = const ['dart_product']; 643 validRuntimes = const ['dart_product'];
660 break; 644 break;
661 case 'precompiler': 645 case 'precompiler':
662 validRuntimes = const ['dart_precompiled']; 646 validRuntimes = const ['dart_precompiled'];
663 break; 647 break;
664 case 'none': 648 case 'none':
665 validRuntimes = const ['vm', 'drt', 'dartium', 649 validRuntimes = const [
666 'ContentShellOnAndroid', 'DartiumOnAndroid']; 650 'vm',
651 'drt',
652 'dartium',
653 'ContentShellOnAndroid',
654 'DartiumOnAndroid'
655 ];
667 break; 656 break;
668 } 657 }
669 if (!validRuntimes.contains(config['runtime'])) { 658 if (!validRuntimes.contains(config['runtime'])) {
670 isValid = false; 659 isValid = false;
671 print("Warning: combination of compiler '${config['compiler']}' and " 660 print("Warning: combination of compiler '${config['compiler']}' and "
672 "runtime '${config['runtime']}' is invalid. " 661 "runtime '${config['runtime']}' is invalid. "
673 "Skipping this combination."); 662 "Skipping this combination.");
674 } 663 }
675 if (config['ie'] && Platform.operatingSystem != 'windows') { 664 if (config['ie'] && Platform.operatingSystem != 'windows') {
676 isValid = false; 665 isValid = false;
677 print("Warning cannot run Internet Explorer on non-Windows operating" 666 print("Warning cannot run Internet Explorer on non-Windows operating"
678 " system."); 667 " system.");
679 } 668 }
680 if (config['shard'] < 1 || config['shard'] > config['shards']) { 669 if (config['shard'] < 1 || config['shard'] > config['shards']) {
681 isValid = false; 670 isValid = false;
682 print("Error: shard index is ${config['shard']} out of " 671 print("Error: shard index is ${config['shard']} out of "
683 "${config['shards']} shards"); 672 "${config['shards']} shards");
684 } 673 }
685 674
686 if (config['use_repository_packages'] && config['use_public_packages']) { 675 if (config['use_repository_packages'] && config['use_public_packages']) {
687 isValid = false; 676 isValid = false;
688 print("Cannot have both --use-repository-packages and " 677 print("Cannot have both --use-repository-packages and "
689 "--use-public-packages"); 678 "--use-public-packages");
690 } 679 }
691 680
692 return isValid; 681 return isValid;
693 } 682 }
694 683
695 /** 684 /**
696 * Recursively expand a configuration with multiple values per key 685 * Recursively expand a configuration with multiple values per key
697 * into a list of configurations with exactly one value per key. 686 * into a list of configurations with exactly one value per key.
698 */ 687 */
699 List<Map> _expandConfigurations(Map configuration) { 688 List<Map> _expandConfigurations(Map configuration) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 configuration['jscl'] = TestUtils.isJsCommandLineRuntime(runtime); 725 configuration['jscl'] = TestUtils.isJsCommandLineRuntime(runtime);
737 726
738 // Allow suppression that is valid for all ie versions 727 // Allow suppression that is valid for all ie versions
739 configuration['ie'] = runtime.startsWith('ie'); 728 configuration['ie'] = runtime.startsWith('ie');
740 729
741 // Expand the test selectors into a suite name and a simple 730 // Expand the test selectors into a suite name and a simple
742 // regular expressions to be used on the full path of a test file 731 // regular expressions to be used on the full path of a test file
743 // in that test suite. If no selectors are explicitly given use 732 // in that test suite. If no selectors are explicitly given use
744 // the default suite patterns. 733 // the default suite patterns.
745 var selectors = configuration['selectors']; 734 var selectors = configuration['selectors'];
746 if (selectors is !Map) { 735 if (selectors is! Map) {
747 if (selectors == null) { 736 if (selectors == null) {
748 if (configuration['suite_dir'] != null) { 737 if (configuration['suite_dir'] != null) {
749 var suite_path = new Path(configuration['suite_dir']); 738 var suite_path = new Path(configuration['suite_dir']);
750 selectors = [suite_path.filename]; 739 selectors = [suite_path.filename];
751 } else { 740 } else {
752 selectors = new List.from(defaultTestSelectors); 741 selectors = new List.from(defaultTestSelectors);
753 } 742 }
754 743
755 var exclude_suites = configuration['exclude_suite'] != null ? 744 var exclude_suites = configuration['exclude_suite'] != null
756 configuration['exclude_suite'].split(',') : []; 745 ? configuration['exclude_suite'].split(',')
746 : [];
757 for (var exclude in exclude_suites) { 747 for (var exclude in exclude_suites) {
758 if (selectors.contains(exclude)) { 748 if (selectors.contains(exclude)) {
759 selectors.remove(exclude); 749 selectors.remove(exclude);
760 } else { 750 } else {
761 print("Error: default selectors does not contain $exclude"); 751 print("Error: default selectors does not contain $exclude");
762 exit(1); 752 exit(1);
763 } 753 }
764 } 754 }
765 } 755 }
766 Map<String, RegExp> selectorMap = new Map<String, RegExp>(); 756 Map<String, RegExp> selectorMap = new Map<String, RegExp>();
767 for (var i = 0; i < selectors.length; i++) { 757 for (var i = 0; i < selectors.length; i++) {
768 var pattern = selectors[i]; 758 var pattern = selectors[i];
769 var suite = pattern; 759 var suite = pattern;
770 var slashLocation = pattern.indexOf('/'); 760 var slashLocation = pattern.indexOf('/');
771 if (slashLocation != -1) { 761 if (slashLocation != -1) {
772 suite = pattern.substring(0, slashLocation); 762 suite = pattern.substring(0, slashLocation);
773 pattern = pattern.substring(slashLocation + 1); 763 pattern = pattern.substring(slashLocation + 1);
774 pattern = pattern.replaceAll('*', '.*'); 764 pattern = pattern.replaceAll('*', '.*');
775 } else { 765 } else {
776 pattern = ".?"; 766 pattern = ".?";
777 } 767 }
778 if (selectorMap.containsKey(suite)) { 768 if (selectorMap.containsKey(suite)) {
779 print("Error: '$suite/$pattern'. Only one test selection" 769 print("Error: '$suite/$pattern'. Only one test selection"
780 " pattern is allowed to start with '$suite/'"); 770 " pattern is allowed to start with '$suite/'");
781 exit(1); 771 exit(1);
782 } 772 }
783 selectorMap[suite] = new RegExp(pattern); 773 selectorMap[suite] = new RegExp(pattern);
784 } 774 }
785 configuration['selectors'] = selectorMap; 775 configuration['selectors'] = selectorMap;
786 } 776 }
787 777
788 // Expand the architectures. 778 // Expand the architectures.
789 if (configuration['arch'].contains(',')) { 779 if (configuration['arch'].contains(',')) {
790 return _expandHelper('arch', configuration); 780 return _expandHelper('arch', configuration);
(...skipping 18 matching lines...) Expand all
809 var updater = runtimeUpdater(configuration); 799 var updater = runtimeUpdater(configuration);
810 if (updater != null) { 800 if (updater != null) {
811 updater.update(); 801 updater.update();
812 } 802 }
813 } 803 }
814 804
815 // Adjust default timeout based on mode, compiler, and sometimes runtime. 805 // Adjust default timeout based on mode, compiler, and sometimes runtime.
816 if (configuration['timeout'] == -1) { 806 if (configuration['timeout'] == -1) {
817 int compilerMulitiplier = 807 int compilerMulitiplier =
818 new CompilerConfiguration(configuration).computeTimeoutMultiplier(); 808 new CompilerConfiguration(configuration).computeTimeoutMultiplier();
819 int runtimeMultiplier = 809 int runtimeMultiplier = new RuntimeConfiguration(configuration)
820 new RuntimeConfiguration(configuration).computeTimeoutMultiplier( 810 .computeTimeoutMultiplier(
821 mode: configuration['mode'], 811 mode: configuration['mode'],
822 isChecked: configuration['checked'], 812 isChecked: configuration['checked'],
823 arch: configuration['arch']); 813 arch: configuration['arch']);
824 configuration['timeout'] = 60 * compilerMulitiplier * runtimeMultiplier; 814 configuration['timeout'] = 60 * compilerMulitiplier * runtimeMultiplier;
825 } 815 }
826 816
827 return [configuration]; 817 return [configuration];
828 } 818 }
829 819
830 /** 820 /**
831 * Helper for _expandConfigurations. Creates a new configuration and adds it 821 * Helper for _expandConfigurations. Creates a new configuration and adds it
832 * to a list, for use in a case when a particular configuration has multiple 822 * to a list, for use in a case when a particular configuration has multiple
833 * results (separated by a ','). 823 * results (separated by a ',').
834 * Arguments: 824 * Arguments:
835 * option: The particular test option we are expanding. 825 * option: The particular test option we are expanding.
836 * configuration: The map containing all test configuration information 826 * configuration: The map containing all test configuration information
837 * specified. 827 * specified.
838 */ 828 */
839 List<Map> _expandHelper(String option, Map configuration) { 829 List<Map> _expandHelper(String option, Map configuration) {
840 var result = new List<Map>(); 830 var result = new List<Map>();
841 var configs = configuration[option]; 831 var configs = configuration[option];
842 for (var config in configs.split(',')) { 832 for (var config in configs.split(',')) {
843 var newConfiguration = new Map.from(configuration); 833 var newConfiguration = new Map.from(configuration);
844 newConfiguration[option] = config; 834 newConfiguration[option] = config;
845 result.addAll(_expandConfigurations(newConfiguration)); 835 result.addAll(_expandConfigurations(newConfiguration));
846 } 836 }
847 return result; 837 return result;
848 } 838 }
849 839
850
851 /** 840 /**
852 * Print out usage information. 841 * Print out usage information.
853 */ 842 */
854 void _printHelp() { 843 void _printHelp() {
855 print('usage: dart test.dart [options] [selector]'); 844 print('usage: dart test.dart [options] [selector]');
856 print(''); 845 print('');
857 print('The optional selector limits the tests that will be run.'); 846 print('The optional selector limits the tests that will be run.');
858 print('For example, the selector "language/issue", or equivalently'); 847 print('For example, the selector "language/issue", or equivalently');
859 print('"language/*issue*", limits to test files matching the regexp'); 848 print('"language/*issue*", limits to test files matching the regexp');
860 print('".*issue.*\\.dart" in the "tests/language" directory.'); 849 print('".*issue.*\\.dart" in the "tests/language" directory.');
861 print(''); 850 print('');
862 print('Options:\n'); 851 print('Options:\n');
863 for (var option in _options) { 852 for (var option in _options) {
864 print('${option.name}: ${option.description}.'); 853 print('${option.name}: ${option.description}.');
865 for (var name in option.keys) { 854 for (var name in option.keys) {
866 assert(name.startsWith('-')); 855 assert(name.startsWith('-'));
867 var buffer = new StringBuffer();; 856 var buffer = new StringBuffer();
857 ;
868 buffer.write(name); 858 buffer.write(name);
869 if (option.type == 'bool') { 859 if (option.type == 'bool') {
870 assert(option.values.isEmpty); 860 assert(option.values.isEmpty);
871 } else { 861 } else {
872 buffer.write(name.startsWith('--') ? '=' : ' '); 862 buffer.write(name.startsWith('--') ? '=' : ' ');
873 if (option.type == 'int') { 863 if (option.type == 'int') {
874 assert(option.values.isEmpty); 864 assert(option.values.isEmpty);
875 buffer.write('n (default: ${option.defaultValue})'); 865 buffer.write('n (default: ${option.defaultValue})');
876 } else { 866 } else {
877 buffer.write('['); 867 buffer.write('[');
878 bool first = true; 868 bool first = true;
879 for (var value in option.values) { 869 for (var value in option.values) {
880 if (!first) buffer.write(", "); 870 if (!first) buffer.write(", ");
881 if (value == option.defaultValue) buffer.write('*'); 871 if (value == option.defaultValue) buffer.write('*');
882 buffer.write(value); 872 buffer.write(value);
883 first = false; 873 first = false;
884 } 874 }
885 buffer.write(']'); 875 buffer.write(']');
886 } 876 }
887 } 877 }
888 print(buffer.toString()); 878 print(buffer.toString());
889 } 879 }
890 print(''); 880 print('');
891 } 881 }
892 } 882 }
893 883
894
895 /** 884 /**
896 * Find the test option specification for a given option key. 885 * Find the test option specification for a given option key.
897 */ 886 */
898 _TestOptionSpecification _getSpecification(String name) { 887 _TestOptionSpecification _getSpecification(String name) {
899 for (var option in _options) { 888 for (var option in _options) {
900 if (option.keys.contains(name)) { 889 if (option.keys.contains(name)) {
901 return option; 890 return option;
902 } 891 }
903 } 892 }
904 print('Unknown test option $name'); 893 print('Unknown test option $name');
905 exit(1); 894 exit(1);
906 } 895 }
907 896
908
909 List<_TestOptionSpecification> _options; 897 List<_TestOptionSpecification> _options;
910 } 898 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_configurations.dart ('k') | tools/testing/dart/test_progress.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698