| 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'; |
| 11 import 'package:yaml/yaml.dart'; | 11 import 'package:yaml/yaml.dart'; |
| 12 | 12 |
| 13 import '../../backend/platform_selector.dart'; |
| 13 import '../../backend/test_platform.dart'; | 14 import '../../backend/test_platform.dart'; |
| 14 import '../../frontend/timeout.dart'; | 15 import '../../frontend/timeout.dart'; |
| 15 import '../../utils.dart'; | 16 import '../../utils.dart'; |
| 16 import '../configuration.dart'; | 17 import '../configuration.dart'; |
| 17 import 'values.dart'; | 18 import 'values.dart'; |
| 18 | 19 |
| 19 /// Loads configuration information from a YAML file at [path]. | 20 /// Loads configuration information from a YAML file at [path]. |
| 20 /// | 21 /// |
| 21 /// Throws a [FormatException] if the configuration is invalid, and a | 22 /// Throws a [FormatException] if the configuration is invalid, and a |
| 22 /// [FileSystemException] if it can't be read. | 23 /// [FileSystemException] if it can't be read. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 52 : _runnerConfig = runnerConfig; | 53 : _runnerConfig = runnerConfig; |
| 53 | 54 |
| 54 /// Loads the configuration in [_document]. | 55 /// Loads the configuration in [_document]. |
| 55 Configuration load() => _loadTestConfig().merge(_loadRunnerConfig()); | 56 Configuration load() => _loadTestConfig().merge(_loadRunnerConfig()); |
| 56 | 57 |
| 57 /// Loads test configuration (but not runner configuration). | 58 /// Loads test configuration (but not runner configuration). |
| 58 Configuration _loadTestConfig() { | 59 Configuration _loadTestConfig() { |
| 59 var verboseTrace = _getBool("verbose_trace"); | 60 var verboseTrace = _getBool("verbose_trace"); |
| 60 var jsTrace = _getBool("js_trace"); | 61 var jsTrace = _getBool("js_trace"); |
| 61 | 62 |
| 63 var skip = _getValue("skip", "boolean or string", |
| 64 (value) => value is bool || value is String); |
| 65 var skipReason; |
| 66 if (skip is String) { |
| 67 skipReason = skip; |
| 68 skip = true; |
| 69 } |
| 70 |
| 71 var testOn = _parseValue("test_on", |
| 72 (value) => new PlatformSelector.parse(value)); |
| 73 |
| 62 var timeout = _parseValue("timeout", (value) => new Timeout.parse(value)); | 74 var timeout = _parseValue("timeout", (value) => new Timeout.parse(value)); |
| 63 | 75 |
| 64 var addTags = _getList("add_tags", (tagNode) { | 76 var addTags = _getList("add_tags", (tagNode) { |
| 65 _validate(tagNode, "Tags must be strings.", (value) => value is String); | 77 _validate(tagNode, "Tags must be strings.", (value) => value is String); |
| 66 _validate( | 78 _validate( |
| 67 tagNode, | 79 tagNode, |
| 68 "Invalid tag. Tags must be (optionally hyphenated) Dart identifiers.", | 80 "Invalid tag. Tags must be (optionally hyphenated) Dart identifiers.", |
| 69 (value) => value.contains(anchoredHyphenatedIdentifier)); | 81 (value) => value.contains(anchoredHyphenatedIdentifier)); |
| 70 return tagNode.value; | 82 return tagNode.value; |
| 71 }); | 83 }); |
| 72 | 84 |
| 73 var tags = _getMap("tags", | 85 var tags = _getMap("tags", |
| 74 key: (keyNode) => _parseNode(keyNode, "tags key", | 86 key: (keyNode) => _parseNode(keyNode, "tags key", |
| 75 (value) => new BooleanSelector.parse(value)), | 87 (value) => new BooleanSelector.parse(value)), |
| 76 value: (valueNode) => | 88 value: (valueNode) => |
| 77 _nestedConfig(valueNode, "tag value", runnerConfig: false)); | 89 _nestedConfig(valueNode, "tag value", runnerConfig: false)); |
| 78 | 90 |
| 79 return new Configuration( | 91 return new Configuration( |
| 80 verboseTrace: verboseTrace, | 92 verboseTrace: verboseTrace, |
| 81 jsTrace: jsTrace, | 93 jsTrace: jsTrace, |
| 94 skip: skip, |
| 95 skipReason: skipReason, |
| 96 testOn: testOn, |
| 82 timeout: timeout, | 97 timeout: timeout, |
| 83 addTags: addTags, | 98 addTags: addTags, |
| 84 tags: tags); | 99 tags: tags); |
| 85 } | 100 } |
| 86 | 101 |
| 87 /// Loads runner configuration (but not test configuration). | 102 /// Loads runner configuration (but not test configuration). |
| 88 /// | 103 /// |
| 89 /// If [_runnerConfig] is `false`, this will error if there are any | 104 /// If [_runnerConfig] is `false`, this will error if there are any |
| 90 /// runner-level configuration fields. | 105 /// runner-level configuration fields. |
| 91 Configuration _loadRunnerConfig() { | 106 Configuration _loadRunnerConfig() { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 if (!_document.containsKey(field)) return; | 276 if (!_document.containsKey(field)) return; |
| 262 _error("$field isn't supported here.", field); | 277 _error("$field isn't supported here.", field); |
| 263 } | 278 } |
| 264 | 279 |
| 265 /// Throws a [SourceSpanFormatException] with [message] about [field]. | 280 /// Throws a [SourceSpanFormatException] with [message] about [field]. |
| 266 void _error(String message, String field) { | 281 void _error(String message, String field) { |
| 267 throw new SourceSpanFormatException( | 282 throw new SourceSpanFormatException( |
| 268 message, _document.nodes[field].span, _source); | 283 message, _document.nodes[field].span, _source); |
| 269 } | 284 } |
| 270 } | 285 } |
| OLD | NEW |