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 #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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 [], | 158 [], |
| 159 false, | 159 false, |
| 160 'bool'), | 160 'bool'), |
| 161 new _TestOptionSpecification( | 161 new _TestOptionSpecification( |
| 162 'tasks', | 162 'tasks', |
| 163 'The number of parallel tasks to run', | 163 'The number of parallel tasks to run', |
| 164 ['-j', '--tasks'], | 164 ['-j', '--tasks'], |
| 165 [], | 165 [], |
| 166 new Platform().numberOfProcessors(), | 166 new Platform().numberOfProcessors(), |
| 167 'int'), | 167 'int'), |
| 168 new _TestOptionSpecification( | 168 new _TestOptionSpecification( |
|
Bill Hesse
2012/03/28 22:46:19
Since nobody replied to Kasper's suggestion of --s
| |
| 169 'shards', | |
| 170 'The number of instances that the tests will be sharded over', | |
| 171 ['--shards'], | |
| 172 [], | |
| 173 1, | |
| 174 'int'), | |
| 175 new _TestOptionSpecification( | |
| 176 'shard', | |
| 177 'The index of this instance when running in sharded mode', | |
| 178 ['--shard'], | |
| 179 [], | |
| 180 1, | |
| 181 'int'), | |
| 182 new _TestOptionSpecification( | |
| 169 'help', | 183 'help', |
| 170 'Print list of options', | 184 'Print list of options', |
| 171 ['-h', '--help'], | 185 ['-h', '--help'], |
| 172 [], | 186 [], |
| 173 false, | 187 false, |
| 174 'bool'), | 188 'bool'), |
| 175 new _TestOptionSpecification( | 189 new _TestOptionSpecification( |
| 176 'verbose', | 190 'verbose', |
| 177 'Verbose output', | 191 'Verbose output', |
| 178 ['-v', '--verbose'], | 192 ['-v', '--verbose'], |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 } | 363 } |
| 350 | 364 |
| 351 // Apply default values for unspecified options. | 365 // Apply default values for unspecified options. |
| 352 for (var option in _options) { | 366 for (var option in _options) { |
| 353 if (!configuration.containsKey(option.name)) { | 367 if (!configuration.containsKey(option.name)) { |
| 354 configuration[option.name] = option.defaultValue; | 368 configuration[option.name] = option.defaultValue; |
| 355 } | 369 } |
| 356 } | 370 } |
| 357 | 371 |
| 358 List<Map> expandedConfigs = _expandConfigurations(configuration); | 372 List<Map> expandedConfigs = _expandConfigurations(configuration); |
| 359 return expandedConfigs.filter(_isValidConfig); | 373 List<Map> result = expandedConfigs.filter(_isValidConfig); |
| 374 return result.isEmpty() ? null : result; | |
| 360 } | 375 } |
| 361 | 376 |
| 362 /** | 377 /** |
| 363 * Determine if a particular configuration has a valid combination of compiler | 378 * Determine if a particular configuration has a valid combination of compiler |
| 364 * and runtime elements. | 379 * and runtime elements. |
| 365 */ | 380 */ |
| 366 bool _isValidConfig(Map config) { | 381 bool _isValidConfig(Map config) { |
| 367 bool isValid = true; | 382 bool isValid = true; |
| 368 switch (config['compiler']) { | 383 switch (config['compiler']) { |
| 369 case 'frog': | 384 case 'frog': |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 385 if (!isValid) { | 400 if (!isValid) { |
| 386 print("Warning: combination of ${config['compiler']} and " + | 401 print("Warning: combination of ${config['compiler']} and " + |
| 387 "${config['runtime']} is invalid. Skipping this combination."); | 402 "${config['runtime']} is invalid. Skipping this combination."); |
| 388 } | 403 } |
| 389 if (config['runtime'] == 'ie' && | 404 if (config['runtime'] == 'ie' && |
| 390 new Platform().operatingSystem() != 'windows') { | 405 new Platform().operatingSystem() != 'windows') { |
| 391 isValid = false; | 406 isValid = false; |
| 392 print("Warning cannot run Internet Explorer on non-Windows operating" + | 407 print("Warning cannot run Internet Explorer on non-Windows operating" + |
| 393 " system."); | 408 " system."); |
| 394 } | 409 } |
| 410 if (config['shard'] < 1 || config['shard'] > config['shards']) { | |
| 411 isValid = false; | |
| 412 print("Error: shard index is ${config['shard']} out of " + | |
| 413 "${config['shards']} shards"); | |
| 414 } | |
| 395 return isValid; | 415 return isValid; |
| 396 } | 416 } |
| 397 | 417 |
| 398 /** | 418 /** |
| 399 * Recursively expand a configuration with multiple values per key | 419 * Recursively expand a configuration with multiple values per key |
| 400 * into a list of configurations with exactly one value per key. | 420 * into a list of configurations with exactly one value per key. |
| 401 */ | 421 */ |
| 402 List<Map> _expandConfigurations(Map configuration) { | 422 List<Map> _expandConfigurations(Map configuration) { |
| 403 // Expand the pseudo-values such as 'all'. | 423 // Expand the pseudo-values such as 'all'. |
| 404 if (configuration['arch'] == 'all') { | 424 if (configuration['arch'] == 'all') { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 return option; | 614 return option; |
| 595 } | 615 } |
| 596 } | 616 } |
| 597 print('Unknown test option $name'); | 617 print('Unknown test option $name'); |
| 598 exit(1); | 618 exit(1); |
| 599 } | 619 } |
| 600 | 620 |
| 601 | 621 |
| 602 List<_TestOptionSpecification> _options; | 622 List<_TestOptionSpecification> _options; |
| 603 } | 623 } |
| OLD | NEW |