| 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:boolean_selector/boolean_selector.dart'; | 7 import 'package:boolean_selector/boolean_selector.dart'; |
| 8 import 'package:glob/glob.dart'; | 8 import 'package:glob/glob.dart'; |
| 9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
| 10 import 'package:source_span/source_span.dart'; | 10 import 'package:source_span/source_span.dart'; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 139 } |
| 140 | 140 |
| 141 var reporter = _getString("reporter"); | 141 var reporter = _getString("reporter"); |
| 142 if (reporter != null && !allReporters.contains(reporter)) { | 142 if (reporter != null && !allReporters.contains(reporter)) { |
| 143 _error('Unknown reporter "$reporter".', "reporter"); | 143 _error('Unknown reporter "$reporter".', "reporter"); |
| 144 } | 144 } |
| 145 | 145 |
| 146 var pubServePort = _getInt("pub_serve"); | 146 var pubServePort = _getInt("pub_serve"); |
| 147 var concurrency = _getInt("concurrency"); | 147 var concurrency = _getInt("concurrency"); |
| 148 | 148 |
| 149 var patterns = _getList("names", (nameNode) { |
| 150 _validate(nameNode, "Names must be strings.", (value) => value is String); |
| 151 return _parseNode(nameNode, "name", (value) => new RegExp(value)); |
| 152 })..addAll(_getList("plain_names", (nameNode) { |
| 153 _validate(nameNode, "Names must be strings.", (value) => value is String); |
| 154 return nameNode.value; |
| 155 })); |
| 156 |
| 149 var allPlatformIdentifiers = | 157 var allPlatformIdentifiers = |
| 150 TestPlatform.all.map((platform) => platform.identifier).toSet(); | 158 TestPlatform.all.map((platform) => platform.identifier).toSet(); |
| 151 var platforms = _getList("platforms", (platformNode) { | 159 var platforms = _getList("platforms", (platformNode) { |
| 152 _validate(platformNode, "Platforms must be strings.", | 160 _validate(platformNode, "Platforms must be strings.", |
| 153 (value) => value is String); | 161 (value) => value is String); |
| 154 _validate(platformNode, 'Unknown platform "${platformNode.value}".', | 162 _validate(platformNode, 'Unknown platform "${platformNode.value}".', |
| 155 allPlatformIdentifiers.contains); | 163 allPlatformIdentifiers.contains); |
| 156 | 164 |
| 157 return TestPlatform.find(platformNode.value); | 165 return TestPlatform.find(platformNode.value); |
| 158 }); | 166 }); |
| 159 | 167 |
| 160 var paths = _getList("paths", (pathNode) { | 168 var paths = _getList("paths", (pathNode) { |
| 161 _validate(pathNode, "Paths must be strings.", (value) => value is String); | 169 _validate(pathNode, "Paths must be strings.", (value) => value is String); |
| 162 _validate(pathNode, "Paths must be relative.", p.url.isRelative); | 170 _validate(pathNode, "Paths must be relative.", p.url.isRelative); |
| 163 | 171 |
| 164 return _parseNode(pathNode, "path", p.fromUri); | 172 return _parseNode(pathNode, "path", p.fromUri); |
| 165 }); | 173 }); |
| 166 | 174 |
| 167 var filename = _parseValue("filename", (value) => new Glob(value)); | 175 var filename = _parseValue("filename", (value) => new Glob(value)); |
| 168 | 176 |
| 169 var chosenPresets = _getList("add_presets", | 177 var chosenPresets = _getList("add_presets", |
| 170 (presetNode) => _parseIdentifierLike(presetNode, "Preset name")); | 178 (presetNode) => _parseIdentifierLike(presetNode, "Preset name")); |
| 171 | 179 |
| 172 return new Configuration( | 180 return new Configuration( |
| 173 reporter: reporter, | 181 reporter: reporter, |
| 174 pubServePort: pubServePort, | 182 pubServePort: pubServePort, |
| 175 concurrency: concurrency, | 183 concurrency: concurrency, |
| 184 patterns: patterns, |
| 176 platforms: platforms, | 185 platforms: platforms, |
| 177 paths: paths, | 186 paths: paths, |
| 178 filename: filename, | 187 filename: filename, |
| 179 chosenPresets: chosenPresets); | 188 chosenPresets: chosenPresets); |
| 180 } | 189 } |
| 181 | 190 |
| 182 /// Throws an exception with [message] if [test] returns `false` when passed | 191 /// Throws an exception with [message] if [test] returns `false` when passed |
| 183 /// [node]'s value. | 192 /// [node]'s value. |
| 184 void _validate(YamlNode node, String message, bool test(value)) { | 193 void _validate(YamlNode node, String message, bool test(value)) { |
| 185 if (test(node.value)) return; | 194 if (test(node.value)) return; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 if (!_document.containsKey(field)) return; | 322 if (!_document.containsKey(field)) return; |
| 314 _error("$field isn't supported here.", field); | 323 _error("$field isn't supported here.", field); |
| 315 } | 324 } |
| 316 | 325 |
| 317 /// Throws a [SourceSpanFormatException] with [message] about [field]. | 326 /// Throws a [SourceSpanFormatException] with [message] about [field]. |
| 318 void _error(String message, String field) { | 327 void _error(String message, String field) { |
| 319 throw new SourceSpanFormatException( | 328 throw new SourceSpanFormatException( |
| 320 message, _document.nodes[field].span, _source); | 329 message, _document.nodes[field].span, _source); |
| 321 } | 330 } |
| 322 } | 331 } |
| OLD | NEW |