| 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 import 'dart:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 import 'package:collection/collection.dart'; | 7 import 'package:collection/collection.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 | 10 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 /// tags. | 107 /// tags. |
| 108 final Set<String> excludeTags; | 108 final Set<String> excludeTags; |
| 109 | 109 |
| 110 /// Configuration for particular tags. | 110 /// Configuration for particular tags. |
| 111 /// | 111 /// |
| 112 /// The keys are tag names, and the values are configuration for those tags. | 112 /// The keys are tag names, and the values are configuration for those tags. |
| 113 /// The configuration should only contain test-level configuration fields, but | 113 /// The configuration should only contain test-level configuration fields, but |
| 114 /// that isn't enforced. | 114 /// that isn't enforced. |
| 115 final Map<String, Configuration> tags; | 115 final Map<String, Configuration> tags; |
| 116 | 116 |
| 117 final Set<String> addTags; |
| 118 |
| 117 /// The global test metadata derived from this configuration. | 119 /// The global test metadata derived from this configuration. |
| 118 Metadata get metadata => new Metadata( | 120 Metadata get metadata => new Metadata( |
| 119 timeout: timeout, | 121 timeout: timeout, |
| 120 verboseTrace: verboseTrace, | 122 verboseTrace: verboseTrace, |
| 123 tags: addTags, |
| 121 forTag: mapMap(tags, value: (_, config) => config.metadata)); | 124 forTag: mapMap(tags, value: (_, config) => config.metadata)); |
| 122 | 125 |
| 123 /// The set of tags that have been declaredin any way in this configuration. | 126 /// The set of tags that have been declaredin any way in this configuration. |
| 124 Set<String> get knownTags { | 127 Set<String> get knownTags { |
| 125 if (_knownTags != null) return _knownTags; | 128 if (_knownTags != null) return _knownTags; |
| 126 | 129 |
| 127 var known = includeTags.union(excludeTags); | 130 var known = includeTags.union(excludeTags).union(addTags); |
| 128 tags.forEach((tag, config) { | 131 tags.forEach((tag, config) { |
| 129 known.add(tag); | 132 known.add(tag); |
| 130 known.addAll(config.knownTags); | 133 known.addAll(config.knownTags); |
| 131 }); | 134 }); |
| 132 | 135 |
| 133 _knownTags = new UnmodifiableSetView(known); | 136 _knownTags = new UnmodifiableSetView(known); |
| 134 return _knownTags; | 137 return _knownTags; |
| 135 } | 138 } |
| 136 Set<String> _knownTags; | 139 Set<String> _knownTags; |
| 137 | 140 |
| 138 /// Parses the configuration from [args]. | 141 /// Parses the configuration from [args]. |
| 139 /// | 142 /// |
| 140 /// Throws a [FormatException] if [args] are invalid. | 143 /// Throws a [FormatException] if [args] are invalid. |
| 141 factory Configuration.parse(List<String> arguments) => args.parse(arguments); | 144 factory Configuration.parse(List<String> arguments) => args.parse(arguments); |
| 142 | 145 |
| 143 /// Loads the configuration from [path]. | 146 /// Loads the configuration from [path]. |
| 144 /// | 147 /// |
| 145 /// Throws an [IOException] if [path] does not exist or cannot be read. Throws | 148 /// Throws an [IOException] if [path] does not exist or cannot be read. Throws |
| 146 /// a [FormatException] if its contents are invalid. | 149 /// a [FormatException] if its contents are invalid. |
| 147 factory Configuration.load(String path) => load(path); | 150 factory Configuration.load(String path) => load(path); |
| 148 | 151 |
| 149 Configuration({bool help, bool version, bool verboseTrace, bool jsTrace, | 152 Configuration({bool help, bool version, bool verboseTrace, bool jsTrace, |
| 150 bool pauseAfterLoad, bool color, String packageRoot, String reporter, | 153 bool pauseAfterLoad, bool color, String packageRoot, String reporter, |
| 151 int pubServePort, int concurrency, Timeout timeout, this.pattern, | 154 int pubServePort, int concurrency, Timeout timeout, this.pattern, |
| 152 Iterable<TestPlatform> platforms, Iterable<String> paths, | 155 Iterable<TestPlatform> platforms, Iterable<String> paths, |
| 153 Glob filename, Iterable<String> includeTags, | 156 Glob filename, Iterable<String> includeTags, |
| 154 Iterable<String> excludeTags, Map<String, Configuration> tags}) | 157 Iterable<String> excludeTags, Iterable<String> addTags, |
| 158 Map<String, Configuration> tags}) |
| 155 : _help = help, | 159 : _help = help, |
| 156 _version = version, | 160 _version = version, |
| 157 _verboseTrace = verboseTrace, | 161 _verboseTrace = verboseTrace, |
| 158 _jsTrace = jsTrace, | 162 _jsTrace = jsTrace, |
| 159 _pauseAfterLoad = pauseAfterLoad, | 163 _pauseAfterLoad = pauseAfterLoad, |
| 160 _color = color, | 164 _color = color, |
| 161 _packageRoot = packageRoot, | 165 _packageRoot = packageRoot, |
| 162 _reporter = reporter, | 166 _reporter = reporter, |
| 163 pubServeUrl = pubServePort == null | 167 pubServeUrl = pubServePort == null |
| 164 ? null | 168 ? null |
| 165 : Uri.parse("http://localhost:$pubServePort"), | 169 : Uri.parse("http://localhost:$pubServePort"), |
| 166 _concurrency = concurrency, | 170 _concurrency = concurrency, |
| 167 timeout = (pauseAfterLoad ?? false) | 171 timeout = (pauseAfterLoad ?? false) |
| 168 ? Timeout.none | 172 ? Timeout.none |
| 169 : (timeout == null ? new Timeout.factor(1) : timeout), | 173 : (timeout == null ? new Timeout.factor(1) : timeout), |
| 170 _platforms = _list(platforms), | 174 _platforms = _list(platforms), |
| 171 _paths = _list(paths), | 175 _paths = _list(paths), |
| 172 _filename = filename, | 176 _filename = filename, |
| 173 includeTags = includeTags?.toSet() ?? new Set(), | 177 includeTags = includeTags?.toSet() ?? new Set(), |
| 174 excludeTags = excludeTags?.toSet() ?? new Set(), | 178 excludeTags = excludeTags?.toSet() ?? new Set(), |
| 179 addTags = addTags?.toSet() ?? new Set(), |
| 175 tags = tags == null ? const {} : new Map.unmodifiable(tags) { | 180 tags = tags == null ? const {} : new Map.unmodifiable(tags) { |
| 176 if (_filename != null && _filename.context.style != p.style) { | 181 if (_filename != null && _filename.context.style != p.style) { |
| 177 throw new ArgumentError( | 182 throw new ArgumentError( |
| 178 "filename's context must match the current operating system, was " | 183 "filename's context must match the current operating system, was " |
| 179 "${_filename.context.style}."); | 184 "${_filename.context.style}."); |
| 180 } | 185 } |
| 181 } | 186 } |
| 182 | 187 |
| 183 /// Returns a [input] as a list or `null`. | 188 /// Returns a [input] as a list or `null`. |
| 184 /// | 189 /// |
| (...skipping 23 matching lines...) Expand all Loading... |
| 208 reporter: other._reporter ?? _reporter, | 213 reporter: other._reporter ?? _reporter, |
| 209 pubServePort: (other.pubServeUrl ?? pubServeUrl)?.port, | 214 pubServePort: (other.pubServeUrl ?? pubServeUrl)?.port, |
| 210 concurrency: other._concurrency ?? _concurrency, | 215 concurrency: other._concurrency ?? _concurrency, |
| 211 timeout: timeout.merge(other.timeout), | 216 timeout: timeout.merge(other.timeout), |
| 212 pattern: other.pattern ?? pattern, | 217 pattern: other.pattern ?? pattern, |
| 213 platforms: other._platforms ?? _platforms, | 218 platforms: other._platforms ?? _platforms, |
| 214 paths: other._paths ?? _paths, | 219 paths: other._paths ?? _paths, |
| 215 filename: other._filename ?? _filename, | 220 filename: other._filename ?? _filename, |
| 216 includeTags: other.includeTags.union(includeTags), | 221 includeTags: other.includeTags.union(includeTags), |
| 217 excludeTags: other.excludeTags.union(excludeTags), | 222 excludeTags: other.excludeTags.union(excludeTags), |
| 223 addTags: other.addTags.union(addTags), |
| 218 tags: mergeMaps(tags, other.tags, | 224 tags: mergeMaps(tags, other.tags, |
| 219 value: (config1, config2) => config1.merge(config2))); | 225 value: (config1, config2) => config1.merge(config2))); |
| 220 } | 226 } |
| 221 } | 227 } |
| OLD | NEW |