OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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("dart:builtin"); | 8 #import("dart:builtin"); |
9 #import("drt_updater.dart"); | 9 #import("drt_updater.dart"); |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 */ | 55 */ |
56 TestOptionsParser() { | 56 TestOptionsParser() { |
57 _options = | 57 _options = |
58 [ new _TestOptionSpecification( | 58 [ new _TestOptionSpecification( |
59 'mode', | 59 'mode', |
60 'Mode in which to run the tests', | 60 'Mode in which to run the tests', |
61 ['-m', '--mode'], | 61 ['-m', '--mode'], |
62 ['all', 'debug', 'release'], | 62 ['all', 'debug', 'release'], |
63 'debug'), | 63 'debug'), |
64 new _TestOptionSpecification( | 64 new _TestOptionSpecification( |
65 'component', | 65 'compiler', |
66 ''' | 66 '''Specify any compilation step (if needed). |
67 Controls how dart code is compiled and executed. | |
68 | 67 |
69 vm: Run dart code on the standalone dart vm. | 68 none: Do not compile the Dart code (run native Dart code on the VM). |
ahe
2012/03/24 13:56:40
I don't think compiler 'none' should imply running
Emily Fortuna
2012/03/26 20:52:32
In what case when the compiler=none would we not b
ahe
2012/04/13 13:46:20
Dartium for example.
I'm just saying that, compil
Emily Fortuna
2012/04/13 17:45:56
True. This was Ivan's request to make running on t
| |
70 | 69 |
71 frog: Compile dart code by running frog on the standalone dart vm, and | 70 frog: Compile dart code to JavaScript by running the frog compiler. |
72 run the resulting javascript on D8. | |
73 | 71 |
74 dart2js: Compile dart code by running dart2js on the standalone | 72 dart2js: Compile dart code to JavaScript by running dart2js (leg). |
75 dart vm, and run the resulting javascript on D8. | |
76 | 73 |
77 frogsh: Compile dart code by running frog on node.js, and run the | 74 dartc: Perform static analysis on Dart code by running dartc. |
78 resulting javascript on the same instance of node.js. | |
79 | |
80 dartium: Run dart code in a type="application/dart" script tag in a | |
81 dartium build of DumpRenderTree. | |
82 | |
83 frogium: Compile dart code by running frog on the standalone dart vm, | |
84 and run the resulting javascript in a javascript script tag in | |
85 a dartium build of DumpRenderTree. | |
86 | |
87 legium: Compile dart code by running dart2js on the standalone dart | |
88 vm, and run the resulting javascript in a javascript script tag | |
89 in a dartium build of DumpRenderTree. | |
90 | |
91 webdriver: Compile dart code by running frog on the standalone dart vm, | |
92 and then run the resulting javascript in the browser that is specified | |
93 by the --browser switch (e.g. chrome, safari, ff, etc.). | |
94 | |
95 dartc: Run dart code through the dartc static analyzer (does not | |
96 execute dart code). | |
97 ''', | 75 ''', |
98 ['-c', '--component'], | 76 ['-c', '--compiler'], |
99 ['most', 'vm', 'frog', 'dart2js', 'frogsh', 'dartium', 'frogium', | 77 ['none', 'frog', 'dart2js', 'dartc'], |
Siggi Cherem (dart-lang)
2012/03/23 23:57:33
seems like you still need frogsh? (saw it in statu
ahe
2012/03/24 13:56:40
I don't think we run frogsh anymore on build bots.
Emily Fortuna
2012/03/26 20:52:32
@Peter, SGTM. In this CL I had originally removed
| |
100 'legium', 'webdriver', 'dartc'], | 78 'none'), |
79 new _TestOptionSpecification( | |
80 'runtime', | |
81 '''Where the tests should be run. | |
82 vm: Run Dart code on the standalone dart vm. | |
83 | |
84 d8: Run JavaScript from the command line using v8. | |
85 | |
86 drt: Run Dart or JavaScript in the headless version of Chrome, | |
87 DumpRenderTree. | |
88 | |
89 ff or firefox: Run JavaScript in Firefox. | |
90 | |
91 chrome: Run JavaScript in Chrome. | |
92 | |
93 safari: Run JavaScript in Safari. | |
94 | |
95 ie: Run JavaScript in Internet Explorer. | |
96 | |
97 opera: Run JavaScript in Opera. | |
98 | |
99 none: No runtime (used for dartc static analysis tests).''', | |
ahe
2012/03/24 13:56:40
for example.
Emily Fortuna
2012/03/26 20:52:32
Done.
| |
100 ['-r', '--runtime'], | |
101 ['vm', 'd8', 'drt', 'ff', 'firefox', 'chrome', | |
102 'safari', 'ie', 'opera', 'none'], | |
101 'vm'), | 103 'vm'), |
102 new _TestOptionSpecification( | 104 new _TestOptionSpecification( |
103 'arch', | 105 'arch', |
104 'The architecture to run tests for', | 106 'The architecture to run tests for', |
105 ['-a', '--arch'], | 107 ['-a', '--arch'], |
106 ['all', 'ia32', 'x64', 'simarm'], | 108 ['all', 'ia32', 'x64', 'simarm'], |
107 'ia32'), | 109 'ia32'), |
108 new _TestOptionSpecification( | 110 new _TestOptionSpecification( |
109 'system', | 111 'system', |
110 'The operating system to run tests on', | 112 'The operating system to run tests on', |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 [], | 197 [], |
196 ''), | 198 ''), |
197 new _TestOptionSpecification( | 199 new _TestOptionSpecification( |
198 'time', | 200 'time', |
199 'Print timing information after running tests', | 201 'Print timing information after running tests', |
200 ['--time'], | 202 ['--time'], |
201 [], | 203 [], |
202 false, | 204 false, |
203 'bool'), | 205 'bool'), |
204 new _TestOptionSpecification( | 206 new _TestOptionSpecification( |
205 'browser', | |
206 'Web browser to use on webdriver tests', | |
207 ['-b', '--browser'], | |
208 ['ff', 'chrome', 'safari', 'ie', 'opera'], | |
209 'chrome'), | |
210 new _TestOptionSpecification( | |
211 'frog', | |
212 'Path to frog executable', | |
213 ['--frog'], | |
214 [], | |
215 ''), | |
216 new _TestOptionSpecification( | |
217 'drt', | 207 'drt', |
218 'Path to DumpRenderTree executable', | 208 'Path to DumpRenderTree executable', |
219 ['--drt'], | 209 ['--drt'], |
220 [], | 210 [], |
221 ''), | 211 ''), |
222 new _TestOptionSpecification( | 212 new _TestOptionSpecification( |
223 'froglib', | |
224 'Path to frog library', | |
225 ['--froglib'], | |
226 [], | |
227 ''), | |
228 new _TestOptionSpecification( | |
229 'noBatch', | 213 'noBatch', |
230 'Do not run browser tests in batch mode', | 214 'Do not run browser tests in batch mode', |
231 ['-n', '--nobatch'], | 215 ['-n', '--nobatch'], |
232 [], | 216 [], |
233 false, | 217 false, |
234 'bool')]; | 218 'bool')]; |
235 } | 219 } |
236 | 220 |
237 | 221 |
238 /** | 222 /** |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 * into a list of configurations with exactly one value per key. | 342 * into a list of configurations with exactly one value per key. |
359 */ | 343 */ |
360 List<Map> _expandConfigurations(Map configuration) { | 344 List<Map> _expandConfigurations(Map configuration) { |
361 // Expand the pseudo-values such as 'all'. | 345 // Expand the pseudo-values such as 'all'. |
362 if (configuration['arch'] == 'all') { | 346 if (configuration['arch'] == 'all') { |
363 configuration['arch'] = 'ia32,x64'; | 347 configuration['arch'] = 'ia32,x64'; |
364 } | 348 } |
365 if (configuration['mode'] == 'all') { | 349 if (configuration['mode'] == 'all') { |
366 configuration['mode'] = 'debug,release'; | 350 configuration['mode'] = 'debug,release'; |
367 } | 351 } |
368 if (configuration['component'] == 'most') { | |
369 configuration['component'] = 'vm,dartc'; | |
370 } | |
371 if (configuration['valgrind']) { | 352 if (configuration['valgrind']) { |
372 // TODO(ager): Get rid of this when there is only one checkout and | 353 // TODO(ager): Get rid of this when there is only one checkout and |
373 // we don't have to special case for the runtime checkout. | 354 // we don't have to special case for the runtime checkout. |
374 File valgrindFile = new File('runtime/tools/valgrind.py'); | 355 File valgrindFile = new File('runtime/tools/valgrind.py'); |
375 if (!valgrindFile.existsSync()) { | 356 if (!valgrindFile.existsSync()) { |
376 valgrindFile = new File('../runtime/tools/valgrind.py'); | 357 valgrindFile = new File('../runtime/tools/valgrind.py'); |
377 } | 358 } |
378 String valgrind = valgrindFile.fullPathSync(); | 359 String valgrind = valgrindFile.fullPathSync(); |
379 configuration['special-command'] = 'python -u $valgrind @'; | 360 configuration['special-command'] = 'python -u $valgrind @'; |
380 } | 361 } |
381 | 362 |
382 // Use verbose progress indication for verbose output unless buildbot | 363 // Use verbose progress indication for verbose output unless buildbot |
383 // progress indication is requested. | 364 // progress indication is requested. |
384 if (configuration['verbose'] && configuration['progress'] != 'buildbot') { | 365 if (configuration['verbose'] && configuration['progress'] != 'buildbot') { |
385 configuration['progress'] = 'verbose'; | 366 configuration['progress'] = 'verbose'; |
386 } | 367 } |
387 | 368 |
388 // Create the artificial 'unchecked' options that test status files | 369 // Create the artificial 'unchecked' options that test status files |
389 // expect. | 370 // expect. |
390 configuration['unchecked'] = !configuration['checked']; | 371 configuration['unchecked'] = !configuration['checked']; |
391 configuration['host_unchecked'] = !configuration['host_checked']; | 372 configuration['host_unchecked'] = !configuration['host_checked']; |
392 | 373 |
374 if (configuration['runtime'] == 'firefox') { | |
375 configuration['runtime'] == 'ff'; | |
376 } | |
377 | |
393 // Expand the test selectors into a suite name and a simple | 378 // Expand the test selectors into a suite name and a simple |
394 // regular expressions to be used on the full path of a test file | 379 // regular expressions to be used on the full path of a test file |
395 // in that test suite. If no selectors are explicitly given use | 380 // in that test suite. If no selectors are explicitly given use |
396 // the default suite patterns. | 381 // the default suite patterns. |
397 var selectors = configuration['selectors']; | 382 var selectors = configuration['selectors']; |
398 if (selectors is !Map) { | 383 if (selectors is !Map) { |
399 if (selectors == null) { | 384 if (selectors == null) { |
400 selectors = new List.from(defaultTestSelectors); | 385 selectors = new List.from(defaultTestSelectors); |
401 } | 386 } |
402 Map<String, RegExp> selectorMap = new Map<String, RegExp>(); | 387 Map<String, RegExp> selectorMap = new Map<String, RegExp>(); |
(...skipping 13 matching lines...) Expand all Loading... | |
416 print("Error: '$suite/$pattern'. Only one test selection" + | 401 print("Error: '$suite/$pattern'. Only one test selection" + |
417 " pattern is allowed to start with '$suite/'"); | 402 " pattern is allowed to start with '$suite/'"); |
418 exit(1); | 403 exit(1); |
419 } | 404 } |
420 selectorMap[suite] = new RegExp(pattern); | 405 selectorMap[suite] = new RegExp(pattern); |
421 } | 406 } |
422 configuration['selectors'] = selectorMap; | 407 configuration['selectors'] = selectorMap; |
423 } | 408 } |
424 | 409 |
425 // Expand the architectures. | 410 // Expand the architectures. |
426 var archs = configuration['arch']; | 411 if (configuration['arch'].contains(',')) { |
427 if (archs.contains(',')) { | 412 return _expandHelper('arch', configuration); |
428 var result = new List<Map>(); | |
429 for (var arch in archs.split(',')) { | |
430 var newConfiguration = new Map.from(configuration); | |
431 newConfiguration['arch'] = arch; | |
432 result.addAll(_expandConfigurations(newConfiguration)); | |
433 } | |
434 return result; | |
435 } | 413 } |
436 | 414 |
437 // Expand modes. | 415 // Expand modes. |
438 var modes = configuration['mode']; | 416 if (configuration['mode'].contains(',')) { |
439 if (modes.contains(',')) { | 417 return _expandHelper('mode', configuration); |
440 var result = new List<Map>(); | 418 } |
441 for (var mode in modes.split(',')) { | 419 |
442 var newConfiguration = new Map.from(configuration); | 420 // Expand compilers. |
443 newConfiguration['mode'] = mode; | 421 if (configuration['compiler'].contains(',')) { |
444 result.addAll(_expandConfigurations(newConfiguration)); | 422 return _expandHelper('compiler', configuration); |
445 } | |
446 return result; | |
447 } | 423 } |
448 | 424 |
449 // Expand components. | 425 // Expand runtimes. |
450 var components = configuration['component']; | 426 var runtimes = configuration['runtime']; |
451 if (components.contains(',')) { | 427 if (runtimes.contains(',')) { |
452 var result = new List<Map>(); | 428 return _expandHelper('runtime', configuration); |
Siggi Cherem (dart-lang)
2012/03/23 23:57:33
could we add a function (or a TODO) that checks th
Emily Fortuna
2012/03/26 20:52:32
Done.
Siggi Cherem (dart-lang)
2012/03/26 22:28:39
Nice, thanks!
| |
453 for (var component in components.split(',')) { | |
454 var newConfiguration = new Map.from(configuration); | |
455 newConfiguration['component'] = component; | |
456 result.addAll(_expandConfigurations(newConfiguration)); | |
457 } | |
458 return result; | |
459 } else { | 429 } else { |
460 // All components eventually go through this path, after expansion. | 430 // All runtimes eventually go through this path, after expansion. |
461 if (DumpRenderTreeUpdater.componentRequiresDRT(components)) { | 431 if (runtimes == 'drt') { |
462 DumpRenderTreeUpdater.update(); | 432 DumpRenderTreeUpdater.update(); |
463 } | 433 } |
464 } | 434 } |
465 | 435 |
466 // Adjust default timeout based on mode and component. | 436 // Adjust default timeout based on mode and runtime. |
467 if (configuration['timeout'] == -1) { | 437 if (configuration['timeout'] == -1) { |
468 var timeout = 60; | 438 var timeout = 60; |
469 switch (configuration['component']) { | 439 switch (configuration['runtime']) { |
470 case 'dartc': | 440 case 'none': // none = dartc static analysis |
ahe
2012/03/24 13:56:40
I would prefer that none does not imply dartc.
Emily Fortuna
2012/03/26 20:52:32
Done.
| |
471 case 'dartium': | 441 case 'drt': |
472 case 'frogium': | 442 case 'ie': |
473 case 'legium': | 443 case 'ff': |
474 case 'webdriver': | 444 case 'chrome': |
445 case 'safari': | |
446 case 'opera': | |
475 timeout *= 4; | 447 timeout *= 4; |
476 break; | 448 break; |
477 case 'dart2js': | 449 case 'd8': |
ahe
2012/03/24 13:56:40
It has nothing to do with d8, the problem is the c
Emily Fortuna
2012/03/26 20:52:32
Done.
| |
478 case 'frog': | |
479 if (configuration['mode'] == 'debug') { | 450 if (configuration['mode'] == 'debug') { |
480 timeout *= 8; | 451 timeout *= 8; |
481 } | 452 } |
482 if (configuration['host_checked']) { | 453 if (configuration['host_checked']) { |
483 timeout *= 16; | 454 timeout *= 16; |
484 } | 455 } |
485 break; | 456 break; |
486 default: | 457 default: |
487 if (configuration['mode'] == 'debug') { | 458 if (configuration['mode'] == 'debug') { |
488 timeout *= 2; | 459 timeout *= 2; |
489 } | 460 } |
490 break; | 461 break; |
491 } | 462 } |
492 configuration['timeout'] = timeout; | 463 configuration['timeout'] = timeout; |
493 } | 464 } |
494 | 465 |
495 return [configuration]; | 466 return [configuration]; |
496 } | 467 } |
497 | 468 |
469 /** | |
470 * Helper for _expandConfigurations. Creates a new configuration and adds it | |
471 * to a list, for use in a case when a particular configuration has multiple | |
472 * results (separated by a ','. | |
ahe
2012/03/24 13:56:40
Missing close parens.
Emily Fortuna
2012/03/26 20:52:32
Done.
| |
473 * Arguments: | |
474 * option: The particular test option we are expanding. | |
475 * configuration: The map containing all test configuration information | |
476 * specified. | |
477 */ | |
478 List<Map> _expandHelper(String option, Map configuration) { | |
479 var result = new List<Map>(); | |
480 var configs = configuration[option]; | |
481 for (var config in configs.split(',')) { | |
482 var newConfiguration = new Map.from(configuration); | |
483 newConfiguration[option] = config; | |
484 result.addAll(_expandConfigurations(newConfiguration)); | |
485 } | |
486 return result; | |
487 } | |
488 | |
498 | 489 |
499 /** | 490 /** |
500 * Print out usage information. | 491 * Print out usage information. |
501 */ | 492 */ |
502 void _printHelp() { | 493 void _printHelp() { |
503 print('usage: dart test.dart [options]\n'); | 494 print('usage: dart test.dart [options]\n'); |
504 print('Options:\n'); | 495 print('Options:\n'); |
505 for (var option in _options) { | 496 for (var option in _options) { |
506 print('${option.name}: ${option.description}.'); | 497 print('${option.name}: ${option.description}.'); |
507 for (var name in option.keys) { | 498 for (var name in option.keys) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 return option; | 534 return option; |
544 } | 535 } |
545 } | 536 } |
546 print('Unknown test option $name'); | 537 print('Unknown test option $name'); |
547 exit(1); | 538 exit(1); |
548 } | 539 } |
549 | 540 |
550 | 541 |
551 List<_TestOptionSpecification> _options; | 542 List<_TestOptionSpecification> _options; |
552 } | 543 } |
OLD | NEW |