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'; |
11 import '../../frontend/timeout.dart'; | 11 import '../../frontend/timeout.dart'; |
12 import '../configuration.dart'; | 12 import '../configuration.dart'; |
13 import 'values.dart'; | 13 import 'values.dart'; |
14 | 14 |
15 /// The parser used to parse the command-line arguments. | 15 /// The parser used to parse the command-line arguments. |
16 final ArgParser _parser = (() { | 16 final ArgParser _parser = (() { |
17 var parser = new ArgParser(allowTrailingOptions: true); | 17 var parser = new ArgParser(allowTrailingOptions: true); |
18 | 18 |
19 var allPlatforms = TestPlatform.all.toList(); | 19 var allPlatforms = TestPlatform.all.toList(); |
20 if (!Platform.isMacOS) allPlatforms.remove(TestPlatform.safari); | 20 if (!Platform.isMacOS) allPlatforms.remove(TestPlatform.safari); |
21 if (!Platform.isWindows) allPlatforms.remove(TestPlatform.internetExplorer); | 21 if (!Platform.isWindows) allPlatforms.remove(TestPlatform.internetExplorer); |
22 | 22 |
23 parser.addFlag("help", abbr: "h", negatable: false, | 23 parser.addFlag("help", abbr: "h", negatable: false, |
24 help: "Shows this usage information."); | 24 help: "Shows this usage information."); |
25 parser.addFlag("version", negatable: false, | 25 parser.addFlag("version", negatable: false, |
26 help: "Shows the package's version."); | 26 help: "Shows the package's version."); |
27 parser.addOption("package-root", hide: true); | |
28 | 27 |
29 // Note that defaultsTo declarations here are only for documentation purposes. | 28 // Note that defaultsTo declarations here are only for documentation purposes. |
30 // We pass null values rather than defaults to [new Configuration] so that it | 29 // We pass null values rather than defaults to [new Configuration] so that it |
31 // merges properly with the config file. | 30 // merges properly with the config file. |
32 | 31 |
33 parser.addSeparator("======== Selecting Tests"); | 32 parser.addSeparator("======== Selecting Tests"); |
34 parser.addOption("name", | 33 parser.addOption("name", |
35 abbr: 'n', | 34 abbr: 'n', |
36 help: 'A substring of the name of the test to run.\n' | 35 help: 'A substring of the name of the test to run.\n' |
37 'Regular expression syntax is supported.\n' | 36 'Regular expression syntax is supported.\n' |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 } | 184 } |
186 } | 185 } |
187 | 186 |
188 return new Configuration( | 187 return new Configuration( |
189 help: _ifParsed('help'), | 188 help: _ifParsed('help'), |
190 version: _ifParsed('version'), | 189 version: _ifParsed('version'), |
191 verboseTrace: _ifParsed('verbose-trace'), | 190 verboseTrace: _ifParsed('verbose-trace'), |
192 jsTrace: _ifParsed('js-trace'), | 191 jsTrace: _ifParsed('js-trace'), |
193 pauseAfterLoad: _ifParsed('pause-after-load'), | 192 pauseAfterLoad: _ifParsed('pause-after-load'), |
194 color: _ifParsed('color'), | 193 color: _ifParsed('color'), |
195 packageRoot: _ifParsed('package-root'), | |
196 dart2jsPath: _ifParsed('dart2js-path'), | 194 dart2jsPath: _ifParsed('dart2js-path'), |
197 dart2jsArgs: _ifParsed('dart2js-args') as List<String>, | 195 dart2jsArgs: _ifParsed('dart2js-args') as List<String>, |
198 precompiledPath: _ifParsed('precompiled'), | 196 precompiledPath: _ifParsed('precompiled'), |
199 reporter: _ifParsed('reporter'), | 197 reporter: _ifParsed('reporter'), |
200 pubServePort: _parseOption('pub-serve', int.parse), | 198 pubServePort: _parseOption('pub-serve', int.parse), |
201 concurrency: _parseOption('concurrency', int.parse), | 199 concurrency: _parseOption('concurrency', int.parse), |
202 shardIndex: shardIndex, | 200 shardIndex: shardIndex, |
203 totalShards: totalShards, | 201 totalShards: totalShards, |
204 timeout: _parseOption('timeout', (value) => new Timeout.parse(value)), | 202 timeout: _parseOption('timeout', (value) => new Timeout.parse(value)), |
205 patterns: patterns, | 203 patterns: patterns, |
(...skipping 28 matching lines...) Expand all Loading... |
234 /// information. | 232 /// information. |
235 /*=T*/ _wrapFormatException/*<T>*/(String name, /*=T*/ parse()) { | 233 /*=T*/ _wrapFormatException/*<T>*/(String name, /*=T*/ parse()) { |
236 try { | 234 try { |
237 return parse(); | 235 return parse(); |
238 } on FormatException catch (error) { | 236 } on FormatException catch (error) { |
239 throw new FormatException('Couldn\'t parse --$name "${_options[name]}": ' | 237 throw new FormatException('Couldn\'t parse --$name "${_options[name]}": ' |
240 '${error.message}'); | 238 '${error.message}'); |
241 } | 239 } |
242 } | 240 } |
243 } | 241 } |
OLD | NEW |