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; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 /// Whether the load paths were passed explicitly or the default was used. | 99 /// Whether the load paths were passed explicitly or the default was used. |
100 bool get explicitPaths => _paths != null; | 100 bool get explicitPaths => _paths != null; |
101 | 101 |
102 /// The glob matching the basename of tests to run. | 102 /// The glob matching the basename of tests to run. |
103 /// | 103 /// |
104 /// This is used to find tests within a directory. | 104 /// This is used to find tests within a directory. |
105 Glob get filename => _filename ?? defaultFilename; | 105 Glob get filename => _filename ?? defaultFilename; |
106 final Glob _filename; | 106 final Glob _filename; |
107 | 107 |
108 /// The pattern to match against test names to decide which to run, or `null` | 108 /// The patterns to match against test names to decide which to run, or `null` |
109 /// if all tests should be run. | 109 /// if all tests should be run. |
110 final Pattern pattern; | 110 /// |
| 111 /// All patterns must match in order for a test to be run. |
| 112 final Set<Pattern> patterns; |
111 | 113 |
112 /// The set of platforms on which to run tests. | 114 /// The set of platforms on which to run tests. |
113 List<TestPlatform> get platforms => _platforms ?? [TestPlatform.vm]; | 115 List<TestPlatform> get platforms => _platforms ?? [TestPlatform.vm]; |
114 final List<TestPlatform> _platforms; | 116 final List<TestPlatform> _platforms; |
115 | 117 |
116 /// The set of presets to use. | 118 /// The set of presets to use. |
117 /// | 119 /// |
118 /// Any chosen presets for the parent configuration are added to the chosen | 120 /// Any chosen presets for the parent configuration are added to the chosen |
119 /// preset sets for child configurations as well. | 121 /// preset sets for child configurations as well. |
120 /// | 122 /// |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 bool skip, | 239 bool skip, |
238 String skipReason, | 240 String skipReason, |
239 PlatformSelector testOn, | 241 PlatformSelector testOn, |
240 bool pauseAfterLoad, | 242 bool pauseAfterLoad, |
241 bool color, | 243 bool color, |
242 String packageRoot, | 244 String packageRoot, |
243 String reporter, | 245 String reporter, |
244 int pubServePort, | 246 int pubServePort, |
245 int concurrency, | 247 int concurrency, |
246 Timeout timeout, | 248 Timeout timeout, |
247 Pattern pattern, | 249 Iterable<Pattern> patterns, |
248 Iterable<TestPlatform> platforms, | 250 Iterable<TestPlatform> platforms, |
249 Iterable<String> paths, | 251 Iterable<String> paths, |
250 Glob filename, | 252 Glob filename, |
251 Iterable<String> chosenPresets, | 253 Iterable<String> chosenPresets, |
252 BooleanSelector includeTags, | 254 BooleanSelector includeTags, |
253 BooleanSelector excludeTags, | 255 BooleanSelector excludeTags, |
254 Iterable addTags, | 256 Iterable addTags, |
255 Map<BooleanSelector, Configuration> tags, | 257 Map<BooleanSelector, Configuration> tags, |
256 Map<PlatformSelector, Configuration> onPlatform, | 258 Map<PlatformSelector, Configuration> onPlatform, |
257 Map<String, Configuration> presets}) { | 259 Map<String, Configuration> presets}) { |
258 _unresolved() => new Configuration._( | 260 _unresolved() => new Configuration._( |
259 help: help, | 261 help: help, |
260 version: version, | 262 version: version, |
261 verboseTrace: verboseTrace, | 263 verboseTrace: verboseTrace, |
262 jsTrace: jsTrace, | 264 jsTrace: jsTrace, |
263 skip: skip, | 265 skip: skip, |
264 skipReason: skipReason, | 266 skipReason: skipReason, |
265 testOn: testOn, | 267 testOn: testOn, |
266 pauseAfterLoad: pauseAfterLoad, | 268 pauseAfterLoad: pauseAfterLoad, |
267 color: color, | 269 color: color, |
268 packageRoot: packageRoot, | 270 packageRoot: packageRoot, |
269 reporter: reporter, | 271 reporter: reporter, |
270 pubServePort: pubServePort, | 272 pubServePort: pubServePort, |
271 concurrency: concurrency, | 273 concurrency: concurrency, |
272 timeout: timeout, | 274 timeout: timeout, |
273 pattern: pattern, | 275 patterns: patterns, |
274 platforms: platforms, | 276 platforms: platforms, |
275 paths: paths, | 277 paths: paths, |
276 filename: filename, | 278 filename: filename, |
277 chosenPresets: chosenPresets, | 279 chosenPresets: chosenPresets, |
278 includeTags: includeTags, | 280 includeTags: includeTags, |
279 excludeTags: excludeTags, | 281 excludeTags: excludeTags, |
280 addTags: addTags, | 282 addTags: addTags, |
281 | 283 |
282 // Make sure we pass [chosenPresets] to the child configurations as | 284 // Make sure we pass [chosenPresets] to the child configurations as |
283 // well. This ensures that | 285 // well. This ensures that |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 bool skip, | 329 bool skip, |
328 this.skipReason, | 330 this.skipReason, |
329 PlatformSelector testOn, | 331 PlatformSelector testOn, |
330 bool pauseAfterLoad, | 332 bool pauseAfterLoad, |
331 bool color, | 333 bool color, |
332 String packageRoot, | 334 String packageRoot, |
333 String reporter, | 335 String reporter, |
334 int pubServePort, | 336 int pubServePort, |
335 int concurrency, | 337 int concurrency, |
336 Timeout timeout, | 338 Timeout timeout, |
337 this.pattern, | 339 Iterable<Pattern> patterns, |
338 Iterable<TestPlatform> platforms, | 340 Iterable<TestPlatform> platforms, |
339 Iterable<String> paths, | 341 Iterable<String> paths, |
340 Glob filename, | 342 Glob filename, |
341 Iterable<String> chosenPresets, | 343 Iterable<String> chosenPresets, |
342 BooleanSelector includeTags, | 344 BooleanSelector includeTags, |
343 BooleanSelector excludeTags, | 345 BooleanSelector excludeTags, |
344 Iterable addTags, | 346 Iterable addTags, |
345 Map<BooleanSelector, Configuration> tags, | 347 Map<BooleanSelector, Configuration> tags, |
346 Map<PlatformSelector, Configuration> onPlatform, | 348 Map<PlatformSelector, Configuration> onPlatform, |
347 Map<String, Configuration> presets}) | 349 Map<String, Configuration> presets}) |
348 : _help = help, | 350 : _help = help, |
349 _version = version, | 351 _version = version, |
350 _verboseTrace = verboseTrace, | 352 _verboseTrace = verboseTrace, |
351 _jsTrace = jsTrace, | 353 _jsTrace = jsTrace, |
352 _skip = skip, | 354 _skip = skip, |
353 testOn = testOn ?? PlatformSelector.all, | 355 testOn = testOn ?? PlatformSelector.all, |
354 _pauseAfterLoad = pauseAfterLoad, | 356 _pauseAfterLoad = pauseAfterLoad, |
355 _color = color, | 357 _color = color, |
356 _packageRoot = packageRoot, | 358 _packageRoot = packageRoot, |
357 _reporter = reporter, | 359 _reporter = reporter, |
358 pubServeUrl = pubServePort == null | 360 pubServeUrl = pubServePort == null |
359 ? null | 361 ? null |
360 : Uri.parse("http://localhost:$pubServePort"), | 362 : Uri.parse("http://localhost:$pubServePort"), |
361 _concurrency = concurrency, | 363 _concurrency = concurrency, |
362 timeout = (pauseAfterLoad ?? false) | 364 timeout = (pauseAfterLoad ?? false) |
363 ? Timeout.none | 365 ? Timeout.none |
364 : (timeout == null ? new Timeout.factor(1) : timeout), | 366 : (timeout == null ? new Timeout.factor(1) : timeout), |
| 367 patterns = new UnmodifiableSetView(patterns?.toSet() ?? new Set()), |
365 _platforms = _list(platforms), | 368 _platforms = _list(platforms), |
366 _paths = _list(paths), | 369 _paths = _list(paths), |
367 _filename = filename, | 370 _filename = filename, |
368 chosenPresets = new Set.from(chosenPresets ?? []), | 371 chosenPresets = new UnmodifiableSetView( |
| 372 chosenPresets?.toSet() ?? new Set()), |
369 includeTags = includeTags ?? BooleanSelector.all, | 373 includeTags = includeTags ?? BooleanSelector.all, |
370 excludeTags = excludeTags ?? BooleanSelector.none, | 374 excludeTags = excludeTags ?? BooleanSelector.none, |
371 addTags = new UnmodifiableSetView(addTags?.toSet() ?? new Set()), | 375 addTags = new UnmodifiableSetView(addTags?.toSet() ?? new Set()), |
372 tags = _map(tags), | 376 tags = _map(tags), |
373 onPlatform = _map(onPlatform), | 377 onPlatform = _map(onPlatform), |
374 presets = _map(presets) { | 378 presets = _map(presets) { |
375 if (_filename != null && _filename.context.style != p.style) { | 379 if (_filename != null && _filename.context.style != p.style) { |
376 throw new ArgumentError( | 380 throw new ArgumentError( |
377 "filename's context must match the current operating system, was " | 381 "filename's context must match the current operating system, was " |
378 "${_filename.context.style}."); | 382 "${_filename.context.style}."); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 skip: other._skip ?? _skip, | 417 skip: other._skip ?? _skip, |
414 skipReason: other.skipReason ?? skipReason, | 418 skipReason: other.skipReason ?? skipReason, |
415 testOn: testOn.intersection(other.testOn), | 419 testOn: testOn.intersection(other.testOn), |
416 pauseAfterLoad: other._pauseAfterLoad ?? _pauseAfterLoad, | 420 pauseAfterLoad: other._pauseAfterLoad ?? _pauseAfterLoad, |
417 color: other._color ?? _color, | 421 color: other._color ?? _color, |
418 packageRoot: other._packageRoot ?? _packageRoot, | 422 packageRoot: other._packageRoot ?? _packageRoot, |
419 reporter: other._reporter ?? _reporter, | 423 reporter: other._reporter ?? _reporter, |
420 pubServePort: (other.pubServeUrl ?? pubServeUrl)?.port, | 424 pubServePort: (other.pubServeUrl ?? pubServeUrl)?.port, |
421 concurrency: other._concurrency ?? _concurrency, | 425 concurrency: other._concurrency ?? _concurrency, |
422 timeout: timeout.merge(other.timeout), | 426 timeout: timeout.merge(other.timeout), |
423 pattern: other.pattern ?? pattern, | 427 patterns: patterns.union(other.patterns), |
424 platforms: other._platforms ?? _platforms, | 428 platforms: other._platforms ?? _platforms, |
425 paths: other._paths ?? _paths, | 429 paths: other._paths ?? _paths, |
426 filename: other._filename ?? _filename, | 430 filename: other._filename ?? _filename, |
427 chosenPresets: chosenPresets.union(other.chosenPresets), | 431 chosenPresets: chosenPresets.union(other.chosenPresets), |
428 includeTags: includeTags.intersection(other.includeTags), | 432 includeTags: includeTags.intersection(other.includeTags), |
429 excludeTags: excludeTags.union(other.excludeTags), | 433 excludeTags: excludeTags.union(other.excludeTags), |
430 addTags: other.addTags.union(addTags), | 434 addTags: other.addTags.union(addTags), |
431 tags: _mergeConfigMaps(tags, other.tags), | 435 tags: _mergeConfigMaps(tags, other.tags), |
432 onPlatform: _mergeConfigMaps(onPlatform, other.onPlatform), | 436 onPlatform: _mergeConfigMaps(onPlatform, other.onPlatform), |
433 presets: _mergeConfigMaps(presets, other.presets)); | 437 presets: _mergeConfigMaps(presets, other.presets)); |
(...skipping 16 matching lines...) Expand all Loading... |
450 bool skip, | 454 bool skip, |
451 String skipReason, | 455 String skipReason, |
452 PlatformSelector testOn, | 456 PlatformSelector testOn, |
453 bool pauseAfterLoad, | 457 bool pauseAfterLoad, |
454 bool color, | 458 bool color, |
455 String packageRoot, | 459 String packageRoot, |
456 String reporter, | 460 String reporter, |
457 int pubServePort, | 461 int pubServePort, |
458 int concurrency, | 462 int concurrency, |
459 Timeout timeout, | 463 Timeout timeout, |
460 Pattern pattern, | 464 Iterable<Pattern> patterns, |
461 Iterable<TestPlatform> platforms, | 465 Iterable<TestPlatform> platforms, |
462 Iterable<String> paths, | 466 Iterable<String> paths, |
463 Glob filename, | 467 Glob filename, |
464 Iterable<String> chosenPresets, | 468 Iterable<String> chosenPresets, |
465 BooleanSelector includeTags, | 469 BooleanSelector includeTags, |
466 BooleanSelector excludeTags, | 470 BooleanSelector excludeTags, |
467 Iterable addTags, | 471 Iterable addTags, |
468 Map<BooleanSelector, Configuration> tags, | 472 Map<BooleanSelector, Configuration> tags, |
469 Map<PlatformSelector, Configuration> onPlatform, | 473 Map<PlatformSelector, Configuration> onPlatform, |
470 Map<String, Configuration> presets}) { | 474 Map<String, Configuration> presets}) { |
471 return new Configuration( | 475 return new Configuration( |
472 help: help ?? _help, | 476 help: help ?? _help, |
473 version: version ?? _version, | 477 version: version ?? _version, |
474 verboseTrace: verboseTrace ?? _verboseTrace, | 478 verboseTrace: verboseTrace ?? _verboseTrace, |
475 jsTrace: jsTrace ?? _jsTrace, | 479 jsTrace: jsTrace ?? _jsTrace, |
476 skip: skip ?? _skip, | 480 skip: skip ?? _skip, |
477 skipReason: skipReason ?? this.skipReason, | 481 skipReason: skipReason ?? this.skipReason, |
478 testOn: testOn ?? this.testOn, | 482 testOn: testOn ?? this.testOn, |
479 pauseAfterLoad: pauseAfterLoad ?? _pauseAfterLoad, | 483 pauseAfterLoad: pauseAfterLoad ?? _pauseAfterLoad, |
480 color: color ?? _color, | 484 color: color ?? _color, |
481 packageRoot: packageRoot ?? _packageRoot, | 485 packageRoot: packageRoot ?? _packageRoot, |
482 reporter: reporter ?? _reporter, | 486 reporter: reporter ?? _reporter, |
483 pubServePort: pubServePort ?? pubServeUrl?.port, | 487 pubServePort: pubServePort ?? pubServeUrl?.port, |
484 concurrency: concurrency ?? _concurrency, | 488 concurrency: concurrency ?? _concurrency, |
485 timeout: timeout ?? this.timeout, | 489 timeout: timeout ?? this.timeout, |
486 pattern: pattern ?? this.pattern, | 490 patterns: patterns ?? this.patterns, |
487 platforms: platforms ?? _platforms, | 491 platforms: platforms ?? _platforms, |
488 paths: paths ?? _paths, | 492 paths: paths ?? _paths, |
489 filename: filename ?? _filename, | 493 filename: filename ?? _filename, |
490 chosenPresets: chosenPresets ?? this.chosenPresets, | 494 chosenPresets: chosenPresets ?? this.chosenPresets, |
491 includeTags: includeTags ?? this.includeTags, | 495 includeTags: includeTags ?? this.includeTags, |
492 excludeTags: excludeTags ?? this.excludeTags, | 496 excludeTags: excludeTags ?? this.excludeTags, |
493 addTags: addTags ?? this.addTags, | 497 addTags: addTags ?? this.addTags, |
494 tags: tags ?? this.tags, | 498 tags: tags ?? this.tags, |
495 onPlatform: onPlatform ?? this.onPlatform, | 499 onPlatform: onPlatform ?? this.onPlatform, |
496 presets: presets ?? this.presets); | 500 presets: presets ?? this.presets); |
497 } | 501 } |
498 | 502 |
499 /// Merges two maps whose values are [Configuration]s. | 503 /// Merges two maps whose values are [Configuration]s. |
500 /// | 504 /// |
501 /// Any overlapping keys in the maps have their configurations merged in the | 505 /// Any overlapping keys in the maps have their configurations merged in the |
502 /// returned map. | 506 /// returned map. |
503 Map<Object, Configuration> _mergeConfigMaps(Map<Object, Configuration> map1, | 507 Map<Object, Configuration> _mergeConfigMaps(Map<Object, Configuration> map1, |
504 Map<Object, Configuration> map2) => | 508 Map<Object, Configuration> map2) => |
505 mergeMaps(map1, map2, | 509 mergeMaps(map1, map2, |
506 value: (config1, config2) => config1.merge(config2)); | 510 value: (config1, config2) => config1.merge(config2)); |
507 } | 511 } |
OLD | NEW |