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). |
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. | 75 |
79 | 76 frogsh: Compile dart code to JavaScript by running the frog compiler on |
80 dartium: Run dart code in a type="application/dart" script tag in a | 77 node.js, and run the resulting JavaScript on the same instance of |
81 dartium build of DumpRenderTree. | 78 node.js.''', |
Siggi Cherem (dart-lang)
2012/03/26 22:28:40
since compiler and runtime have limited combinatio
| |
82 | 79 ['-c', '--compiler'], |
83 frogium: Compile dart code by running frog on the standalone dart vm, | 80 ['none', 'frog', 'dart2js', 'dartc', 'frogsh'], |
84 and run the resulting javascript in a javascript script tag in | 81 'none'), |
85 a dartium build of DumpRenderTree. | 82 new _TestOptionSpecification( |
86 | 83 'runtime', |
87 legium: Compile dart code by running dart2js on the standalone dart | 84 '''Where the tests should be run. |
88 vm, and run the resulting javascript in a javascript script tag | 85 vm: Run Dart code on the standalone dart vm. |
89 in a dartium build of DumpRenderTree. | 86 |
90 | 87 d8: Run JavaScript from the command line using v8. |
91 webdriver: Compile dart code by running frog on the standalone dart vm, | 88 |
92 and then run the resulting javascript in the browser that is specified | 89 drt: Run Dart or JavaScript in the headless version of Chrome, |
93 by the --browser switch (e.g. chrome, safari, ff, etc.). | 90 DumpRenderTree. |
94 | 91 |
95 dartc: Run dart code through the dartc static analyzer (does not | 92 ff or firefox: Run JavaScript in Firefox. |
96 execute dart code). | 93 |
97 ''', | 94 chrome: Run JavaScript in Chrome. |
98 ['-c', '--component'], | 95 |
99 ['most', 'vm', 'frog', 'dart2js', 'frogsh', 'dartium', 'frogium', | 96 safari: Run JavaScript in Safari. |
100 'legium', 'webdriver', 'dartc'], | 97 |
98 ie: Run JavaScript in Internet Explorer. | |
99 | |
100 opera: Run JavaScript in Opera. | |
101 | |
102 none: No runtime, compile only (for example, used for dartc static analysis | |
103 tests).''', | |
104 ['-r', '--runtime'], | |
105 ['vm', 'd8', 'drt', 'ff', 'firefox', 'chrome', | |
106 'safari', 'ie', 'opera', 'none'], | |
101 'vm'), | 107 'vm'), |
102 new _TestOptionSpecification( | 108 new _TestOptionSpecification( |
103 'arch', | 109 'arch', |
104 'The architecture to run tests for', | 110 'The architecture to run tests for', |
105 ['-a', '--arch'], | 111 ['-a', '--arch'], |
106 ['all', 'ia32', 'x64', 'simarm'], | 112 ['all', 'ia32', 'x64', 'simarm'], |
107 'ia32'), | 113 'ia32'), |
108 new _TestOptionSpecification( | 114 new _TestOptionSpecification( |
109 'system', | 115 'system', |
110 'The operating system to run tests on', | 116 'The operating system to run tests on', |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 [], | 201 [], |
196 ''), | 202 ''), |
197 new _TestOptionSpecification( | 203 new _TestOptionSpecification( |
198 'time', | 204 'time', |
199 'Print timing information after running tests', | 205 'Print timing information after running tests', |
200 ['--time'], | 206 ['--time'], |
201 [], | 207 [], |
202 false, | 208 false, |
203 'bool'), | 209 'bool'), |
204 new _TestOptionSpecification( | 210 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', | 211 'drt', |
218 'Path to DumpRenderTree executable', | 212 'Path to DumpRenderTree executable', |
219 ['--drt'], | 213 ['--drt'], |
220 [], | 214 [], |
221 ''), | 215 ''), |
222 new _TestOptionSpecification( | 216 new _TestOptionSpecification( |
223 'froglib', | |
224 'Path to frog library', | |
225 ['--froglib'], | |
226 [], | |
227 ''), | |
228 new _TestOptionSpecification( | |
229 'noBatch', | 217 'noBatch', |
230 'Do not run browser tests in batch mode', | 218 'Do not run browser tests in batch mode', |
231 ['-n', '--nobatch'], | 219 ['-n', '--nobatch'], |
232 [], | 220 [], |
233 false, | 221 false, |
234 'bool')]; | 222 'bool')]; |
235 } | 223 } |
236 | 224 |
237 | 225 |
238 /** | 226 /** |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 } | 330 } |
343 } | 331 } |
344 | 332 |
345 // Apply default values for unspecified options. | 333 // Apply default values for unspecified options. |
346 for (var option in _options) { | 334 for (var option in _options) { |
347 if (!configuration.containsKey(option.name)) { | 335 if (!configuration.containsKey(option.name)) { |
348 configuration[option.name] = option.defaultValue; | 336 configuration[option.name] = option.defaultValue; |
349 } | 337 } |
350 } | 338 } |
351 | 339 |
352 return _expandConfigurations(configuration); | 340 List<Map> expandedConfigs = _expandConfigurations(configuration); |
341 return expandedConfigs.filter(_isValidConfig); | |
353 } | 342 } |
354 | 343 |
344 /** | |
345 * Loop through the set of configurations that we will be testing. Return a | |
Siggi Cherem (dart-lang)
2012/03/26 22:28:40
rewrite comment to talk about a single config? (th
Emily Fortuna
2012/03/26 23:31:32
Done.
| |
346 * list that contains the valid set of configurations that will actually be | |
347 * tested. | |
348 */ | |
349 bool _isValidConfig(Map config) { | |
350 bool isValid = true; | |
351 switch (config['compiler']) { | |
352 case 'frog': | |
353 case 'dart2js': | |
354 case 'frogsh': | |
355 isValid = (const ['d8', 'drt', 'ff', 'chrome', 'safari', 'ie', | |
Siggi Cherem (dart-lang)
2012/03/26 22:48:04
btw - is the current os/system available in [confi
| |
356 'opera', 'none']).indexOf(config['runtime']) >= 0; | |
Siggi Cherem (dart-lang)
2012/03/26 22:28:40
I thought [none] wasn't valid here. I guess if you
Siggi Cherem (dart-lang)
2012/03/26 22:48:04
BTW - One disadvantage of adding 'none' here is th
Emily Fortuna
2012/03/26 23:31:32
I added this at Peter's request. Peter wanted to a
Emily Fortuna
2012/03/26 23:31:32
Added a comment.
| |
357 break; | |
358 case 'dartc': | |
359 isValid = config['runtime'] == 'none'; | |
360 break; | |
361 case 'none': | |
362 isValid = (const ['vm', 'drt']).indexOf(config['runtime']) >= 0; | |
363 } | |
364 if (!isValid) { | |
365 print("Warning: combination of ${config['compiler']} and " + | |
366 "${config['runtime']} is invalid. Skipping this combination."); | |
367 } | |
368 return isValid; | |
369 } | |
355 | 370 |
356 /** | 371 /** |
357 * Recursively expand a configuration with multiple values per key | 372 * Recursively expand a configuration with multiple values per key |
358 * into a list of configurations with exactly one value per key. | 373 * into a list of configurations with exactly one value per key. |
359 */ | 374 */ |
360 List<Map> _expandConfigurations(Map configuration) { | 375 List<Map> _expandConfigurations(Map configuration) { |
361 // Expand the pseudo-values such as 'all'. | 376 // Expand the pseudo-values such as 'all'. |
362 if (configuration['arch'] == 'all') { | 377 if (configuration['arch'] == 'all') { |
363 configuration['arch'] = 'ia32,x64'; | 378 configuration['arch'] = 'ia32,x64'; |
364 } | 379 } |
365 if (configuration['mode'] == 'all') { | 380 if (configuration['mode'] == 'all') { |
366 configuration['mode'] = 'debug,release'; | 381 configuration['mode'] = 'debug,release'; |
367 } | 382 } |
368 if (configuration['component'] == 'most') { | |
369 configuration['component'] = 'vm,dartc'; | |
370 } | |
371 if (configuration['valgrind']) { | 383 if (configuration['valgrind']) { |
372 // TODO(ager): Get rid of this when there is only one checkout and | 384 // 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. | 385 // we don't have to special case for the runtime checkout. |
374 File valgrindFile = new File('runtime/tools/valgrind.py'); | 386 File valgrindFile = new File('runtime/tools/valgrind.py'); |
375 if (!valgrindFile.existsSync()) { | 387 if (!valgrindFile.existsSync()) { |
376 valgrindFile = new File('../runtime/tools/valgrind.py'); | 388 valgrindFile = new File('../runtime/tools/valgrind.py'); |
377 } | 389 } |
378 String valgrind = valgrindFile.fullPathSync(); | 390 String valgrind = valgrindFile.fullPathSync(); |
379 configuration['special-command'] = 'python -u $valgrind @'; | 391 configuration['special-command'] = 'python -u $valgrind @'; |
380 } | 392 } |
381 | 393 |
382 // Use verbose progress indication for verbose output unless buildbot | 394 // Use verbose progress indication for verbose output unless buildbot |
383 // progress indication is requested. | 395 // progress indication is requested. |
384 if (configuration['verbose'] && configuration['progress'] != 'buildbot') { | 396 if (configuration['verbose'] && configuration['progress'] != 'buildbot') { |
385 configuration['progress'] = 'verbose'; | 397 configuration['progress'] = 'verbose'; |
386 } | 398 } |
387 | 399 |
388 // Create the artificial 'unchecked' options that test status files | 400 // Create the artificial 'unchecked' options that test status files |
389 // expect. | 401 // expect. |
390 configuration['unchecked'] = !configuration['checked']; | 402 configuration['unchecked'] = !configuration['checked']; |
391 configuration['host_unchecked'] = !configuration['host_checked']; | 403 configuration['host_unchecked'] = !configuration['host_checked']; |
392 | 404 |
405 if (configuration['runtime'] == 'firefox') { | |
406 configuration['runtime'] == 'ff'; | |
407 } | |
408 | |
393 // Expand the test selectors into a suite name and a simple | 409 // 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 | 410 // 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 | 411 // in that test suite. If no selectors are explicitly given use |
396 // the default suite patterns. | 412 // the default suite patterns. |
397 var selectors = configuration['selectors']; | 413 var selectors = configuration['selectors']; |
398 if (selectors is !Map) { | 414 if (selectors is !Map) { |
399 if (selectors == null) { | 415 if (selectors == null) { |
400 selectors = new List.from(defaultTestSelectors); | 416 selectors = new List.from(defaultTestSelectors); |
401 } | 417 } |
402 Map<String, RegExp> selectorMap = new Map<String, RegExp>(); | 418 Map<String, RegExp> selectorMap = new Map<String, RegExp>(); |
(...skipping 13 matching lines...) Expand all Loading... | |
416 print("Error: '$suite/$pattern'. Only one test selection" + | 432 print("Error: '$suite/$pattern'. Only one test selection" + |
417 " pattern is allowed to start with '$suite/'"); | 433 " pattern is allowed to start with '$suite/'"); |
418 exit(1); | 434 exit(1); |
419 } | 435 } |
420 selectorMap[suite] = new RegExp(pattern); | 436 selectorMap[suite] = new RegExp(pattern); |
421 } | 437 } |
422 configuration['selectors'] = selectorMap; | 438 configuration['selectors'] = selectorMap; |
423 } | 439 } |
424 | 440 |
425 // Expand the architectures. | 441 // Expand the architectures. |
426 var archs = configuration['arch']; | 442 if (configuration['arch'].contains(',')) { |
427 if (archs.contains(',')) { | 443 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 } | 444 } |
436 | 445 |
437 // Expand modes. | 446 // Expand modes. |
438 var modes = configuration['mode']; | 447 if (configuration['mode'].contains(',')) { |
439 if (modes.contains(',')) { | 448 return _expandHelper('mode', configuration); |
440 var result = new List<Map>(); | 449 } |
441 for (var mode in modes.split(',')) { | 450 |
442 var newConfiguration = new Map.from(configuration); | 451 // Expand compilers. |
443 newConfiguration['mode'] = mode; | 452 if (configuration['compiler'].contains(',')) { |
444 result.addAll(_expandConfigurations(newConfiguration)); | 453 return _expandHelper('compiler', configuration); |
445 } | |
446 return result; | |
447 } | 454 } |
448 | 455 |
449 // Expand components. | 456 // Expand runtimes. |
450 var components = configuration['component']; | 457 var runtimes = configuration['runtime']; |
451 if (components.contains(',')) { | 458 if (runtimes.contains(',')) { |
452 var result = new List<Map>(); | 459 return _expandHelper('runtime', configuration); |
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 { | 460 } else { |
460 // All components eventually go through this path, after expansion. | 461 // All runtimes eventually go through this path, after expansion. |
461 if (DumpRenderTreeUpdater.componentRequiresDRT(components)) { | 462 if (runtimes == 'drt') { |
462 DumpRenderTreeUpdater.update(); | 463 DumpRenderTreeUpdater.update(); |
463 } | 464 } |
464 } | 465 } |
465 | 466 |
466 // Adjust default timeout based on mode and component. | 467 // Adjust default timeout based on mode, compiler, and sometimes runtime. |
467 if (configuration['timeout'] == -1) { | 468 if (configuration['timeout'] == -1) { |
468 var timeout = 60; | 469 var timeout = 60; |
469 switch (configuration['component']) { | 470 switch (configuration['compiler']) { |
470 case 'dartc': | 471 case 'dartc': |
471 case 'dartium': | |
472 case 'frogium': | |
473 case 'legium': | |
474 case 'webdriver': | |
475 timeout *= 4; | 472 timeout *= 4; |
476 break; | 473 break; |
477 case 'dart2js': | 474 case 'dart2js': |
478 case 'frog': | 475 case 'frog': |
479 if (configuration['mode'] == 'debug') { | 476 if (configuration['mode'] == 'debug') { |
480 timeout *= 8; | 477 timeout *= 8; |
481 } | 478 } |
482 if (configuration['host_checked']) { | 479 if (configuration['host_checked']) { |
483 timeout *= 16; | 480 timeout *= 16; |
484 } | 481 } |
482 if ((const ['ie', 'ff', 'chrome', 'safari', | |
483 'opera']).indexOf(configuration['runtime']) >= 0) { | |
484 timeout *= 4; // Allow additional time for browser testing to run. | |
485 } | |
485 break; | 486 break; |
486 default: | 487 default: |
487 if (configuration['mode'] == 'debug') { | 488 if (configuration['mode'] == 'debug') { |
488 timeout *= 2; | 489 timeout *= 2; |
489 } | 490 } |
491 if (configuration['runtime'] == 'drt') { | |
492 timeout *= 4; | |
493 } | |
490 break; | 494 break; |
491 } | 495 } |
492 configuration['timeout'] = timeout; | 496 configuration['timeout'] = timeout; |
493 } | 497 } |
494 | 498 |
495 return [configuration]; | 499 return [configuration]; |
496 } | 500 } |
497 | 501 |
502 /** | |
503 * Helper for _expandConfigurations. Creates a new configuration and adds it | |
504 * to a list, for use in a case when a particular configuration has multiple | |
505 * results (separated by a ','). | |
506 * Arguments: | |
507 * option: The particular test option we are expanding. | |
508 * configuration: The map containing all test configuration information | |
509 * specified. | |
510 */ | |
511 List<Map> _expandHelper(String option, Map configuration) { | |
512 var result = new List<Map>(); | |
513 var configs = configuration[option]; | |
514 for (var config in configs.split(',')) { | |
515 var newConfiguration = new Map.from(configuration); | |
516 newConfiguration[option] = config; | |
517 result.addAll(_expandConfigurations(newConfiguration)); | |
518 } | |
519 return result; | |
520 } | |
521 | |
498 | 522 |
499 /** | 523 /** |
500 * Print out usage information. | 524 * Print out usage information. |
501 */ | 525 */ |
502 void _printHelp() { | 526 void _printHelp() { |
503 print('usage: dart test.dart [options]\n'); | 527 print('usage: dart test.dart [options]\n'); |
504 print('Options:\n'); | 528 print('Options:\n'); |
505 for (var option in _options) { | 529 for (var option in _options) { |
506 print('${option.name}: ${option.description}.'); | 530 print('${option.name}: ${option.description}.'); |
507 for (var name in option.keys) { | 531 for (var name in option.keys) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 return option; | 567 return option; |
544 } | 568 } |
545 } | 569 } |
546 print('Unknown test option $name'); | 570 print('Unknown test option $name'); |
547 exit(1); | 571 exit(1); |
548 } | 572 } |
549 | 573 |
550 | 574 |
551 List<_TestOptionSpecification> _options; | 575 List<_TestOptionSpecification> _options; |
552 } | 576 } |
OLD | NEW |