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

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

Issue 1715583003: Use boolean selector syntax for tags. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 10 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
« no previous file with comments | « lib/src/runner.dart ('k') | lib/src/runner/configuration/args.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:collection/collection.dart'; 8 import 'package:collection/collection.dart';
8 import 'package:glob/glob.dart'; 9 import 'package:glob/glob.dart';
9 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
10 11
11 import '../backend/metadata.dart'; 12 import '../backend/metadata.dart';
12 import '../backend/test_platform.dart'; 13 import '../backend/test_platform.dart';
13 import '../frontend/timeout.dart'; 14 import '../frontend/timeout.dart';
14 import '../util/io.dart'; 15 import '../util/io.dart';
15 import '../utils.dart'; 16 import '../utils.dart';
16 import 'configuration/args.dart' as args; 17 import 'configuration/args.dart' as args;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 final Glob _filename; 86 final Glob _filename;
86 87
87 /// The pattern to match against test names to decide which to run, or `null` 88 /// The pattern to match against test names to decide which to run, or `null`
88 /// if all tests should be run. 89 /// if all tests should be run.
89 final Pattern pattern; 90 final Pattern pattern;
90 91
91 /// The set of platforms on which to run tests. 92 /// The set of platforms on which to run tests.
92 List<TestPlatform> get platforms => _platforms ?? [TestPlatform.vm]; 93 List<TestPlatform> get platforms => _platforms ?? [TestPlatform.vm];
93 final List<TestPlatform> _platforms; 94 final List<TestPlatform> _platforms;
94 95
95 /// Restricts the set of tests to a set of tags. 96 /// Only run tests whose tags match this selector.
96 /// 97 ///
97 /// If this is empty, it applies no restrictions. 98 /// When [merge]d, this is intersected with the other configuration's included
99 /// tags.
100 final BooleanSelector includeTags;
101
102 /// Do not run tests whose tags match this selector.
98 /// 103 ///
99 /// When [merge]d, this is unioned with the other configuration's tags. 104 /// When [merge]d, this is unioned with the other configuration's
100 final Set<String> includeTags; 105 /// excluded tags.
101 106 final BooleanSelector excludeTags;
102 /// Does not run tests with tags from this set.
103 ///
104 /// If this is empty, it applies no restrictions.
105 ///
106 /// When [merge]d, this is unioned with the other configuration's excluded
107 /// tags.
108 final Set<String> excludeTags;
109 107
110 /// Configuration for particular tags. 108 /// Configuration for particular tags.
111 /// 109 ///
112 /// The keys are tag names, and the values are configuration for those tags. 110 /// The keys are tag selectors, and the values are configurations for tests
113 /// The configuration should only contain test-level configuration fields, but 111 /// whose tags match those selectors. The configuration should only contain
114 /// that isn't enforced. 112 /// test-level configuration fields, but that isn't enforced.
115 final Map<String, Configuration> tags; 113 final Map<BooleanSelector, Configuration> tags;
116 114
115 /// Tags that are added to the tests.
116 ///
117 /// This is usually only used for scoped configuration.
117 final Set<String> addTags; 118 final Set<String> addTags;
118 119
119 /// The global test metadata derived from this configuration. 120 /// The global test metadata derived from this configuration.
120 Metadata get metadata => new Metadata( 121 Metadata get metadata => new Metadata(
121 timeout: timeout, 122 timeout: timeout,
122 verboseTrace: verboseTrace, 123 verboseTrace: verboseTrace,
123 tags: addTags, 124 tags: addTags,
124 forTag: mapMap(tags, value: (_, config) => config.metadata)); 125 forTag: mapMap(tags, value: (_, config) => config.metadata));
125 126
126 /// The set of tags that have been declaredin any way in this configuration. 127 /// The set of tags that have been declaredin any way in this configuration.
127 Set<String> get knownTags { 128 Set<String> get knownTags {
128 if (_knownTags != null) return _knownTags; 129 if (_knownTags != null) return _knownTags;
129 130
130 var known = includeTags.union(excludeTags).union(addTags); 131 var known = includeTags.variables.toSet()
131 tags.forEach((tag, config) { 132 ..addAll(excludeTags.variables)
132 known.add(tag); 133 ..addAll(addTags);
134 tags.forEach((selector, config) {
135 known.addAll(selector.variables);
133 known.addAll(config.knownTags); 136 known.addAll(config.knownTags);
134 }); 137 });
135 138
136 _knownTags = new UnmodifiableSetView(known); 139 _knownTags = new UnmodifiableSetView(known);
137 return _knownTags; 140 return _knownTags;
138 } 141 }
139 Set<String> _knownTags; 142 Set<String> _knownTags;
140 143
141 /// Parses the configuration from [args]. 144 /// Parses the configuration from [args].
142 /// 145 ///
143 /// Throws a [FormatException] if [args] are invalid. 146 /// Throws a [FormatException] if [args] are invalid.
144 factory Configuration.parse(List<String> arguments) => args.parse(arguments); 147 factory Configuration.parse(List<String> arguments) => args.parse(arguments);
145 148
146 /// Loads the configuration from [path]. 149 /// Loads the configuration from [path].
147 /// 150 ///
148 /// Throws an [IOException] if [path] does not exist or cannot be read. Throws 151 /// Throws an [IOException] if [path] does not exist or cannot be read. Throws
149 /// a [FormatException] if its contents are invalid. 152 /// a [FormatException] if its contents are invalid.
150 factory Configuration.load(String path) => load(path); 153 factory Configuration.load(String path) => load(path);
151 154
152 Configuration({bool help, bool version, bool verboseTrace, bool jsTrace, 155 Configuration({bool help, bool version, bool verboseTrace, bool jsTrace,
153 bool pauseAfterLoad, bool color, String packageRoot, String reporter, 156 bool pauseAfterLoad, bool color, String packageRoot, String reporter,
154 int pubServePort, int concurrency, Timeout timeout, this.pattern, 157 int pubServePort, int concurrency, Timeout timeout, this.pattern,
155 Iterable<TestPlatform> platforms, Iterable<String> paths, 158 Iterable<TestPlatform> platforms, Iterable<String> paths,
156 Glob filename, Iterable<String> includeTags, 159 Glob filename, BooleanSelector includeTags,
157 Iterable<String> excludeTags, Iterable<String> addTags, 160 BooleanSelector excludeTags, Iterable addTags,
158 Map<String, Configuration> tags}) 161 Map<BooleanSelector, Configuration> tags})
159 : _help = help, 162 : _help = help,
160 _version = version, 163 _version = version,
161 _verboseTrace = verboseTrace, 164 _verboseTrace = verboseTrace,
162 _jsTrace = jsTrace, 165 _jsTrace = jsTrace,
163 _pauseAfterLoad = pauseAfterLoad, 166 _pauseAfterLoad = pauseAfterLoad,
164 _color = color, 167 _color = color,
165 _packageRoot = packageRoot, 168 _packageRoot = packageRoot,
166 _reporter = reporter, 169 _reporter = reporter,
167 pubServeUrl = pubServePort == null 170 pubServeUrl = pubServePort == null
168 ? null 171 ? null
169 : Uri.parse("http://localhost:$pubServePort"), 172 : Uri.parse("http://localhost:$pubServePort"),
170 _concurrency = concurrency, 173 _concurrency = concurrency,
171 timeout = (pauseAfterLoad ?? false) 174 timeout = (pauseAfterLoad ?? false)
172 ? Timeout.none 175 ? Timeout.none
173 : (timeout == null ? new Timeout.factor(1) : timeout), 176 : (timeout == null ? new Timeout.factor(1) : timeout),
174 _platforms = _list(platforms), 177 _platforms = _list(platforms),
175 _paths = _list(paths), 178 _paths = _list(paths),
176 _filename = filename, 179 _filename = filename,
177 includeTags = includeTags?.toSet() ?? new Set(), 180 includeTags = includeTags ?? BooleanSelector.all,
178 excludeTags = excludeTags?.toSet() ?? new Set(), 181 excludeTags = excludeTags ?? BooleanSelector.none,
179 addTags = addTags?.toSet() ?? new Set(), 182 addTags = addTags?.toSet() ?? new Set(),
180 tags = tags == null ? const {} : new Map.unmodifiable(tags) { 183 tags = tags == null ? const {} : new Map.unmodifiable(tags) {
181 if (_filename != null && _filename.context.style != p.style) { 184 if (_filename != null && _filename.context.style != p.style) {
182 throw new ArgumentError( 185 throw new ArgumentError(
183 "filename's context must match the current operating system, was " 186 "filename's context must match the current operating system, was "
184 "${_filename.context.style}."); 187 "${_filename.context.style}.");
185 } 188 }
186 } 189 }
187 190
188 /// Returns a [input] as a list or `null`. 191 /// Returns a [input] as a list or `null`.
(...skipping 22 matching lines...) Expand all
211 color: other._color ?? _color, 214 color: other._color ?? _color,
212 packageRoot: other._packageRoot ?? _packageRoot, 215 packageRoot: other._packageRoot ?? _packageRoot,
213 reporter: other._reporter ?? _reporter, 216 reporter: other._reporter ?? _reporter,
214 pubServePort: (other.pubServeUrl ?? pubServeUrl)?.port, 217 pubServePort: (other.pubServeUrl ?? pubServeUrl)?.port,
215 concurrency: other._concurrency ?? _concurrency, 218 concurrency: other._concurrency ?? _concurrency,
216 timeout: timeout.merge(other.timeout), 219 timeout: timeout.merge(other.timeout),
217 pattern: other.pattern ?? pattern, 220 pattern: other.pattern ?? pattern,
218 platforms: other._platforms ?? _platforms, 221 platforms: other._platforms ?? _platforms,
219 paths: other._paths ?? _paths, 222 paths: other._paths ?? _paths,
220 filename: other._filename ?? _filename, 223 filename: other._filename ?? _filename,
221 includeTags: other.includeTags.union(includeTags), 224 includeTags: includeTags.intersection(other.includeTags),
222 excludeTags: other.excludeTags.union(excludeTags), 225 excludeTags: excludeTags.union(other.excludeTags),
223 addTags: other.addTags.union(addTags), 226 addTags: other.addTags.union(addTags),
224 tags: mergeMaps(tags, other.tags, 227 tags: mergeMaps(tags, other.tags,
225 value: (config1, config2) => config1.merge(config2))); 228 value: (config1, config2) => config1.merge(config2)));
226 } 229 }
227 } 230 }
OLDNEW
« no previous file with comments | « lib/src/runner.dart ('k') | lib/src/runner/configuration/args.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698