| OLD | NEW |
| 1 // Copyright (c) 2012, 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"; |
| 11 | 11 |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 * Print out usage information. | 648 * Print out usage information. |
| 649 */ | 649 */ |
| 650 void _printHelp() { | 650 void _printHelp() { |
| 651 print('usage: dart test.dart [options]\n'); | 651 print('usage: dart test.dart [options]\n'); |
| 652 print('Options:\n'); | 652 print('Options:\n'); |
| 653 for (var option in _options) { | 653 for (var option in _options) { |
| 654 print('${option.name}: ${option.description}.'); | 654 print('${option.name}: ${option.description}.'); |
| 655 for (var name in option.keys) { | 655 for (var name in option.keys) { |
| 656 assert(name.startsWith('-')); | 656 assert(name.startsWith('-')); |
| 657 var buffer = new StringBuffer();; | 657 var buffer = new StringBuffer();; |
| 658 buffer.add(name); | 658 buffer.write(name); |
| 659 if (option.type == 'bool') { | 659 if (option.type == 'bool') { |
| 660 assert(option.values.isEmpty); | 660 assert(option.values.isEmpty); |
| 661 } else { | 661 } else { |
| 662 buffer.add(name.startsWith('--') ? '=' : ' '); | 662 buffer.write(name.startsWith('--') ? '=' : ' '); |
| 663 if (option.type == 'int') { | 663 if (option.type == 'int') { |
| 664 assert(option.values.isEmpty); | 664 assert(option.values.isEmpty); |
| 665 buffer.add('n (default: ${option.defaultValue})'); | 665 buffer.write('n (default: ${option.defaultValue})'); |
| 666 } else { | 666 } else { |
| 667 buffer.add('['); | 667 buffer.write('['); |
| 668 bool first = true; | 668 bool first = true; |
| 669 for (var value in option.values) { | 669 for (var value in option.values) { |
| 670 if (!first) buffer.add(", "); | 670 if (!first) buffer.write(", "); |
| 671 if (value == option.defaultValue) buffer.add('*'); | 671 if (value == option.defaultValue) buffer.write('*'); |
| 672 buffer.add(value); | 672 buffer.write(value); |
| 673 first = false; | 673 first = false; |
| 674 } | 674 } |
| 675 buffer.add(']'); | 675 buffer.write(']'); |
| 676 } | 676 } |
| 677 } | 677 } |
| 678 print(buffer.toString()); | 678 print(buffer.toString()); |
| 679 } | 679 } |
| 680 print(''); | 680 print(''); |
| 681 } | 681 } |
| 682 } | 682 } |
| 683 | 683 |
| 684 | 684 |
| 685 /** | 685 /** |
| 686 * Find the test option specification for a given option key. | 686 * Find the test option specification for a given option key. |
| 687 */ | 687 */ |
| 688 _TestOptionSpecification _getSpecification(String name) { | 688 _TestOptionSpecification _getSpecification(String name) { |
| 689 for (var option in _options) { | 689 for (var option in _options) { |
| 690 if (option.keys.any((key) => key == name)) { | 690 if (option.keys.any((key) => key == name)) { |
| 691 return option; | 691 return option; |
| 692 } | 692 } |
| 693 } | 693 } |
| 694 print('Unknown test option $name'); | 694 print('Unknown test option $name'); |
| 695 exit(1); | 695 exit(1); |
| 696 } | 696 } |
| 697 | 697 |
| 698 | 698 |
| 699 List<_TestOptionSpecification> _options; | 699 List<_TestOptionSpecification> _options; |
| 700 } | 700 } |
| OLD | NEW |