| 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 List<String> defaultTestSelectors = | 7 List<String> defaultTestSelectors = |
| 8 const ['dartc', 'samples', 'standalone', 'corelib', 'co19', 'language', | 8 const ['dartc', 'samples', 'standalone', 'corelib', 'co19', 'language', |
| 9 'isolate', 'stub-generator', 'vm']; | 9 'isolate', 'stub-generator', 'vm']; |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 List<String> values; | 27 List<String> values; |
| 28 var defaultValue; | 28 var defaultValue; |
| 29 String type; | 29 String type; |
| 30 } | 30 } |
| 31 | 31 |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * Parser of test options. | 34 * Parser of test options. |
| 35 */ | 35 */ |
| 36 class TestOptionsParser { | 36 class TestOptionsParser { |
| 37 String specialCommandHelp = |
| 38 """ |
| 39 Special command support. Wraps the command line in |
| 40 a special command. The special command should contain |
| 41 an '@' character which will be replaced by the normal |
| 42 command. |
| 43 |
| 44 For example if the normal command that will be executed |
| 45 is 'dart file.dart' and you specify special command |
| 46 'python -u valgrind.py @ suffix' the final command will be |
| 47 'python -u valgrind.py dart file.dart suffix'"""; |
| 48 |
| 37 /** | 49 /** |
| 38 * Creates a test options parser initialized with the known options. | 50 * Creates a test options parser initialized with the known options. |
| 39 */ | 51 */ |
| 40 TestOptionsParser() { | 52 TestOptionsParser() { |
| 41 _options = | 53 _options = |
| 42 [ new _TestOptionSpecification( | 54 [ new _TestOptionSpecification( |
| 43 'mode', | 55 'mode', |
| 44 'Mode in which to run the tests', | 56 'Mode in which to run the tests', |
| 45 ['-m', '--mode'], | 57 ['-m', '--mode'], |
| 46 ['all', 'debug', 'release'], | 58 ['all', 'debug', 'release'], |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 -1, | 90 -1, |
| 79 'int'), | 91 'int'), |
| 80 new _TestOptionSpecification( | 92 new _TestOptionSpecification( |
| 81 'progress', | 93 'progress', |
| 82 'Progress indication mode', | 94 'Progress indication mode', |
| 83 ['-p', '--progress'], | 95 ['-p', '--progress'], |
| 84 ['compact', 'color', 'line', 'verbose', 'status', 'buildbot'], | 96 ['compact', 'color', 'line', 'verbose', 'status', 'buildbot'], |
| 85 'compact'), | 97 'compact'), |
| 86 new _TestOptionSpecification( | 98 new _TestOptionSpecification( |
| 87 'report', | 99 'report', |
| 88 'Print a summary report of the number of tests, by expectation.', | 100 'Print a summary report of the number of tests, by expectation', |
| 89 ['--report'], | 101 ['--report'], |
| 90 [], | 102 [], |
| 91 false, | 103 false, |
| 92 'bool'), | 104 'bool'), |
| 93 new _TestOptionSpecification( | 105 new _TestOptionSpecification( |
| 94 'tasks', | 106 'tasks', |
| 95 'The number of parallel tasks to run', | 107 'The number of parallel tasks to run', |
| 96 ['-j', '--tasks'], | 108 ['-j', '--tasks'], |
| 97 [], | 109 [], |
| 98 new Platform().numberOfProcessors(), | 110 new Platform().numberOfProcessors(), |
| 99 'int'), | 111 'int'), |
| 100 new _TestOptionSpecification( | 112 new _TestOptionSpecification( |
| 101 'help', | 113 'help', |
| 102 'Print list of options', | 114 'Print list of options', |
| 103 ['-h', '--help'], | 115 ['-h', '--help'], |
| 104 [], | 116 [], |
| 105 false, | 117 false, |
| 106 'bool'), | 118 'bool'), |
| 107 new _TestOptionSpecification( | 119 new _TestOptionSpecification( |
| 108 'verbose', | 120 'verbose', |
| 109 'Verbose output', | 121 'Verbose output', |
| 110 ['-v', '--verbose'], | 122 ['-v', '--verbose'], |
| 111 [], | 123 [], |
| 112 false, | 124 false, |
| 113 'bool')]; | 125 'bool'), |
| 126 new _TestOptionSpecification( |
| 127 'valgrind', |
| 128 'Run tests through valgrind', |
| 129 ['--valgrind'], |
| 130 [], |
| 131 false, |
| 132 'bool'), |
| 133 new _TestOptionSpecification( |
| 134 'special-command', |
| 135 specialCommandHelp, |
| 136 ['--special-command'], |
| 137 [], |
| 138 '')]; |
| 114 } | 139 } |
| 115 | 140 |
| 116 | 141 |
| 117 /** | 142 /** |
| 118 * Parse a list of strings as test options. | 143 * Parse a list of strings as test options. |
| 119 * | 144 * |
| 120 * Returns a list of configurations in which to run the | 145 * Returns a list of configurations in which to run the |
| 121 * tests. Configurations are maps mapping from option keys to | 146 * tests. Configurations are maps mapping from option keys to |
| 122 * values. When encountering the first non-option string, the rest | 147 * values. When encountering the first non-option string, the rest |
| 123 * of the arguments are stored in the returned Map under the 'rest' | 148 * of the arguments are stored in the returned Map under the 'rest' |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // Expand the pseudo-values such as 'all'. | 254 // Expand the pseudo-values such as 'all'. |
| 230 if (configuration['arch'] == 'all') { | 255 if (configuration['arch'] == 'all') { |
| 231 configuration['arch'] = 'ia32,x64,simarm'; | 256 configuration['arch'] = 'ia32,x64,simarm'; |
| 232 } | 257 } |
| 233 if (configuration['mode'] == 'all') { | 258 if (configuration['mode'] == 'all') { |
| 234 configuration['mode'] = 'debug,release'; | 259 configuration['mode'] = 'debug,release'; |
| 235 } | 260 } |
| 236 if (configuration['component'] == 'most') { | 261 if (configuration['component'] == 'most') { |
| 237 configuration['component'] = 'vm,dartc'; | 262 configuration['component'] = 'vm,dartc'; |
| 238 } | 263 } |
| 264 if (configuration['valgrind']) { |
| 265 // TODO(ager): Get rid of this when there is only one checkout and |
| 266 // we don't have to special case for the runtime checkout. |
| 267 File valgrindFile = new File('runtime/tools/valgrind.py'); |
| 268 if (!valgrindFile.existsSync()) { |
| 269 valgrindFile = new File('../runtime/tools/valgrind.py'); |
| 270 } |
| 271 String valgrind = valgrindFile.fullPathSync(); |
| 272 configuration['special-command'] = 'python -u $valgrind @'; |
| 273 } |
| 239 | 274 |
| 240 // Use verbose progress indication for verbose output. | 275 // Use verbose progress indication for verbose output. |
| 241 if (configuration['verbose']) { | 276 if (configuration['verbose']) { |
| 242 configuration['progress'] = 'verbose'; | 277 configuration['progress'] = 'verbose'; |
| 243 } | 278 } |
| 244 | 279 |
| 245 // Create the artificial 'unchecked' option that test status files | 280 // Create the artificial 'unchecked' option that test status files |
| 246 // expect. | 281 // expect. |
| 247 configuration['unchecked'] = !configuration['checked']; | 282 configuration['unchecked'] = !configuration['checked']; |
| 248 | 283 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 if (option.keys.some((key) => key == name)) { | 417 if (option.keys.some((key) => key == name)) { |
| 383 return option; | 418 return option; |
| 384 } | 419 } |
| 385 } | 420 } |
| 386 return null; | 421 return null; |
| 387 } | 422 } |
| 388 | 423 |
| 389 | 424 |
| 390 List<_TestOptionSpecification> _options; | 425 List<_TestOptionSpecification> _options; |
| 391 } | 426 } |
| OLD | NEW |