| 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 if (split == -1) { |
| 133 value = ''; | 133 name = arg; |
| 134 if (split != -1) { | 134 value = ''; |
| 135 } else { |
| 135 name = arg.substring(0, split); | 136 name = arg.substring(0, split); |
| 136 value = arg.substring(split + 1, arg.length); | 137 value = arg.substring(split + 1, arg.length); |
| 137 } | 138 } |
| 138 } else if (arg.startsWith('-')) { | 139 } else if (arg.startsWith('-')) { |
| 139 if (arg == '-h') { | 140 if (arg == '-h') { |
| 140 _printHelp(); | 141 _printHelp(); |
| 141 return null; | 142 return null; |
| 142 } | 143 } |
| 143 name = arg; | 144 if (arg.length > 2) { |
| 144 if ((i + 1) >= arguments.length) { | 145 name = arg.substring(0, 2); |
| 145 print('No value supplied for option $name'); | 146 value = arg.substring(2, arg.length); |
| 146 return null; | 147 } else { |
| 148 name = arg; |
| 149 if ((i + 1) >= arguments.length) { |
| 150 print('No value supplied for option $name'); |
| 151 return null; |
| 152 } |
| 153 value = arguments[++i]; |
| 147 } | 154 } |
| 148 value = arguments[++i]; | |
| 149 } else { | 155 } else { |
| 150 // The argument does not start with '-' or '--' and is | 156 // The argument does not start with '-' or '--' and is |
| 151 // therefore not an option. We use it as a test selection | 157 // therefore not an option. We use it as a test selection |
| 152 // pattern. | 158 // pattern. |
| 153 var patterns = configuration['patterns']; | 159 configuration.putIfAbsent('selectors', () => []); |
| 154 if (patterns == null) { | 160 var patterns = configuration['selectors']; |
| 155 configuration['patterns'] = patterns = new List(); | |
| 156 } | |
| 157 patterns.add(arg); | 161 patterns.add(arg); |
| 158 continue; | 162 continue; |
| 159 } | 163 } |
| 160 // Find the option specification for the name. | 164 // Find the option specification for the name. |
| 161 var spec = _getSpecification(name); | 165 var spec = _getSpecification(name); |
| 162 if (spec == null) { | 166 if (spec == null) { |
| 163 print('Unknown test option $name'); | 167 print('Unknown test option $name'); |
| 164 return null; | 168 return null; |
| 165 } | 169 } |
| 166 // Parse the value for the option. | 170 // Parse the value for the option. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 configuration['mode'] = 'debug,release'; | 218 configuration['mode'] = 'debug,release'; |
| 215 } | 219 } |
| 216 if (configuration['component'] == 'most') { | 220 if (configuration['component'] == 'most') { |
| 217 configuration['component'] = 'vm,dartc'; | 221 configuration['component'] = 'vm,dartc'; |
| 218 } | 222 } |
| 219 | 223 |
| 220 // Create the artificial 'unchecked' option that test status files | 224 // Create the artificial 'unchecked' option that test status files |
| 221 // expect. | 225 // expect. |
| 222 configuration['unchecked'] = !configuration['checked']; | 226 configuration['unchecked'] = !configuration['checked']; |
| 223 | 227 |
| 224 // Expand the test selectors into simple regular expressions to be | 228 // 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 | 229 // regular expressions to be used on the full path of a test file |
| 226 // explicitly given use the default suite patterns. | 230 // in that test suite. If no selectors are explicitly given use |
| 227 List patterns = configuration['patterns']; | 231 // the default suite patterns. |
| 228 if (patterns == null) { | 232 var selectors = configuration['selectors']; |
| 229 patterns = new List.from(defaultTestSelectors); | 233 if (selectors is !Map) { |
| 234 if (selectors == null) { |
| 235 selectors = new List.from(defaultTestSelectors); |
| 236 } |
| 237 Map<String, RegExp> selectorMap = new Map<String, RegExp>(); |
| 238 for (var i = 0; i < selectors.length; i++) { |
| 239 var pattern = selectors[i]; |
| 240 var suite = pattern; |
| 241 var slashLocation = pattern.indexOf('/'); |
| 242 if (slashLocation != -1) { |
| 243 suite = pattern.substring(0, slashLocation); |
| 244 pattern = pattern.substring(slashLocation + 1); |
| 245 } |
| 246 pattern = pattern.replaceAll('*', '.*'); |
| 247 pattern = pattern.replaceAll('/', '.*'); |
| 248 if (selectorMap.containsKey(suite)) { |
| 249 print("Warning: selector '$suite/$pattern' overrides " + |
| 250 "previous selector for suite '$suite'"); |
| 251 } |
| 252 selectorMap[suite] = new RegExp(pattern); |
| 253 } |
| 254 configuration['selectors'] = selectorMap; |
| 230 } | 255 } |
| 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 | 256 |
| 239 // Expand the architectures. | 257 // Expand the architectures. |
| 240 var archs = configuration['architecture']; | 258 var archs = configuration['architecture']; |
| 241 if (archs.contains(',')) { | 259 if (archs.contains(',')) { |
| 242 var result = new List<Map>(); | 260 var result = new List<Map>(); |
| 243 for (var arch in archs.split(',')) { | 261 for (var arch in archs.split(',')) { |
| 244 var newConfiguration = new Map.from(configuration); | 262 var newConfiguration = new Map.from(configuration); |
| 245 newConfiguration['architecture'] = arch; | 263 newConfiguration['architecture'] = arch; |
| 246 result.addAll(_expandConfigurations(newConfiguration)); | 264 result.addAll(_expandConfigurations(newConfiguration)); |
| 247 } | 265 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 if (option.keys.some((key) => key == name)) { | 359 if (option.keys.some((key) => key == name)) { |
| 342 return option; | 360 return option; |
| 343 } | 361 } |
| 344 } | 362 } |
| 345 return null; | 363 return null; |
| 346 } | 364 } |
| 347 | 365 |
| 348 | 366 |
| 349 List<_TestOptionSpecification> _options; | 367 List<_TestOptionSpecification> _options; |
| 350 } | 368 } |
| OLD | NEW |