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:boolean_selector/boolean_selector.dart'; | 7 import 'package:boolean_selector/boolean_selector.dart'; |
8 import 'package:collection/collection.dart'; | 8 import 'package:collection/collection.dart'; |
9 import 'package:glob/glob.dart'; | 9 import 'package:glob/glob.dart'; |
10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
11 | 11 |
12 import '../backend/metadata.dart'; | 12 import '../backend/metadata.dart'; |
| 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 '../util/io.dart'; | 16 import '../util/io.dart'; |
16 import '../utils.dart'; | 17 import '../utils.dart'; |
17 import 'configuration/args.dart' as args; | 18 import 'configuration/args.dart' as args; |
18 import 'configuration/load.dart'; | 19 import 'configuration/load.dart'; |
19 import 'configuration/values.dart'; | 20 import 'configuration/values.dart'; |
20 | 21 |
21 /// A class that encapsulates the command-line configuration of the test runner. | 22 /// A class that encapsulates the command-line configuration of the test runner. |
22 class Configuration { | 23 class Configuration { |
(...skipping 11 matching lines...) Expand all Loading... |
34 /// Whether stack traces should be presented as-is or folded to remove | 35 /// Whether stack traces should be presented as-is or folded to remove |
35 /// irrelevant packages. | 36 /// irrelevant packages. |
36 bool get verboseTrace => _verboseTrace ?? false; | 37 bool get verboseTrace => _verboseTrace ?? false; |
37 final bool _verboseTrace; | 38 final bool _verboseTrace; |
38 | 39 |
39 /// Whether JavaScript stack traces should be left as-is or converted to | 40 /// Whether JavaScript stack traces should be left as-is or converted to |
40 /// Dart-like traces. | 41 /// Dart-like traces. |
41 bool get jsTrace => _jsTrace ?? false; | 42 bool get jsTrace => _jsTrace ?? false; |
42 final bool _jsTrace; | 43 final bool _jsTrace; |
43 | 44 |
| 45 /// Whether tests should be skipped. |
| 46 bool get skip => _skip ?? false; |
| 47 final bool _skip; |
| 48 |
| 49 /// The reason tests or suites should be skipped, if given. |
| 50 final String skipReason; |
| 51 |
| 52 /// The selector indicating which platforms the tests support. |
| 53 /// |
| 54 /// When [merge]d, this is intersected with the other configuration's |
| 55 /// supported platforms. |
| 56 final PlatformSelector testOn; |
| 57 |
44 /// Whether to pause for debugging after loading each test suite. | 58 /// Whether to pause for debugging after loading each test suite. |
45 bool get pauseAfterLoad => _pauseAfterLoad ?? false; | 59 bool get pauseAfterLoad => _pauseAfterLoad ?? false; |
46 final bool _pauseAfterLoad; | 60 final bool _pauseAfterLoad; |
47 | 61 |
48 /// The package root for resolving "package:" URLs. | 62 /// The package root for resolving "package:" URLs. |
49 String get packageRoot => _packageRoot ?? p.join(p.current, 'packages'); | 63 String get packageRoot => _packageRoot ?? p.join(p.current, 'packages'); |
50 final String _packageRoot; | 64 final String _packageRoot; |
51 | 65 |
52 /// The name of the reporter to use to display results. | 66 /// The name of the reporter to use to display results. |
53 String get reporter => _reporter ?? defaultReporter; | 67 String get reporter => _reporter ?? defaultReporter; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 128 |
115 /// Tags that are added to the tests. | 129 /// Tags that are added to the tests. |
116 /// | 130 /// |
117 /// This is usually only used for scoped configuration. | 131 /// This is usually only used for scoped configuration. |
118 final Set<String> addTags; | 132 final Set<String> addTags; |
119 | 133 |
120 /// The global test metadata derived from this configuration. | 134 /// The global test metadata derived from this configuration. |
121 Metadata get metadata => new Metadata( | 135 Metadata get metadata => new Metadata( |
122 timeout: timeout, | 136 timeout: timeout, |
123 verboseTrace: verboseTrace, | 137 verboseTrace: verboseTrace, |
| 138 skip: skip, |
| 139 skipReason: skipReason, |
| 140 testOn: testOn, |
124 tags: addTags, | 141 tags: addTags, |
125 forTag: mapMap(tags, value: (_, config) => config.metadata)); | 142 forTag: mapMap(tags, value: (_, config) => config.metadata)); |
126 | 143 |
127 /// The set of tags that have been declaredin any way in this configuration. | 144 /// The set of tags that have been declaredin any way in this configuration. |
128 Set<String> get knownTags { | 145 Set<String> get knownTags { |
129 if (_knownTags != null) return _knownTags; | 146 if (_knownTags != null) return _knownTags; |
130 | 147 |
131 var known = includeTags.variables.toSet() | 148 var known = includeTags.variables.toSet() |
132 ..addAll(excludeTags.variables) | 149 ..addAll(excludeTags.variables) |
133 ..addAll(addTags); | 150 ..addAll(addTags); |
(...skipping 11 matching lines...) Expand all Loading... |
145 /// | 162 /// |
146 /// Throws a [FormatException] if [args] are invalid. | 163 /// Throws a [FormatException] if [args] are invalid. |
147 factory Configuration.parse(List<String> arguments) => args.parse(arguments); | 164 factory Configuration.parse(List<String> arguments) => args.parse(arguments); |
148 | 165 |
149 /// Loads the configuration from [path]. | 166 /// Loads the configuration from [path]. |
150 /// | 167 /// |
151 /// Throws an [IOException] if [path] does not exist or cannot be read. Throws | 168 /// Throws an [IOException] if [path] does not exist or cannot be read. Throws |
152 /// a [FormatException] if its contents are invalid. | 169 /// a [FormatException] if its contents are invalid. |
153 factory Configuration.load(String path) => load(path); | 170 factory Configuration.load(String path) => load(path); |
154 | 171 |
155 Configuration({bool help, bool version, bool verboseTrace, bool jsTrace, | 172 Configuration({ |
156 bool pauseAfterLoad, bool color, String packageRoot, String reporter, | 173 bool help, |
157 int pubServePort, int concurrency, Timeout timeout, this.pattern, | 174 bool version, |
158 Iterable<TestPlatform> platforms, Iterable<String> paths, | 175 bool verboseTrace, |
159 Glob filename, BooleanSelector includeTags, | 176 bool jsTrace, |
160 BooleanSelector excludeTags, Iterable addTags, | 177 bool skip, |
| 178 this.skipReason, |
| 179 PlatformSelector testOn, |
| 180 bool pauseAfterLoad, |
| 181 bool color, |
| 182 String packageRoot, |
| 183 String reporter, |
| 184 int pubServePort, |
| 185 int concurrency, |
| 186 Timeout timeout, |
| 187 this.pattern, |
| 188 Iterable<TestPlatform> platforms, |
| 189 Iterable<String> paths, |
| 190 Glob filename, |
| 191 BooleanSelector includeTags, |
| 192 BooleanSelector excludeTags, |
| 193 Iterable addTags, |
161 Map<BooleanSelector, Configuration> tags}) | 194 Map<BooleanSelector, Configuration> tags}) |
162 : _help = help, | 195 : _help = help, |
163 _version = version, | 196 _version = version, |
164 _verboseTrace = verboseTrace, | 197 _verboseTrace = verboseTrace, |
165 _jsTrace = jsTrace, | 198 _jsTrace = jsTrace, |
| 199 _skip = skip, |
| 200 testOn = testOn ?? PlatformSelector.all, |
166 _pauseAfterLoad = pauseAfterLoad, | 201 _pauseAfterLoad = pauseAfterLoad, |
167 _color = color, | 202 _color = color, |
168 _packageRoot = packageRoot, | 203 _packageRoot = packageRoot, |
169 _reporter = reporter, | 204 _reporter = reporter, |
170 pubServeUrl = pubServePort == null | 205 pubServeUrl = pubServePort == null |
171 ? null | 206 ? null |
172 : Uri.parse("http://localhost:$pubServePort"), | 207 : Uri.parse("http://localhost:$pubServePort"), |
173 _concurrency = concurrency, | 208 _concurrency = concurrency, |
174 timeout = (pauseAfterLoad ?? false) | 209 timeout = (pauseAfterLoad ?? false) |
175 ? Timeout.none | 210 ? Timeout.none |
(...skipping 27 matching lines...) Expand all Loading... |
203 /// | 238 /// |
204 /// For most fields, if both configurations have values set, [other]'s value | 239 /// For most fields, if both configurations have values set, [other]'s value |
205 /// takes precedence. However, certain fields are merged together instead. | 240 /// takes precedence. However, certain fields are merged together instead. |
206 /// This is indicated in those fields' documentation. | 241 /// This is indicated in those fields' documentation. |
207 Configuration merge(Configuration other) { | 242 Configuration merge(Configuration other) { |
208 return new Configuration( | 243 return new Configuration( |
209 help: other._help ?? _help, | 244 help: other._help ?? _help, |
210 version: other._version ?? _version, | 245 version: other._version ?? _version, |
211 verboseTrace: other._verboseTrace ?? _verboseTrace, | 246 verboseTrace: other._verboseTrace ?? _verboseTrace, |
212 jsTrace: other._jsTrace ?? _jsTrace, | 247 jsTrace: other._jsTrace ?? _jsTrace, |
| 248 skip: other._skip ?? _skip, |
| 249 skipReason: other.skipReason ?? skipReason, |
| 250 testOn: testOn.intersection(other.testOn), |
213 pauseAfterLoad: other._pauseAfterLoad ?? _pauseAfterLoad, | 251 pauseAfterLoad: other._pauseAfterLoad ?? _pauseAfterLoad, |
214 color: other._color ?? _color, | 252 color: other._color ?? _color, |
215 packageRoot: other._packageRoot ?? _packageRoot, | 253 packageRoot: other._packageRoot ?? _packageRoot, |
216 reporter: other._reporter ?? _reporter, | 254 reporter: other._reporter ?? _reporter, |
217 pubServePort: (other.pubServeUrl ?? pubServeUrl)?.port, | 255 pubServePort: (other.pubServeUrl ?? pubServeUrl)?.port, |
218 concurrency: other._concurrency ?? _concurrency, | 256 concurrency: other._concurrency ?? _concurrency, |
219 timeout: timeout.merge(other.timeout), | 257 timeout: timeout.merge(other.timeout), |
220 pattern: other.pattern ?? pattern, | 258 pattern: other.pattern ?? pattern, |
221 platforms: other._platforms ?? _platforms, | 259 platforms: other._platforms ?? _platforms, |
222 paths: other._paths ?? _paths, | 260 paths: other._paths ?? _paths, |
223 filename: other._filename ?? _filename, | 261 filename: other._filename ?? _filename, |
224 includeTags: includeTags.intersection(other.includeTags), | 262 includeTags: includeTags.intersection(other.includeTags), |
225 excludeTags: excludeTags.union(other.excludeTags), | 263 excludeTags: excludeTags.union(other.excludeTags), |
226 addTags: other.addTags.union(addTags), | 264 addTags: other.addTags.union(addTags), |
227 tags: mergeMaps(tags, other.tags, | 265 tags: mergeMaps(tags, other.tags, |
228 value: (config1, config2) => config1.merge(config2))); | 266 value: (config1, config2) => config1.merge(config2))); |
229 } | 267 } |
230 } | 268 } |
OLD | NEW |