| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.runner.configuration; | 5 library test.runner.configuration; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'package:args/args.dart'; | 10 import 'package:args/args.dart'; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 /// The set of platforms on which to run tests. | 147 /// The set of platforms on which to run tests. |
| 148 List<TestPlatform> get platforms => | 148 List<TestPlatform> get platforms => |
| 149 _options["platform"].map(TestPlatform.find).toList(); | 149 _options["platform"].map(TestPlatform.find).toList(); |
| 150 | 150 |
| 151 /// Parses the configuration from [args]. | 151 /// Parses the configuration from [args]. |
| 152 /// | 152 /// |
| 153 /// Throws a [FormatException] if [args] are invalid. | 153 /// Throws a [FormatException] if [args] are invalid. |
| 154 Configuration.parse(List<String> args) | 154 Configuration.parse(List<String> args) |
| 155 : _options = _parser.parse(args) { | 155 : _options = _parser.parse(args) { |
| 156 _concurrency = _options['concurrency'] == null | 156 if (pauseAfterLoad) { |
| 157 ? _defaultConcurrency | 157 _concurrency = 1; |
| 158 : _wrapFormatException('concurrency', int.parse); | 158 } else if (_options['concurrency'] == null) { |
| 159 _concurrency = _defaultConcurrency; |
| 160 } else { |
| 161 _concurrency = _wrapFormatException('concurrency', int.parse); |
| 162 } |
| 159 | 163 |
| 160 if (_options["name"] != null && _options["plain-name"] != null) { | 164 if (_options["name"] != null && _options["plain-name"] != null) { |
| 161 throw new FormatException( | 165 throw new FormatException( |
| 162 "--name and --plain-name may not both be passed."); | 166 "--name and --plain-name may not both be passed."); |
| 163 } | 167 } |
| 164 } | 168 } |
| 165 | 169 |
| 166 /// Runs [parse] on the value of the option [name], and wraps any | 170 /// Runs [parse] on the value of the option [name], and wraps any |
| 167 /// [FormatException] it throws with additional information. | 171 /// [FormatException] it throws with additional information. |
| 168 _wrapFormatException(String name, parse(value)) { | 172 _wrapFormatException(String name, parse(value)) { |
| 169 try { | 173 try { |
| 170 return parse(_options[name]); | 174 return parse(_options[name]); |
| 171 } on FormatException catch (error) { | 175 } on FormatException catch (error) { |
| 172 throw new FormatException('Couldn\'t parse --$name "${_options[name]}": ' | 176 throw new FormatException('Couldn\'t parse --$name "${_options[name]}": ' |
| 173 '${error.message}'); | 177 '${error.message}'); |
| 174 } | 178 } |
| 175 } | 179 } |
| 176 } | 180 } |
| OLD | NEW |