Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: lib/src/runner/configuration.dart

Issue 1730173004: Add on_os and on_platform fields. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/operating_system.dart';
kevmoo 2016/02/26 23:06:20 unused import?
nweiz 2016/03/01 02:24:04 Done.
13 import '../backend/platform_selector.dart'; 14 import '../backend/platform_selector.dart';
14 import '../backend/test_platform.dart'; 15 import '../backend/test_platform.dart';
15 import '../frontend/timeout.dart'; 16 import '../frontend/timeout.dart';
16 import '../util/io.dart'; 17 import '../util/io.dart';
17 import '../utils.dart'; 18 import '../utils.dart';
18 import 'configuration/args.dart' as args; 19 import 'configuration/args.dart' as args;
19 import 'configuration/load.dart'; 20 import 'configuration/load.dart';
20 import 'configuration/values.dart'; 21 import 'configuration/values.dart';
21 22
22 /// A class that encapsulates the command-line configuration of the test runner. 23 /// A class that encapsulates the command-line configuration of the test runner.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 final Set<String> addTags; 133 final Set<String> addTags;
133 134
134 /// The global test metadata derived from this configuration. 135 /// The global test metadata derived from this configuration.
135 Metadata get metadata => new Metadata( 136 Metadata get metadata => new Metadata(
136 timeout: timeout, 137 timeout: timeout,
137 verboseTrace: verboseTrace, 138 verboseTrace: verboseTrace,
138 skip: skip, 139 skip: skip,
139 skipReason: skipReason, 140 skipReason: skipReason,
140 testOn: testOn, 141 testOn: testOn,
141 tags: addTags, 142 tags: addTags,
142 forTag: mapMap(tags, value: (_, config) => config.metadata)); 143 forTag: mapMap(tags, value: (_, config) => config.metadata),
144 onPlatform: mapMap(onPlatform, value: (_, config) => config.metadata));
143 145
144 /// The set of tags that have been declaredin any way in this configuration. 146 /// The set of tags that have been declaredin any way in this configuration.
145 Set<String> get knownTags { 147 Set<String> get knownTags {
146 if (_knownTags != null) return _knownTags; 148 if (_knownTags != null) return _knownTags;
147 149
148 var known = includeTags.variables.toSet() 150 var known = includeTags.variables.toSet()
149 ..addAll(excludeTags.variables) 151 ..addAll(excludeTags.variables)
150 ..addAll(addTags); 152 ..addAll(addTags);
151 tags.forEach((selector, config) { 153 tags.forEach((selector, config) {
152 known.addAll(selector.variables); 154 known.addAll(selector.variables);
153 known.addAll(config.knownTags); 155 known.addAll(config.knownTags);
154 }); 156 });
155 157
156 _knownTags = new UnmodifiableSetView(known); 158 _knownTags = new UnmodifiableSetView(known);
157 return _knownTags; 159 return _knownTags;
158 } 160 }
159 Set<String> _knownTags; 161 Set<String> _knownTags;
160 162
163 /// Configuration for particular platforms.
164 ///
165 /// The keys are platform selectors, and the values are configurations for
166 /// those platforms. These configuration should only contain test-level
167 /// configuration fields, but that isn't enforced.
168 final Map<PlatformSelector, Configuration> onPlatform;
169
161 /// Parses the configuration from [args]. 170 /// Parses the configuration from [args].
162 /// 171 ///
163 /// Throws a [FormatException] if [args] are invalid. 172 /// Throws a [FormatException] if [args] are invalid.
164 factory Configuration.parse(List<String> arguments) => args.parse(arguments); 173 factory Configuration.parse(List<String> arguments) => args.parse(arguments);
165 174
166 /// Loads the configuration from [path]. 175 /// Loads the configuration from [path].
167 /// 176 ///
168 /// Throws an [IOException] if [path] does not exist or cannot be read. Throws 177 /// Throws an [IOException] if [path] does not exist or cannot be read. Throws
169 /// a [FormatException] if its contents are invalid. 178 /// a [FormatException] if its contents are invalid.
170 factory Configuration.load(String path) => load(path); 179 factory Configuration.load(String path) => load(path);
(...skipping 13 matching lines...) Expand all
184 int pubServePort, 193 int pubServePort,
185 int concurrency, 194 int concurrency,
186 Timeout timeout, 195 Timeout timeout,
187 this.pattern, 196 this.pattern,
188 Iterable<TestPlatform> platforms, 197 Iterable<TestPlatform> platforms,
189 Iterable<String> paths, 198 Iterable<String> paths,
190 Glob filename, 199 Glob filename,
191 BooleanSelector includeTags, 200 BooleanSelector includeTags,
192 BooleanSelector excludeTags, 201 BooleanSelector excludeTags,
193 Iterable addTags, 202 Iterable addTags,
194 Map<BooleanSelector, Configuration> tags}) 203 Map<BooleanSelector, Configuration> tags,
204 Map<PlatformSelector, Configuration> onPlatform})
195 : _help = help, 205 : _help = help,
196 _version = version, 206 _version = version,
197 _verboseTrace = verboseTrace, 207 _verboseTrace = verboseTrace,
198 _jsTrace = jsTrace, 208 _jsTrace = jsTrace,
199 _skip = skip, 209 _skip = skip,
200 testOn = testOn ?? PlatformSelector.all, 210 testOn = testOn ?? PlatformSelector.all,
201 _pauseAfterLoad = pauseAfterLoad, 211 _pauseAfterLoad = pauseAfterLoad,
202 _color = color, 212 _color = color,
203 _packageRoot = packageRoot, 213 _packageRoot = packageRoot,
204 _reporter = reporter, 214 _reporter = reporter,
205 pubServeUrl = pubServePort == null 215 pubServeUrl = pubServePort == null
206 ? null 216 ? null
207 : Uri.parse("http://localhost:$pubServePort"), 217 : Uri.parse("http://localhost:$pubServePort"),
208 _concurrency = concurrency, 218 _concurrency = concurrency,
209 timeout = (pauseAfterLoad ?? false) 219 timeout = (pauseAfterLoad ?? false)
210 ? Timeout.none 220 ? Timeout.none
211 : (timeout == null ? new Timeout.factor(1) : timeout), 221 : (timeout == null ? new Timeout.factor(1) : timeout),
212 _platforms = _list(platforms), 222 _platforms = _list(platforms),
213 _paths = _list(paths), 223 _paths = _list(paths),
214 _filename = filename, 224 _filename = filename,
215 includeTags = includeTags ?? BooleanSelector.all, 225 includeTags = includeTags ?? BooleanSelector.all,
216 excludeTags = excludeTags ?? BooleanSelector.none, 226 excludeTags = excludeTags ?? BooleanSelector.none,
217 addTags = addTags?.toSet() ?? new Set(), 227 addTags = addTags?.toSet() ?? new Set(),
218 tags = tags == null ? const {} : new Map.unmodifiable(tags) { 228 tags = tags == null ? const {} : new Map.unmodifiable(tags),
229 onPlatform = onPlatform == null
230 ? const {}
231 : new Map.unmodifiable(onPlatform) {
219 if (_filename != null && _filename.context.style != p.style) { 232 if (_filename != null && _filename.context.style != p.style) {
220 throw new ArgumentError( 233 throw new ArgumentError(
221 "filename's context must match the current operating system, was " 234 "filename's context must match the current operating system, was "
222 "${_filename.context.style}."); 235 "${_filename.context.style}.");
223 } 236 }
224 } 237 }
225 238
226 /// Returns a [input] as a list or `null`. 239 /// Returns a [input] as a list or `null`.
227 /// 240 ///
228 /// If [input] is `null` or empty, this returns `null`. Otherwise, it returns 241 /// If [input] is `null` or empty, this returns `null`. Otherwise, it returns
(...skipping 27 matching lines...) Expand all
256 concurrency: other._concurrency ?? _concurrency, 269 concurrency: other._concurrency ?? _concurrency,
257 timeout: timeout.merge(other.timeout), 270 timeout: timeout.merge(other.timeout),
258 pattern: other.pattern ?? pattern, 271 pattern: other.pattern ?? pattern,
259 platforms: other._platforms ?? _platforms, 272 platforms: other._platforms ?? _platforms,
260 paths: other._paths ?? _paths, 273 paths: other._paths ?? _paths,
261 filename: other._filename ?? _filename, 274 filename: other._filename ?? _filename,
262 includeTags: includeTags.intersection(other.includeTags), 275 includeTags: includeTags.intersection(other.includeTags),
263 excludeTags: excludeTags.union(other.excludeTags), 276 excludeTags: excludeTags.union(other.excludeTags),
264 addTags: other.addTags.union(addTags), 277 addTags: other.addTags.union(addTags),
265 tags: mergeMaps(tags, other.tags, 278 tags: mergeMaps(tags, other.tags,
279 value: (config1, config2) => config1.merge(config2)),
280 onPlatform: mergeMaps(onPlatform, other.onPlatform,
266 value: (config1, config2) => config1.merge(config2))); 281 value: (config1, config2) => config1.merge(config2)));
267 } 282 }
268 } 283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698