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 | 8 |
9 import '../../frontend/timeout.dart'; | 9 import '../../frontend/timeout.dart'; |
10 import '../../backend/test_platform.dart'; | 10 import '../../backend/test_platform.dart'; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 color: ifParsed('color'), | 149 color: ifParsed('color'), |
150 packageRoot: ifParsed('package-root'), | 150 packageRoot: ifParsed('package-root'), |
151 reporter: ifParsed('reporter'), | 151 reporter: ifParsed('reporter'), |
152 pubServePort: _wrapFormatException(options, 'pub-serve', int.parse), | 152 pubServePort: _wrapFormatException(options, 'pub-serve', int.parse), |
153 concurrency: _wrapFormatException(options, 'concurrency', int.parse), | 153 concurrency: _wrapFormatException(options, 'concurrency', int.parse), |
154 timeout: _wrapFormatException(options, 'timeout', | 154 timeout: _wrapFormatException(options, 'timeout', |
155 (value) => new Timeout.parse(value)), | 155 (value) => new Timeout.parse(value)), |
156 pattern: pattern, | 156 pattern: pattern, |
157 platforms: ifParsed('platform')?.map(TestPlatform.find), | 157 platforms: ifParsed('platform')?.map(TestPlatform.find), |
158 paths: options.rest.isEmpty ? null : options.rest, | 158 paths: options.rest.isEmpty ? null : options.rest, |
159 tags: tags, | 159 includeTags: tags, |
160 excludeTags: excludeTags); | 160 excludeTags: excludeTags); |
161 } | 161 } |
162 | 162 |
163 /// Runs [parse] on the value of the option [name], and wraps any | 163 /// Runs [parse] on the value of the option [name], and wraps any |
164 /// [FormatException] it throws with additional information. | 164 /// [FormatException] it throws with additional information. |
165 _wrapFormatException(ArgResults options, String name, parse(value)) { | 165 _wrapFormatException(ArgResults options, String name, parse(value)) { |
166 if (!options.wasParsed(name)) return null; | 166 if (!options.wasParsed(name)) return null; |
167 | 167 |
168 var value = options[name]; | 168 var value = options[name]; |
169 if (value == null) return null; | 169 if (value == null) return null; |
170 | 170 |
171 try { | 171 try { |
172 return parse(value); | 172 return parse(value); |
173 } on FormatException catch (error) { | 173 } on FormatException catch (error) { |
174 throw new FormatException('Couldn\'t parse --$name "${options[name]}": ' | 174 throw new FormatException('Couldn\'t parse --$name "${options[name]}": ' |
175 '${error.message}'); | 175 '${error.message}'); |
176 } | 176 } |
177 } | 177 } |
OLD | NEW |