| OLD | NEW |
| 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 "dart:math"; | 8 import "dart:math"; |
| 9 import "drt_updater.dart"; | 9 import "drt_updater.dart"; |
| 10 import "test_suite.dart"; | 10 import "test_suite.dart"; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 List<String> keys; | 32 List<String> keys; |
| 33 List<String> values; | 33 List<String> values; |
| 34 var defaultValue; | 34 var defaultValue; |
| 35 String type; | 35 String type; |
| 36 } | 36 } |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * Parser of test options. | 39 * Parser of test options. |
| 40 */ | 40 */ |
| 41 class TestOptionsParser { | 41 class TestOptionsParser { |
| 42 String specialCommandHelp = | |
| 43 """ | |
| 44 Special command support. Wraps the command line in | |
| 45 a special command. The special command should contain | |
| 46 an '@' character which will be replaced by the normal | |
| 47 command executable. | |
| 48 | |
| 49 For example if the normal command line that will be executed | |
| 50 is 'dart file.dart' and you specify special command | |
| 51 'python -u valgrind.py @ suffix' the final command will be | |
| 52 'python -u valgrind.py dart suffix file.dart'"""; | |
| 53 | |
| 54 /** | 42 /** |
| 55 * Creates a test options parser initialized with the known options. | 43 * Creates a test options parser initialized with the known options. |
| 56 */ | 44 */ |
| 57 TestOptionsParser() { | 45 TestOptionsParser() { |
| 58 _options = | 46 _options = |
| 59 [ new _TestOptionSpecification( | 47 [ new _TestOptionSpecification( |
| 60 'mode', | 48 'mode', |
| 61 'Mode in which to run the tests', | 49 'Mode in which to run the tests', |
| 62 ['-m', '--mode'], | 50 ['-m', '--mode'], |
| 63 ['all', 'debug', 'release'], | 51 ['all', 'debug', 'release'], |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 false, | 206 false, |
| 219 'bool'), | 207 'bool'), |
| 220 new _TestOptionSpecification( | 208 new _TestOptionSpecification( |
| 221 'list', | 209 'list', |
| 222 'List tests only, do not run them', | 210 'List tests only, do not run them', |
| 223 ['--list'], | 211 ['--list'], |
| 224 [], | 212 [], |
| 225 false, | 213 false, |
| 226 'bool'), | 214 'bool'), |
| 227 new _TestOptionSpecification( | 215 new _TestOptionSpecification( |
| 228 'valgrind', | |
| 229 'Run tests through valgrind', | |
| 230 ['--valgrind'], | |
| 231 [], | |
| 232 false, | |
| 233 'bool'), | |
| 234 new _TestOptionSpecification( | |
| 235 'special-command', | |
| 236 specialCommandHelp, | |
| 237 ['--special-command'], | |
| 238 [], | |
| 239 ''), | |
| 240 new _TestOptionSpecification( | |
| 241 'time', | 216 'time', |
| 242 'Print timing information after running tests', | 217 'Print timing information after running tests', |
| 243 ['--time'], | 218 ['--time'], |
| 244 [], | 219 [], |
| 245 false, | 220 false, |
| 246 'bool'), | 221 'bool'), |
| 247 new _TestOptionSpecification( | 222 new _TestOptionSpecification( |
| 248 'dart', | 223 'dart', |
| 249 'Path to dart executable', | 224 'Path to dart executable', |
| 250 ['--dart'], | 225 ['--dart'], |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 * into a list of configurations with exactly one value per key. | 550 * into a list of configurations with exactly one value per key. |
| 576 */ | 551 */ |
| 577 List<Map> _expandConfigurations(Map configuration) { | 552 List<Map> _expandConfigurations(Map configuration) { |
| 578 // Expand the pseudo-values such as 'all'. | 553 // Expand the pseudo-values such as 'all'. |
| 579 if (configuration['arch'] == 'all') { | 554 if (configuration['arch'] == 'all') { |
| 580 configuration['arch'] = 'ia32,x64,simarm,simmips'; | 555 configuration['arch'] = 'ia32,x64,simarm,simmips'; |
| 581 } | 556 } |
| 582 if (configuration['mode'] == 'all') { | 557 if (configuration['mode'] == 'all') { |
| 583 configuration['mode'] = 'debug,release'; | 558 configuration['mode'] = 'debug,release'; |
| 584 } | 559 } |
| 585 if (configuration['valgrind']) { | |
| 586 // TODO(ager): Get rid of this when there is only one checkout and | |
| 587 // we don't have to special case for the runtime checkout. | |
| 588 File valgrindFile = new File('runtime/tools/valgrind.py'); | |
| 589 if (!valgrindFile.existsSync()) { | |
| 590 valgrindFile = new File('../runtime/tools/valgrind.py'); | |
| 591 } | |
| 592 String valgrind = valgrindFile.fullPathSync(); | |
| 593 configuration['special-command'] = 'python -u $valgrind @'; | |
| 594 } | |
| 595 | 560 |
| 596 // Use verbose progress indication for verbose output unless buildbot | 561 // Use verbose progress indication for verbose output unless buildbot |
| 597 // progress indication is requested. | 562 // progress indication is requested. |
| 598 if (configuration['verbose'] && configuration['progress'] != 'buildbot') { | 563 if (configuration['verbose'] && configuration['progress'] != 'buildbot') { |
| 599 configuration['progress'] = 'verbose'; | 564 configuration['progress'] = 'verbose'; |
| 600 } | 565 } |
| 601 | 566 |
| 602 // Create the artificial negative options that test status files | 567 // Create the artificial negative options that test status files |
| 603 // expect. | 568 // expect. |
| 604 configuration['unchecked'] = !configuration['checked']; | 569 configuration['unchecked'] = !configuration['checked']; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 return option; | 752 return option; |
| 788 } | 753 } |
| 789 } | 754 } |
| 790 print('Unknown test option $name'); | 755 print('Unknown test option $name'); |
| 791 exit(1); | 756 exit(1); |
| 792 } | 757 } |
| 793 | 758 |
| 794 | 759 |
| 795 List<_TestOptionSpecification> _options; | 760 List<_TestOptionSpecification> _options; |
| 796 } | 761 } |
| OLD | NEW |