Chromium Code Reviews| 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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 | 455 |
| 456 // Apply default values for unspecified options. | 456 // Apply default values for unspecified options. |
| 457 for (var option in _options) { | 457 for (var option in _options) { |
| 458 if (!configuration.containsKey(option.name)) { | 458 if (!configuration.containsKey(option.name)) { |
| 459 configuration[option.name] = option.defaultValue; | 459 configuration[option.name] = option.defaultValue; |
| 460 } | 460 } |
| 461 } | 461 } |
| 462 | 462 |
| 463 List<Map> expandedConfigs = _expandConfigurations(configuration); | 463 List<Map> expandedConfigs = _expandConfigurations(configuration); |
| 464 List<Map> result = expandedConfigs.where(_isValidConfig).toList(); | 464 List<Map> result = expandedConfigs.where(_isValidConfig).toList(); |
| 465 for (var config in result) { | |
| 466 config['_reproducing_arguments_'] = | |
|
ricow1
2013/06/20 13:54:50
why are you prefixing and postfixing it with _
kustermann
2013/06/20 14:17:24
Because all values we put in the configuration obj
| |
| 467 _constructReproducingCommandArguments(config); | |
| 468 } | |
| 465 return result.isEmpty ? null : result; | 469 return result.isEmpty ? null : result; |
| 466 } | 470 } |
| 467 | 471 |
| 472 // For printing out reproducing command lines, we don't want to add these | |
| 473 // options. | |
| 474 Set<String> _blacklistedOptions = new Set<String>.from([ | |
| 475 'progress', 'failure-summary', 'step_name', 'report', 'tasks', 'verbose', | |
| 476 'time', 'dart', 'drt', 'dartium', 'build_directory', 'append_logs', | |
| 477 'write_debug_log', 'local_ip', | |
|
ricow1
2013/06/20 13:54:50
maybe add shards and shard?
kustermann
2013/06/20 14:17:24
Good idea. Done.
| |
| 478 ]); | |
| 479 | |
| 480 List<String> _constructReproducingCommandArguments(Map config) { | |
| 481 var arguments = new List<String>(); | |
| 482 for (var configKey in config.keys) { | |
| 483 if (!_blacklistedOptions.contains(configKey)) { | |
| 484 for (var option in _options) { | |
| 485 var configValue = config[configKey]; | |
| 486 // We only include entries of [conf] if we find an option for it. | |
| 487 if (configKey == option.name && configValue != option.defaultValue) { | |
| 488 var isBooleanOption = option.type == 'bool'; | |
| 489 // Sort by length, so we get the shortest variant. | |
| 490 var possibleOptions = new List.from(option.keys); | |
| 491 possibleOptions.sort((a, b) => (a.length < b.length ? -1 : 1)); | |
| 492 var key = possibleOptions[0]; | |
| 493 if (key.startsWith('--')) { | |
| 494 // long version | |
| 495 arguments.add(key); | |
| 496 if (!isBooleanOption) { | |
| 497 arguments.add("$configValue"); | |
| 498 } | |
| 499 } else { | |
| 500 // short version | |
| 501 assert(key.startsWith('-')); | |
| 502 if (!isBooleanOption) { | |
| 503 arguments.add("$key$configValue"); | |
| 504 } else { | |
| 505 arguments.add(key); | |
| 506 } | |
| 507 } | |
| 508 } | |
| 509 } | |
| 510 } | |
| 511 } | |
| 512 return arguments; | |
| 513 } | |
| 514 | |
| 468 /** | 515 /** |
| 469 * Determine if a particular configuration has a valid combination of compiler | 516 * Determine if a particular configuration has a valid combination of compiler |
| 470 * and runtime elements. | 517 * and runtime elements. |
| 471 */ | 518 */ |
| 472 bool _isValidConfig(Map config) { | 519 bool _isValidConfig(Map config) { |
| 473 bool isValid = true; | 520 bool isValid = true; |
| 474 List<String> validRuntimes; | 521 List<String> validRuntimes; |
| 475 switch (config['compiler']) { | 522 switch (config['compiler']) { |
| 476 case 'dart2js': | 523 case 'dart2js': |
| 477 // Note: by adding 'none' as a configuration, if the user | 524 // Note: by adding 'none' as a configuration, if the user |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 739 return option; | 786 return option; |
| 740 } | 787 } |
| 741 } | 788 } |
| 742 print('Unknown test option $name'); | 789 print('Unknown test option $name'); |
| 743 exit(1); | 790 exit(1); |
| 744 } | 791 } |
| 745 | 792 |
| 746 | 793 |
| 747 List<_TestOptionSpecification> _options; | 794 List<_TestOptionSpecification> _options; |
| 748 } | 795 } |
| OLD | NEW |