| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 } | 361 } |
| 362 // Parse the value for the option. | 362 // Parse the value for the option. |
| 363 if (spec.type == 'bool') { | 363 if (spec.type == 'bool') { |
| 364 if (!value.isEmpty) { | 364 if (!value.isEmpty) { |
| 365 print('No value expected for bool option $name'); | 365 print('No value expected for bool option $name'); |
| 366 exit(1); | 366 exit(1); |
| 367 } | 367 } |
| 368 configuration[spec.name] = true; | 368 configuration[spec.name] = true; |
| 369 } else if (spec.type == 'int') { | 369 } else if (spec.type == 'int') { |
| 370 try { | 370 try { |
| 371 configuration[spec.name] = parseInt(value); | 371 configuration[spec.name] = int.parse(value); |
| 372 } catch (e) { | 372 } catch (e) { |
| 373 print('Integer value expected for int option $name'); | 373 print('Integer value expected for int option $name'); |
| 374 exit(1); | 374 exit(1); |
| 375 } | 375 } |
| 376 } else { | 376 } else { |
| 377 assert(spec.type == 'string'); | 377 assert(spec.type == 'string'); |
| 378 if (!spec.values.isEmpty) { | 378 if (!spec.values.isEmpty) { |
| 379 for (var v in value.split(',')) { | 379 for (var v in value.split(',')) { |
| 380 if (spec.values.lastIndexOf(v) == -1) { | 380 if (spec.values.lastIndexOf(v) == -1) { |
| 381 print('Unknown value ($v) for option $name'); | 381 print('Unknown value ($v) for option $name'); |
| 382 exit(1); | 382 exit(1); |
| 383 } | 383 } |
| 384 } | 384 } |
| 385 } | 385 } |
| 386 configuration[spec.name] = value; | 386 configuration[spec.name] = value; |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 390 // Apply default values for unspecified options. | 390 // Apply default values for unspecified options. |
| 391 for (var option in _options) { | 391 for (var option in _options) { |
| 392 if (!configuration.containsKey(option.name)) { | 392 if (!configuration.containsKey(option.name)) { |
| 393 configuration[option.name] = option.defaultValue; | 393 configuration[option.name] = option.defaultValue; |
| 394 } | 394 } |
| 395 } | 395 } |
| 396 | 396 |
| 397 List<Map> expandedConfigs = _expandConfigurations(configuration); | 397 List<Map> expandedConfigs = _expandConfigurations(configuration); |
| 398 List<Map> result = expandedConfigs.filter(_isValidConfig); | 398 List<Map> result = expandedConfigs.where(_isValidConfig).toList(); |
| 399 return result.isEmpty ? null : result; | 399 return result.isEmpty ? null : result; |
| 400 } | 400 } |
| 401 | 401 |
| 402 /** | 402 /** |
| 403 * Determine if a particular configuration has a valid combination of compiler | 403 * Determine if a particular configuration has a valid combination of compiler |
| 404 * and runtime elements. | 404 * and runtime elements. |
| 405 */ | 405 */ |
| 406 bool _isValidConfig(Map config) { | 406 bool _isValidConfig(Map config) { |
| 407 bool isValid = true; | 407 bool isValid = true; |
| 408 List<String> validRuntimes; | 408 List<String> validRuntimes; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 print(''); | 658 print(''); |
| 659 } | 659 } |
| 660 } | 660 } |
| 661 | 661 |
| 662 | 662 |
| 663 /** | 663 /** |
| 664 * Find the test option specification for a given option key. | 664 * Find the test option specification for a given option key. |
| 665 */ | 665 */ |
| 666 _TestOptionSpecification _getSpecification(String name) { | 666 _TestOptionSpecification _getSpecification(String name) { |
| 667 for (var option in _options) { | 667 for (var option in _options) { |
| 668 if (option.keys.some((key) => key == name)) { | 668 if (option.keys.any((key) => key == name)) { |
| 669 return option; | 669 return option; |
| 670 } | 670 } |
| 671 } | 671 } |
| 672 print('Unknown test option $name'); | 672 print('Unknown test option $name'); |
| 673 exit(1); | 673 exit(1); |
| 674 } | 674 } |
| 675 | 675 |
| 676 | 676 |
| 677 List<_TestOptionSpecification> _options; | 677 List<_TestOptionSpecification> _options; |
| 678 } | 678 } |
| OLD | NEW |