OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:io'; | 5 import 'dart:io'; |
6 | 6 |
7 import 'package:args/args.dart'; | 7 import 'package:args/args.dart'; |
8 import 'package:boolean_selector/boolean_selector.dart'; | 8 import 'package:boolean_selector/boolean_selector.dart'; |
9 | 9 |
10 import '../../backend/test_platform.dart'; | 10 import '../../backend/test_platform.dart'; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 valueHelp: 'port'); | 78 valueHelp: 'port'); |
79 parser.addOption("timeout", | 79 parser.addOption("timeout", |
80 help: 'The default test timeout. For example: 15s, 2x, none', | 80 help: 'The default test timeout. For example: 15s, 2x, none', |
81 defaultsTo: '30s'); | 81 defaultsTo: '30s'); |
82 parser.addFlag("pause-after-load", | 82 parser.addFlag("pause-after-load", |
83 help: 'Pauses for debugging before any tests execute.\n' | 83 help: 'Pauses for debugging before any tests execute.\n' |
84 'Implies --concurrency=1 and --timeout=none.\n' | 84 'Implies --concurrency=1 and --timeout=none.\n' |
85 'Currently only supported for browser tests.', | 85 'Currently only supported for browser tests.', |
86 negatable: false); | 86 negatable: false); |
87 | 87 |
88 // These are used by the internal Google test runner, so they're hidden from | |
89 // the --help output but still supported as stable API surface. See | |
90 // [Configuration.shardIndex] for details on their semantics. | |
91 parser.addOption("shard-index", hide: true); | |
92 parser.addOption("total-shards", hide: true); | |
93 | |
94 parser.addSeparator("======== Output"); | 88 parser.addSeparator("======== Output"); |
95 parser.addOption("reporter", | 89 parser.addOption("reporter", |
96 abbr: 'r', | 90 abbr: 'r', |
97 help: 'The runner used to print test results.', | 91 help: 'The runner used to print test results.', |
98 defaultsTo: defaultReporter, | 92 defaultsTo: defaultReporter, |
99 allowed: allReporters, | 93 allowed: allReporters, |
100 allowedHelp: { | 94 allowedHelp: { |
101 'compact': 'A single line, updated continuously.', | 95 'compact': 'A single line, updated continuously.', |
102 'expanded': 'A separate line for each update.', | 96 'expanded': 'A separate line for each update.', |
103 'json': 'A machine-readable format (see https://goo.gl/0HRhdZ).' | 97 'json': 'A machine-readable format (see https://goo.gl/0HRhdZ).' |
104 }); | 98 }); |
105 parser.addFlag("verbose-trace", negatable: false, | 99 parser.addFlag("verbose-trace", negatable: false, |
106 help: 'Whether to emit stack traces with core library frames.'); | 100 help: 'Whether to emit stack traces with core library frames.'); |
107 parser.addFlag("js-trace", negatable: false, | 101 parser.addFlag("js-trace", negatable: false, |
108 help: 'Whether to emit raw JavaScript stack traces for browser tests.'); | 102 help: 'Whether to emit raw JavaScript stack traces for browser tests.'); |
109 parser.addFlag("color", | 103 parser.addFlag("color", |
110 help: 'Whether to use terminal colors.\n(auto-detected by default)'); | 104 help: 'Whether to use terminal colors.\n(auto-detected by default)'); |
111 | 105 |
| 106 /// The following options are used only by the internal Google test runner. |
| 107 /// They're hidden and not supported as stable API surface outside Google. |
| 108 |
| 109 parser.addOption("dart2js-path", |
| 110 help: 'The path to the dart2js executable.', hide: true); |
| 111 parser.addOption("dart2js-args", |
| 112 help: 'Extra arguments to pass to dart2js.', |
| 113 allowMultiple: true, hide: true); |
| 114 parser.addOption("total-shards", |
| 115 help: 'The total number of invocations of the test runner being run.', |
| 116 hide: true); |
| 117 parser.addOption("shard-index", |
| 118 help: 'The index of this test runner invocation (of --total-shards).', |
| 119 hide: true); |
| 120 |
112 return parser; | 121 return parser; |
113 })(); | 122 })(); |
114 | 123 |
115 /// The usage string for the command-line arguments. | 124 /// The usage string for the command-line arguments. |
116 String get usage => _parser.usage; | 125 String get usage => _parser.usage; |
117 | 126 |
118 /// Parses the configuration from [args]. | 127 /// Parses the configuration from [args]. |
119 /// | 128 /// |
120 /// Throws a [FormatException] if [args] are invalid. | 129 /// Throws a [FormatException] if [args] are invalid. |
121 Configuration parse(List<String> args) => new _Parser(args).parse(); | 130 Configuration parse(List<String> args) => new _Parser(args).parse(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 177 } |
169 | 178 |
170 return new Configuration( | 179 return new Configuration( |
171 help: _ifParsed('help'), | 180 help: _ifParsed('help'), |
172 version: _ifParsed('version'), | 181 version: _ifParsed('version'), |
173 verboseTrace: _ifParsed('verbose-trace'), | 182 verboseTrace: _ifParsed('verbose-trace'), |
174 jsTrace: _ifParsed('js-trace'), | 183 jsTrace: _ifParsed('js-trace'), |
175 pauseAfterLoad: _ifParsed('pause-after-load'), | 184 pauseAfterLoad: _ifParsed('pause-after-load'), |
176 color: _ifParsed('color'), | 185 color: _ifParsed('color'), |
177 packageRoot: _ifParsed('package-root'), | 186 packageRoot: _ifParsed('package-root'), |
| 187 dart2jsPath: _ifParsed('dart2js-path'), |
| 188 dart2jsArgs: _ifParsed('dart2js-args') as List<String>, |
178 reporter: _ifParsed('reporter'), | 189 reporter: _ifParsed('reporter'), |
179 pubServePort: _parseOption('pub-serve', int.parse), | 190 pubServePort: _parseOption('pub-serve', int.parse), |
180 concurrency: _parseOption('concurrency', int.parse), | 191 concurrency: _parseOption('concurrency', int.parse), |
181 shardIndex: shardIndex, | 192 shardIndex: shardIndex, |
182 totalShards: totalShards, | 193 totalShards: totalShards, |
183 timeout: _parseOption('timeout', (value) => new Timeout.parse(value)), | 194 timeout: _parseOption('timeout', (value) => new Timeout.parse(value)), |
184 patterns: patterns, | 195 patterns: patterns, |
185 platforms: (_ifParsed('platform') as List<String>) | 196 platforms: (_ifParsed('platform') as List<String>) |
186 ?.map(TestPlatform.find), | 197 ?.map(TestPlatform.find), |
187 chosenPresets: _ifParsed('preset') as List<String>, | 198 chosenPresets: _ifParsed('preset') as List<String>, |
(...skipping 24 matching lines...) Expand all Loading... |
212 /// information. | 223 /// information. |
213 /*=T*/ _wrapFormatException/*<T>*/(String name, /*=T*/ parse()) { | 224 /*=T*/ _wrapFormatException/*<T>*/(String name, /*=T*/ parse()) { |
214 try { | 225 try { |
215 return parse(); | 226 return parse(); |
216 } on FormatException catch (error) { | 227 } on FormatException catch (error) { |
217 throw new FormatException('Couldn\'t parse --$name "${_options[name]}": ' | 228 throw new FormatException('Couldn\'t parse --$name "${_options[name]}": ' |
218 '${error.message}'); | 229 '${error.message}'); |
219 } | 230 } |
220 } | 231 } |
221 } | 232 } |
OLD | NEW |