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:async'; | 5 import 'dart:async'; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 | 7 |
8 import 'package:async/async.dart'; | 8 import 'package:async/async.dart'; |
9 | 9 |
10 import 'backend/group.dart'; | 10 import 'backend/group.dart'; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 return loadSuite.changeSuite((suite) { | 195 return loadSuite.changeSuite((suite) { |
196 _warnForUnknownTags(suite); | 196 _warnForUnknownTags(suite); |
197 | 197 |
198 return suite.filter((test) { | 198 return suite.filter((test) { |
199 // Skip any tests that don't match the given pattern. | 199 // Skip any tests that don't match the given pattern. |
200 if (_config.pattern != null && !test.name.contains(_config.pattern)) { | 200 if (_config.pattern != null && !test.name.contains(_config.pattern)) { |
201 return false; | 201 return false; |
202 } | 202 } |
203 | 203 |
204 // If the user provided tags, skip tests that don't match all of them. | 204 // If the user provided tags, skip tests that don't match all of them. |
205 if (!_config.tags.isEmpty && | 205 if (!_config.includeTags.isEmpty && |
206 !test.metadata.tags.containsAll(_config.tags)) { | 206 !test.metadata.tags.containsAll(_config.includeTags)) { |
207 return false; | 207 return false; |
208 } | 208 } |
209 | 209 |
210 // Skip tests that do match any tags the user wants to exclude. | 210 // Skip tests that do match any tags the user wants to exclude. |
211 if (_config.excludeTags.intersection(test.metadata.tags).isNotEmpty) { | 211 if (_config.excludeTags.intersection(test.metadata.tags).isNotEmpty) { |
212 return false; | 212 return false; |
213 } | 213 } |
214 | 214 |
215 return true; | 215 return true; |
216 }); | 216 }); |
(...skipping 12 matching lines...) Expand all Loading... |
229 | 229 |
230 var yellow = _config.color ? '\u001b[33m' : ''; | 230 var yellow = _config.color ? '\u001b[33m' : ''; |
231 var bold = _config.color ? '\u001b[1m' : ''; | 231 var bold = _config.color ? '\u001b[1m' : ''; |
232 var noColor = _config.color ? '\u001b[0m' : ''; | 232 var noColor = _config.color ? '\u001b[0m' : ''; |
233 | 233 |
234 var buffer = new StringBuffer() | 234 var buffer = new StringBuffer() |
235 ..write("${yellow}Warning:$noColor ") | 235 ..write("${yellow}Warning:$noColor ") |
236 ..write(unknownTags.length == 1 ? "A tag was " : "Tags were ") | 236 ..write(unknownTags.length == 1 ? "A tag was " : "Tags were ") |
237 ..write("used that ") | 237 ..write("used that ") |
238 ..write(unknownTags.length == 1 ? "wasn't " : "weren't ") | 238 ..write(unknownTags.length == 1 ? "wasn't " : "weren't ") |
239 ..writeln("specified on the command line."); | 239 ..writeln("specified in dart_test.yaml."); |
240 | 240 |
241 unknownTags.forEach((tag, entries) { | 241 unknownTags.forEach((tag, entries) { |
242 buffer.write(" $bold$tag$noColor was used in"); | 242 buffer.write(" $bold$tag$noColor was used in"); |
243 | 243 |
244 if (entries.length == 1) { | 244 if (entries.length == 1) { |
245 buffer.writeln(" ${_entryDescription(entries.single)}"); | 245 buffer.writeln(" ${_entryDescription(entries.single)}"); |
246 return; | 246 return; |
247 } | 247 } |
248 | 248 |
249 buffer.write(":"); | 249 buffer.write(":"); |
250 for (var entry in entries) { | 250 for (var entry in entries) { |
251 buffer.write("\n ${_entryDescription(entry)}"); | 251 buffer.write("\n ${_entryDescription(entry)}"); |
252 } | 252 } |
253 buffer.writeln(); | 253 buffer.writeln(); |
254 }); | 254 }); |
255 | 255 |
256 print(buffer.toString()); | 256 print(buffer.toString()); |
257 } | 257 } |
258 | 258 |
259 /// Collects all tags used by [suite] or its children that aren't also passed | 259 /// Collects all tags used by [suite] or its children that aren't also passed |
260 /// on the command line. | 260 /// on the command line. |
261 /// | 261 /// |
262 /// This returns a map from tag names to lists of entries that use those tags. | 262 /// This returns a map from tag names to lists of entries that use those tags. |
263 Map<String, List<GroupEntry>> _collectUnknownTags(Suite suite) { | 263 Map<String, List<GroupEntry>> _collectUnknownTags(Suite suite) { |
264 var knownTags = _config.tags.union(_config.excludeTags); | |
265 var unknownTags = {}; | 264 var unknownTags = {}; |
266 var currentTags = new Set(); | 265 var currentTags = new Set(); |
267 | 266 |
268 collect(entry) { | 267 collect(entry) { |
269 var newTags = new Set(); | 268 var newTags = new Set(); |
270 for (var unknownTag in entry.metadata.tags.difference(knownTags)) { | 269 for (var unknownTag in |
| 270 entry.metadata.tags.difference(_config.knownTags)) { |
271 if (currentTags.contains(unknownTag)) continue; | 271 if (currentTags.contains(unknownTag)) continue; |
272 unknownTags.putIfAbsent(unknownTag, () => []).add(entry); | 272 unknownTags.putIfAbsent(unknownTag, () => []).add(entry); |
273 newTags.add(unknownTag); | 273 newTags.add(unknownTag); |
274 } | 274 } |
275 | 275 |
276 if (entry is! Group) return; | 276 if (entry is! Group) return; |
277 | 277 |
278 currentTags.addAll(newTags); | 278 currentTags.addAll(newTags); |
279 for (var child in entry.entries) { | 279 for (var child in entry.entries) { |
280 collect(child); | 280 collect(child); |
(...skipping 25 matching lines...) Expand all Loading... |
306 await _debugOperation.valueOrCancellation(); | 306 await _debugOperation.valueOrCancellation(); |
307 }).listen(null); | 307 }).listen(null); |
308 | 308 |
309 var results = await Future.wait([ | 309 var results = await Future.wait([ |
310 _suiteSubscription.asFuture().then((_) => _engine.suiteSink.close()), | 310 _suiteSubscription.asFuture().then((_) => _engine.suiteSink.close()), |
311 _engine.run() | 311 _engine.run() |
312 ]); | 312 ]); |
313 return results.last; | 313 return results.last; |
314 } | 314 } |
315 } | 315 } |
OLD | NEW |