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

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

Issue 1890853003: Add support for sharding test runs. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 8 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: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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 /// Whether to use command-line color escapes. 86 /// Whether to use command-line color escapes.
87 bool get color => _color ?? canUseSpecialChars; 87 bool get color => _color ?? canUseSpecialChars;
88 final bool _color; 88 final bool _color;
89 89
90 /// How many tests to run concurrently. 90 /// How many tests to run concurrently.
91 int get concurrency => 91 int get concurrency =>
92 pauseAfterLoad ? 1 : (_concurrency ?? defaultConcurrency); 92 pauseAfterLoad ? 1 : (_concurrency ?? defaultConcurrency);
93 final int _concurrency; 93 final int _concurrency;
94 94
95 /// The index of the current shard, if sharding is in use, or `null` if it's
96 /// not.
97 ///
98 /// Sharding is a technique that allows the Google internal test framework to
99 /// easily split a test run across multiple workers without requiring the
100 /// tests to be modified by the user. When sharding is in use, the runner gets
101 /// a shard index (this field) and a total number of shards, and is expected
102 /// to provide the following guarantees:
103 ///
104 /// * Running the same invocation of the runner, with the same shard index and
105 /// total shards, will run the same set of tests.
106 /// * Across all shards, each test must be run exactly once.
107 ///
108 /// In addition, tests should be balanced across shards as much as possible.
109 final int shardIndex;
110
111 /// The total number of shards, if sharding is in use, or `null` if it's not.
112 ///
113 /// See [shardIndex] for details.
114 final int totalShards;
115
95 /// The paths from which to load tests. 116 /// The paths from which to load tests.
96 List<String> get paths => _paths ?? ["test"]; 117 List<String> get paths => _paths ?? ["test"];
97 final List<String> _paths; 118 final List<String> _paths;
98 119
99 /// Whether the load paths were passed explicitly or the default was used. 120 /// Whether the load paths were passed explicitly or the default was used.
100 bool get explicitPaths => _paths != null; 121 bool get explicitPaths => _paths != null;
101 122
102 /// The glob matching the basename of tests to run. 123 /// The glob matching the basename of tests to run.
103 /// 124 ///
104 /// This is used to find tests within a directory. 125 /// This is used to find tests within a directory.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 bool jsTrace, 263 bool jsTrace,
243 bool skip, 264 bool skip,
244 String skipReason, 265 String skipReason,
245 PlatformSelector testOn, 266 PlatformSelector testOn,
246 bool pauseAfterLoad, 267 bool pauseAfterLoad,
247 bool color, 268 bool color,
248 String packageRoot, 269 String packageRoot,
249 String reporter, 270 String reporter,
250 int pubServePort, 271 int pubServePort,
251 int concurrency, 272 int concurrency,
273 int shardIndex,
274 int totalShards,
252 Timeout timeout, 275 Timeout timeout,
253 Iterable<Pattern> patterns, 276 Iterable<Pattern> patterns,
254 Iterable<TestPlatform> platforms, 277 Iterable<TestPlatform> platforms,
255 Iterable<String> paths, 278 Iterable<String> paths,
256 Glob filename, 279 Glob filename,
257 Iterable<String> chosenPresets, 280 Iterable<String> chosenPresets,
258 BooleanSelector includeTags, 281 BooleanSelector includeTags,
259 BooleanSelector excludeTags, 282 BooleanSelector excludeTags,
260 Iterable addTags, 283 Iterable addTags,
261 Map<BooleanSelector, Configuration> tags, 284 Map<BooleanSelector, Configuration> tags,
262 Map<PlatformSelector, Configuration> onPlatform, 285 Map<PlatformSelector, Configuration> onPlatform,
263 Map<String, Configuration> presets}) { 286 Map<String, Configuration> presets}) {
264 _unresolved() => new Configuration._( 287 _unresolved() => new Configuration._(
265 help: help, 288 help: help,
266 version: version, 289 version: version,
267 verboseTrace: verboseTrace, 290 verboseTrace: verboseTrace,
268 jsTrace: jsTrace, 291 jsTrace: jsTrace,
269 skip: skip, 292 skip: skip,
270 skipReason: skipReason, 293 skipReason: skipReason,
271 testOn: testOn, 294 testOn: testOn,
272 pauseAfterLoad: pauseAfterLoad, 295 pauseAfterLoad: pauseAfterLoad,
273 color: color, 296 color: color,
274 packageRoot: packageRoot, 297 packageRoot: packageRoot,
275 reporter: reporter, 298 reporter: reporter,
276 pubServePort: pubServePort, 299 pubServePort: pubServePort,
277 concurrency: concurrency, 300 concurrency: concurrency,
301 shardIndex: shardIndex,
302 totalShards: totalShards,
278 timeout: timeout, 303 timeout: timeout,
279 patterns: patterns, 304 patterns: patterns,
280 platforms: platforms, 305 platforms: platforms,
281 paths: paths, 306 paths: paths,
282 filename: filename, 307 filename: filename,
283 chosenPresets: chosenPresets, 308 chosenPresets: chosenPresets,
284 includeTags: includeTags, 309 includeTags: includeTags,
285 excludeTags: excludeTags, 310 excludeTags: excludeTags,
286 addTags: addTags, 311 addTags: addTags,
287 312
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 bool jsTrace, 357 bool jsTrace,
333 bool skip, 358 bool skip,
334 this.skipReason, 359 this.skipReason,
335 PlatformSelector testOn, 360 PlatformSelector testOn,
336 bool pauseAfterLoad, 361 bool pauseAfterLoad,
337 bool color, 362 bool color,
338 String packageRoot, 363 String packageRoot,
339 String reporter, 364 String reporter,
340 int pubServePort, 365 int pubServePort,
341 int concurrency, 366 int concurrency,
367 this.shardIndex,
368 this.totalShards,
342 Timeout timeout, 369 Timeout timeout,
343 Iterable<Pattern> patterns, 370 Iterable<Pattern> patterns,
344 Iterable<TestPlatform> platforms, 371 Iterable<TestPlatform> platforms,
345 Iterable<String> paths, 372 Iterable<String> paths,
346 Glob filename, 373 Glob filename,
347 Iterable<String> chosenPresets, 374 Iterable<String> chosenPresets,
348 BooleanSelector includeTags, 375 BooleanSelector includeTags,
349 BooleanSelector excludeTags, 376 BooleanSelector excludeTags,
350 Iterable addTags, 377 Iterable addTags,
351 Map<BooleanSelector, Configuration> tags, 378 Map<BooleanSelector, Configuration> tags,
(...skipping 26 matching lines...) Expand all
378 excludeTags = excludeTags ?? BooleanSelector.none, 405 excludeTags = excludeTags ?? BooleanSelector.none,
379 addTags = new UnmodifiableSetView(addTags?.toSet() ?? new Set()), 406 addTags = new UnmodifiableSetView(addTags?.toSet() ?? new Set()),
380 tags = _map(tags), 407 tags = _map(tags),
381 onPlatform = _map(onPlatform), 408 onPlatform = _map(onPlatform),
382 presets = _map(presets) { 409 presets = _map(presets) {
383 if (_filename != null && _filename.context.style != p.style) { 410 if (_filename != null && _filename.context.style != p.style) {
384 throw new ArgumentError( 411 throw new ArgumentError(
385 "filename's context must match the current operating system, was " 412 "filename's context must match the current operating system, was "
386 "${_filename.context.style}."); 413 "${_filename.context.style}.");
387 } 414 }
415
416 if ((shardIndex == null) != (totalShards == null)) {
417 throw new ArgumentError(
418 "shardIndex and totalShards may only be passed together.");
419 } else if (shardIndex != null) {
420 RangeError.checkValueInInterval(
421 shardIndex, 0, totalShards - 1, "shardIndex");
422 }
388 } 423 }
389 424
390 /// Returns a [input] as an unmodifiable list or `null`. 425 /// Returns a [input] as an unmodifiable list or `null`.
391 /// 426 ///
392 /// If [input] is `null` or empty, this returns `null`. Otherwise, it returns 427 /// If [input] is `null` or empty, this returns `null`. Otherwise, it returns
393 /// `input.toList()`. 428 /// `input.toList()`.
394 static List _list(Iterable input) { 429 static List _list(Iterable input) {
395 if (input == null) return null; 430 if (input == null) return null;
396 input = new List.unmodifiable(input); 431 input = new List.unmodifiable(input);
397 if (input.isEmpty) return null; 432 if (input.isEmpty) return null;
(...skipping 22 matching lines...) Expand all
420 jsTrace: other._jsTrace ?? _jsTrace, 455 jsTrace: other._jsTrace ?? _jsTrace,
421 skip: other._skip ?? _skip, 456 skip: other._skip ?? _skip,
422 skipReason: other.skipReason ?? skipReason, 457 skipReason: other.skipReason ?? skipReason,
423 testOn: testOn.intersection(other.testOn), 458 testOn: testOn.intersection(other.testOn),
424 pauseAfterLoad: other._pauseAfterLoad ?? _pauseAfterLoad, 459 pauseAfterLoad: other._pauseAfterLoad ?? _pauseAfterLoad,
425 color: other._color ?? _color, 460 color: other._color ?? _color,
426 packageRoot: other._packageRoot ?? _packageRoot, 461 packageRoot: other._packageRoot ?? _packageRoot,
427 reporter: other._reporter ?? _reporter, 462 reporter: other._reporter ?? _reporter,
428 pubServePort: (other.pubServeUrl ?? pubServeUrl)?.port, 463 pubServePort: (other.pubServeUrl ?? pubServeUrl)?.port,
429 concurrency: other._concurrency ?? _concurrency, 464 concurrency: other._concurrency ?? _concurrency,
465 shardIndex: other.shardIndex ?? shardIndex,
466 totalShards: other.totalShards ?? totalShards,
430 timeout: timeout.merge(other.timeout), 467 timeout: timeout.merge(other.timeout),
431 patterns: patterns.union(other.patterns), 468 patterns: patterns.union(other.patterns),
432 platforms: other._platforms ?? _platforms, 469 platforms: other._platforms ?? _platforms,
433 paths: other._paths ?? _paths, 470 paths: other._paths ?? _paths,
434 filename: other._filename ?? _filename, 471 filename: other._filename ?? _filename,
435 chosenPresets: chosenPresets.union(other.chosenPresets), 472 chosenPresets: chosenPresets.union(other.chosenPresets),
436 includeTags: includeTags.intersection(other.includeTags), 473 includeTags: includeTags.intersection(other.includeTags),
437 excludeTags: excludeTags.union(other.excludeTags), 474 excludeTags: excludeTags.union(other.excludeTags),
438 addTags: other.addTags.union(addTags), 475 addTags: other.addTags.union(addTags),
439 tags: _mergeConfigMaps(tags, other.tags), 476 tags: _mergeConfigMaps(tags, other.tags),
(...skipping 17 matching lines...) Expand all
457 bool jsTrace, 494 bool jsTrace,
458 bool skip, 495 bool skip,
459 String skipReason, 496 String skipReason,
460 PlatformSelector testOn, 497 PlatformSelector testOn,
461 bool pauseAfterLoad, 498 bool pauseAfterLoad,
462 bool color, 499 bool color,
463 String packageRoot, 500 String packageRoot,
464 String reporter, 501 String reporter,
465 int pubServePort, 502 int pubServePort,
466 int concurrency, 503 int concurrency,
504 int shardIndex,
505 int totalShards,
467 Timeout timeout, 506 Timeout timeout,
468 Iterable<Pattern> patterns, 507 Iterable<Pattern> patterns,
469 Iterable<TestPlatform> platforms, 508 Iterable<TestPlatform> platforms,
470 Iterable<String> paths, 509 Iterable<String> paths,
471 Glob filename, 510 Glob filename,
472 Iterable<String> chosenPresets, 511 Iterable<String> chosenPresets,
473 BooleanSelector includeTags, 512 BooleanSelector includeTags,
474 BooleanSelector excludeTags, 513 BooleanSelector excludeTags,
475 Iterable addTags, 514 Iterable addTags,
476 Map<BooleanSelector, Configuration> tags, 515 Map<BooleanSelector, Configuration> tags,
477 Map<PlatformSelector, Configuration> onPlatform, 516 Map<PlatformSelector, Configuration> onPlatform,
478 Map<String, Configuration> presets}) { 517 Map<String, Configuration> presets}) {
479 return new Configuration( 518 return new Configuration(
480 help: help ?? _help, 519 help: help ?? _help,
481 version: version ?? _version, 520 version: version ?? _version,
482 verboseTrace: verboseTrace ?? _verboseTrace, 521 verboseTrace: verboseTrace ?? _verboseTrace,
483 jsTrace: jsTrace ?? _jsTrace, 522 jsTrace: jsTrace ?? _jsTrace,
484 skip: skip ?? _skip, 523 skip: skip ?? _skip,
485 skipReason: skipReason ?? this.skipReason, 524 skipReason: skipReason ?? this.skipReason,
486 testOn: testOn ?? this.testOn, 525 testOn: testOn ?? this.testOn,
487 pauseAfterLoad: pauseAfterLoad ?? _pauseAfterLoad, 526 pauseAfterLoad: pauseAfterLoad ?? _pauseAfterLoad,
488 color: color ?? _color, 527 color: color ?? _color,
489 packageRoot: packageRoot ?? _packageRoot, 528 packageRoot: packageRoot ?? _packageRoot,
490 reporter: reporter ?? _reporter, 529 reporter: reporter ?? _reporter,
491 pubServePort: pubServePort ?? pubServeUrl?.port, 530 pubServePort: pubServePort ?? pubServeUrl?.port,
492 concurrency: concurrency ?? _concurrency, 531 concurrency: concurrency ?? _concurrency,
532 shardIndex: shardIndex ?? this.shardIndex,
533 totalShards: totalShards ?? this.totalShards,
493 timeout: timeout ?? this.timeout, 534 timeout: timeout ?? this.timeout,
494 patterns: patterns ?? this.patterns, 535 patterns: patterns ?? this.patterns,
495 platforms: platforms ?? _platforms, 536 platforms: platforms ?? _platforms,
496 paths: paths ?? _paths, 537 paths: paths ?? _paths,
497 filename: filename ?? _filename, 538 filename: filename ?? _filename,
498 chosenPresets: chosenPresets ?? this.chosenPresets, 539 chosenPresets: chosenPresets ?? this.chosenPresets,
499 includeTags: includeTags ?? this.includeTags, 540 includeTags: includeTags ?? this.includeTags,
500 excludeTags: excludeTags ?? this.excludeTags, 541 excludeTags: excludeTags ?? this.excludeTags,
501 addTags: addTags ?? this.addTags, 542 addTags: addTags ?? this.addTags,
502 tags: tags ?? this.tags, 543 tags: tags ?? this.tags,
503 onPlatform: onPlatform ?? this.onPlatform, 544 onPlatform: onPlatform ?? this.onPlatform,
504 presets: presets ?? this.presets); 545 presets: presets ?? this.presets);
505 } 546 }
506 547
507 /// Merges two maps whose values are [Configuration]s. 548 /// Merges two maps whose values are [Configuration]s.
508 /// 549 ///
509 /// Any overlapping keys in the maps have their configurations merged in the 550 /// Any overlapping keys in the maps have their configurations merged in the
510 /// returned map. 551 /// returned map.
511 Map<Object, Configuration> _mergeConfigMaps(Map<Object, Configuration> map1, 552 Map<Object, Configuration> _mergeConfigMaps(Map<Object, Configuration> map1,
512 Map<Object, Configuration> map2) => 553 Map<Object, Configuration> map2) =>
513 mergeMaps(map1, map2, 554 mergeMaps(map1, map2,
514 value: (config1, config2) => config1.merge(config2)); 555 value: (config1, config2) => config1.merge(config2));
515 } 556 }
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