| 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:glob/glob.dart'; | 7 import 'package:glob/glob.dart'; |
| 8 import 'package:path/path.dart' as p; | 8 import 'package:path/path.dart' as p; |
| 9 import 'package:source_span/source_span.dart'; | 9 import 'package:source_span/source_span.dart'; |
| 10 import 'package:yaml/yaml.dart'; | 10 import 'package:yaml/yaml.dart'; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 /// Loads the configuration in [_document]. | 53 /// Loads the configuration in [_document]. |
| 54 Configuration load() => _loadTestConfig().merge(_loadRunnerConfig()); | 54 Configuration load() => _loadTestConfig().merge(_loadRunnerConfig()); |
| 55 | 55 |
| 56 /// Loads test configuration (but not runner configuration). | 56 /// Loads test configuration (but not runner configuration). |
| 57 Configuration _loadTestConfig() { | 57 Configuration _loadTestConfig() { |
| 58 var verboseTrace = _getBool("verbose_trace"); | 58 var verboseTrace = _getBool("verbose_trace"); |
| 59 var jsTrace = _getBool("js_trace"); | 59 var jsTrace = _getBool("js_trace"); |
| 60 | 60 |
| 61 var timeout = _parseValue("timeout", (value) => new Timeout.parse(value)); | 61 var timeout = _parseValue("timeout", (value) => new Timeout.parse(value)); |
| 62 | 62 |
| 63 var addTags = _getList("add_tags", (tagNode) { |
| 64 _validate(tagNode, "Tags must be strings.", (value) => value is String); |
| 65 _validate( |
| 66 tagNode, |
| 67 "Invalid tag. Tags must be (optionally hyphenated) Dart identifiers.", |
| 68 (value) => value.contains(anchoredHyphenatedIdentifier)); |
| 69 return tagNode.value; |
| 70 }); |
| 71 |
| 63 var tags = _getMap("tags", key: (keyNode) { | 72 var tags = _getMap("tags", key: (keyNode) { |
| 64 _validate(keyNode, "tags key must be a string.", | 73 _validate(keyNode, "tags key must be a string.", |
| 65 (value) => value is String); | 74 (value) => value is String); |
| 66 _validate( | 75 _validate( |
| 67 keyNode, | 76 keyNode, |
| 68 "Invalid tag. Tags must be (optionally hyphenated) Dart identifiers.", | 77 "Invalid tag. Tags must be (optionally hyphenated) Dart identifiers.", |
| 69 (value) => value.contains(anchoredHyphenatedIdentifier)); | 78 (value) => value.contains(anchoredHyphenatedIdentifier)); |
| 70 | 79 |
| 71 return keyNode.value; | 80 return keyNode.value; |
| 72 }, value: (valueNode) { | 81 }, value: (valueNode) { |
| 73 return _nestedConfig(valueNode, "tag value", runnerConfig: false); | 82 return _nestedConfig(valueNode, "tag value", runnerConfig: false); |
| 74 }); | 83 }); |
| 75 | 84 |
| 76 return new Configuration( | 85 return new Configuration( |
| 77 verboseTrace: verboseTrace, | 86 verboseTrace: verboseTrace, |
| 78 jsTrace: jsTrace, | 87 jsTrace: jsTrace, |
| 79 timeout: timeout, | 88 timeout: timeout, |
| 89 addTags: addTags, |
| 80 tags: tags); | 90 tags: tags); |
| 81 } | 91 } |
| 82 | 92 |
| 83 /// Loads runner configuration (but not test configuration). | 93 /// Loads runner configuration (but not test configuration). |
| 84 /// | 94 /// |
| 85 /// If [_runnerConfig] is `false`, this will error if there are any | 95 /// If [_runnerConfig] is `false`, this will error if there are any |
| 86 /// runner-level configuration fields. | 96 /// runner-level configuration fields. |
| 87 Configuration _loadRunnerConfig() { | 97 Configuration _loadRunnerConfig() { |
| 88 if (!_runnerConfig) { | 98 if (!_runnerConfig) { |
| 89 _disallow("reporter"); | 99 _disallow("reporter"); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 if (!_document.containsKey(field)) return; | 267 if (!_document.containsKey(field)) return; |
| 258 _error("$field isn't supported here.", field); | 268 _error("$field isn't supported here.", field); |
| 259 } | 269 } |
| 260 | 270 |
| 261 /// Throws a [SourceSpanFormatException] with [message] about [field]. | 271 /// Throws a [SourceSpanFormatException] with [message] about [field]. |
| 262 void _error(String message, String field) { | 272 void _error(String message, String field) { |
| 263 throw new SourceSpanFormatException( | 273 throw new SourceSpanFormatException( |
| 264 message, _document.nodes[field].span, _source); | 274 message, _document.nodes[field].span, _source); |
| 265 } | 275 } |
| 266 } | 276 } |
| OLD | NEW |