Chromium Code Reviews| 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 ['samples', 'standalone', 'corelib', 'co19', 'language', | 8 const ['samples', 'standalone', 'corelib', 'co19', 'language', |
| 9 'isolate', 'stub-generator', 'vm']; | 9 'isolate', 'stub-generator', 'vm']; |
| 10 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 // Extract name and value for options. | 122 // Extract name and value for options. |
| 123 var arg = arguments[i]; | 123 var arg = arguments[i]; |
| 124 var name = ''; | 124 var name = ''; |
| 125 var value = ''; | 125 var value = ''; |
| 126 if (arg.startsWith('--')) { | 126 if (arg.startsWith('--')) { |
| 127 if (arg == '--help') { | 127 if (arg == '--help') { |
| 128 _printHelp(); | 128 _printHelp(); |
| 129 return null; | 129 return null; |
| 130 } | 130 } |
| 131 var split = arg.lastIndexOf('='); | 131 var split = arg.lastIndexOf('='); |
| 132 name = arg; | 132 name = arg; |
|
Bill Hesse
2011/12/02 10:21:05
Why isn't this an if ... else?
if (split == -1) {
Mads Ager (google)
2011/12/02 10:36:53
Done.
| |
| 133 value = ''; | 133 value = ''; |
| 134 if (split != -1) { | 134 if (split != -1) { |
| 135 name = arg.substring(0, split); | 135 name = arg.substring(0, split); |
| 136 value = arg.substring(split + 1, arg.length); | 136 value = arg.substring(split + 1, arg.length); |
| 137 } | 137 } |
| 138 } else if (arg.startsWith('-')) { | 138 } else if (arg.startsWith('-')) { |
| 139 if (arg == '-h') { | 139 if (arg == '-h') { |
| 140 _printHelp(); | 140 _printHelp(); |
| 141 return null; | 141 return null; |
| 142 } | 142 } |
| 143 name = arg; | 143 if (arg.length > 2) { |
| 144 if ((i + 1) >= arguments.length) { | 144 name = arg.substring(0, 2); |
| 145 print('No value supplied for option $name'); | 145 value = arg.substring(2, arg.length); |
| 146 return null; | 146 } else { |
| 147 name = arg; | |
| 148 if ((i + 1) >= arguments.length) { | |
| 149 print('No value supplied for option $name'); | |
| 150 return null; | |
| 151 } | |
| 152 value = arguments[++i]; | |
| 147 } | 153 } |
| 148 value = arguments[++i]; | |
| 149 } else { | 154 } else { |
| 150 // The argument does not start with '-' or '--' and is | 155 // The argument does not start with '-' or '--' and is |
| 151 // therefore not an option. We use it as a test selection | 156 // therefore not an option. We use it as a test selection |
| 152 // pattern. | 157 // pattern. |
| 153 var patterns = configuration['patterns']; | 158 var patterns = configuration['selectors']; |
| 154 if (patterns == null) { | 159 if (patterns == null) { |
|
Bill Hesse
2011/12/02 10:21:05
This is exactly
var patterns = configuration.putIf
Mads Ager (google)
2011/12/02 10:36:53
Done.
| |
| 155 configuration['patterns'] = patterns = new List(); | 160 configuration['selectors'] = patterns = new List(); |
| 156 } | 161 } |
| 157 patterns.add(arg); | 162 patterns.add(arg); |
| 158 continue; | 163 continue; |
| 159 } | 164 } |
| 160 // Find the option specification for the name. | 165 // Find the option specification for the name. |
| 161 var spec = _getSpecification(name); | 166 var spec = _getSpecification(name); |
| 162 if (spec == null) { | 167 if (spec == null) { |
| 163 print('Unknown test option $name'); | 168 print('Unknown test option $name'); |
| 164 return null; | 169 return null; |
| 165 } | 170 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 configuration['mode'] = 'debug,release'; | 219 configuration['mode'] = 'debug,release'; |
| 215 } | 220 } |
| 216 if (configuration['component'] == 'most') { | 221 if (configuration['component'] == 'most') { |
| 217 configuration['component'] = 'vm,dartc'; | 222 configuration['component'] = 'vm,dartc'; |
| 218 } | 223 } |
| 219 | 224 |
| 220 // Create the artificial 'unchecked' option that test status files | 225 // Create the artificial 'unchecked' option that test status files |
| 221 // expect. | 226 // expect. |
| 222 configuration['unchecked'] = !configuration['checked']; | 227 configuration['unchecked'] = !configuration['checked']; |
| 223 | 228 |
| 224 // Expand the test selectors into simple regular expressions to be | 229 // Expand the test selectors into a suite name and a simple |
| 225 // used on the full path of a test file. If no selectors are | 230 // regular expressions to be used on the full path of a test file |
| 226 // explicitly given use the default suite patterns. | 231 // in that test suite. If no selectors are explicitly given use |
| 227 List patterns = configuration['patterns']; | 232 // the default suite patterns. |
| 228 if (patterns == null) { | 233 List selectors = configuration['selectors']; |
|
Bill Hesse
2011/12/02 10:21:05
If selectors will sometimes be a Map, this should
Mads Ager (google)
2011/12/02 10:36:53
Thanks! Done.
| |
| 229 patterns = new List.from(defaultTestSelectors); | 234 if (selectors is !Map) { |
| 235 if (selectors == null) { | |
| 236 selectors = new List.from(defaultTestSelectors); | |
| 237 } | |
| 238 Map<String, RegExp> selectorMap = new Map<String, RegExp>(); | |
| 239 for (var i = 0; i < selectors.length; i++) { | |
| 240 var pattern = selectors[i]; | |
| 241 var suite = pattern; | |
| 242 var slashLocation = pattern.indexOf('/'); | |
| 243 if (slashLocation != -1) { | |
| 244 suite = pattern.substring(0, slashLocation); | |
| 245 pattern = pattern.substring(slashLocation + 1); | |
| 246 } | |
| 247 pattern = pattern.replaceAll('*', '.*'); | |
| 248 pattern = pattern.replaceAll('/', '.*'); | |
|
Bill Hesse
2011/12/02 10:21:05
At least the "replaceAll('/'..." can go inside the
Mads Ager (google)
2011/12/02 10:36:53
Yes, the first component has to be a suite name an
| |
| 249 selectorMap[suite] = new RegExp(pattern); | |
| 250 } | |
| 251 configuration['selectors'] = selectorMap; | |
| 230 } | 252 } |
| 231 for (var i = 0; i < patterns.length; i++) { | |
| 232 if (patterns[i] is RegExp) continue; | |
| 233 patterns[i] = patterns[i].replaceAll('*', '.*'); | |
| 234 patterns[i] = patterns[i].replaceAll('/', '.*'); | |
| 235 patterns[i] = new RegExp(patterns[i]); | |
| 236 } | |
| 237 configuration['patterns'] = patterns; | |
| 238 | 253 |
| 239 // Expand the architectures. | 254 // Expand the architectures. |
| 240 var archs = configuration['architecture']; | 255 var archs = configuration['architecture']; |
| 241 if (archs.contains(',')) { | 256 if (archs.contains(',')) { |
| 242 var result = new List<Map>(); | 257 var result = new List<Map>(); |
| 243 for (var arch in archs.split(',')) { | 258 for (var arch in archs.split(',')) { |
| 244 var newConfiguration = new Map.from(configuration); | 259 var newConfiguration = new Map.from(configuration); |
| 245 newConfiguration['architecture'] = arch; | 260 newConfiguration['architecture'] = arch; |
| 246 result.addAll(_expandConfigurations(newConfiguration)); | 261 result.addAll(_expandConfigurations(newConfiguration)); |
| 247 } | 262 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 if (option.keys.some((key) => key == name)) { | 356 if (option.keys.some((key) => key == name)) { |
| 342 return option; | 357 return option; |
| 343 } | 358 } |
| 344 } | 359 } |
| 345 return null; | 360 return null; |
| 346 } | 361 } |
| 347 | 362 |
| 348 | 363 |
| 349 List<_TestOptionSpecification> _options; | 364 List<_TestOptionSpecification> _options; |
| 350 } | 365 } |
| OLD | NEW |