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

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

Issue 1879823002: Don't track hidden tests in Engine. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: 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 | « no previous file | no next file » | 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:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 7
8 import 'package:async/async.dart' hide Result; 8 import 'package:async/async.dart' hide Result;
9 import 'package:collection/collection.dart'; 9 import 'package:collection/collection.dart';
10 import 'package:pool/pool.dart'; 10 import 'package:pool/pool.dart';
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 final _skipped = new Set<LiveTest>(); 140 final _skipped = new Set<LiveTest>();
141 141
142 /// The set of tests that have completed and been marked as failing or error. 142 /// The set of tests that have completed and been marked as failing or error.
143 Set<LiveTest> get failed => new UnmodifiableSetView(_failed); 143 Set<LiveTest> get failed => new UnmodifiableSetView(_failed);
144 final _failed = new Set<LiveTest>(); 144 final _failed = new Set<LiveTest>();
145 145
146 /// The tests that are still running, in the order they begain running. 146 /// The tests that are still running, in the order they begain running.
147 List<LiveTest> get active => new UnmodifiableListView(_active); 147 List<LiveTest> get active => new UnmodifiableListView(_active);
148 final _active = new QueueList<LiveTest>(); 148 final _active = new QueueList<LiveTest>();
149 149
150 /// The set of tests that have completed successfully but shouldn't be
151 /// displayed by the reporter.
152 ///
153 /// This includes load tests, `setUpAll`, and `tearDownAll`.
154 final _hidden = new Set<LiveTest>();
155
156 /// The set of tests that have been marked for restarting. 150 /// The set of tests that have been marked for restarting.
157 /// 151 ///
158 /// This is always a subset of [active]. Once a test in here has finished 152 /// This is always a subset of [active]. Once a test in here has finished
159 /// running, it's run again. 153 /// running, it's run again.
160 final _restarted = new Set<LiveTest>(); 154 final _restarted = new Set<LiveTest>();
161 155
162 /// The tests from [LoadSuite]s that are still running, in the order they 156 /// The tests from [LoadSuite]s that are still running, in the order they
163 /// began running. 157 /// began running.
164 /// 158 ///
165 /// This is separate from [active] because load tests aren't always surfaced. 159 /// This is separate from [active] because load tests aren't always surfaced.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 326
333 if (state.result != Result.success) { 327 if (state.result != Result.success) {
334 _passed.remove(liveTest); 328 _passed.remove(liveTest);
335 _failed.add(liveTest); 329 _failed.add(liveTest);
336 } else if (liveTest.test.metadata.skip) { 330 } else if (liveTest.test.metadata.skip) {
337 _skipped.add(liveTest); 331 _skipped.add(liveTest);
338 } else if (countSuccess) { 332 } else if (countSuccess) {
339 _passed.add(liveTest); 333 _passed.add(liveTest);
340 } else { 334 } else {
341 _liveTests.remove(liveTest); 335 _liveTests.remove(liveTest);
342 _hidden.add(liveTest);
343 } 336 }
344 }); 337 });
345 338
346 _onTestStartedController.add(liveTest); 339 _onTestStartedController.add(liveTest);
347 340
348 // First, schedule a microtask to ensure that [onTestStarted] fires before 341 // First, schedule a microtask to ensure that [onTestStarted] fires before
349 // the first [LiveTest.onStateChange] event. Once the test finishes, use 342 // the first [LiveTest.onStateChange] event. Once the test finishes, use
350 // [new Future] to do a coarse-grained event loop pump to avoid starving 343 // [new Future] to do a coarse-grained event loop pump to avoid starving
351 // non-microtask events. 344 // non-microtask events.
352 await new Future.microtask(liveTest.run); 345 await new Future.microtask(liveTest.run);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 _active.remove(liveTest); 394 _active.remove(liveTest);
402 _liveTests.remove(liveTest); 395 _liveTests.remove(liveTest);
403 396
404 if (_activeLoadTests.isNotEmpty) { 397 if (_activeLoadTests.isNotEmpty) {
405 _active.add(_activeLoadTests.last); 398 _active.add(_activeLoadTests.last);
406 _liveTests.add(_activeLoadTests.last); 399 _liveTests.add(_activeLoadTests.last);
407 } 400 }
408 } 401 }
409 402
410 // Surface the load test if it fails so that the user can see the failure. 403 // Surface the load test if it fails so that the user can see the failure.
411 if (state.result == Result.success) { 404 if (state.result == Result.success) return;
412 _hidden.add(liveTest); 405 _failed.add(liveTest);
413 } else { 406 _liveTests.add(liveTest);
414 _failed.add(liveTest);
415 _liveTests.add(liveTest);
416 }
417 }); 407 });
418 408
419 // Run the test immediately. We don't want loading to be blocked on suites 409 // Run the test immediately. We don't want loading to be blocked on suites
420 // that are already running. 410 // that are already running.
421 _onTestStartedController.add(liveTest); 411 _onTestStartedController.add(liveTest);
422 await liveTest.run(); 412 await liveTest.run();
423 413
424 return suite.suite; 414 return suite.suite;
425 } 415 }
426 416
427 /// Signals that the caller is done paying attention to test results and the 417 /// Signals that the caller is done paying attention to test results and the
428 /// engine should release any resources it has allocated. 418 /// engine should release any resources it has allocated.
429 /// 419 ///
430 /// Any actively-running tests are also closed. VM tests are allowed to finish 420 /// Any actively-running tests are also closed. VM tests are allowed to finish
431 /// running so that any modifications they've made to the filesystem can be 421 /// running so that any modifications they've made to the filesystem can be
432 /// cleaned up. 422 /// cleaned up.
433 /// 423 ///
434 /// **Note that closing the engine is not the same as closing [suiteSink].** 424 /// **Note that closing the engine is not the same as closing [suiteSink].**
435 /// Closing [suiteSink] indicates that no more input will be provided, closing 425 /// Closing [suiteSink] indicates that no more input will be provided, closing
436 /// the engine indicates that no more output should be emitted. 426 /// the engine indicates that no more output should be emitted.
437 Future close() async { 427 Future close() async {
438 _closed = true; 428 _closed = true;
439 if (_closedBeforeDone != null) _closedBeforeDone = true; 429 if (_closedBeforeDone != null) _closedBeforeDone = true;
440 _onSuiteAddedController.close(); 430 _onSuiteAddedController.close();
441 _suiteController.close(); 431 _suiteController.close();
442 432
443 // Close the running tests first so that we're sure to wait for them to 433 // Close the running tests first so that we're sure to wait for them to
444 // finish before we close their suites and cause them to become unloaded. 434 // finish before we close their suites and cause them to become unloaded.
445 var allLiveTests = liveTests.toSet() 435 var allLiveTests = liveTests.toSet()..addAll(_activeLoadTests);
446 ..addAll(_activeLoadTests)
447 ..addAll(_hidden);
448 var futures = allLiveTests.map((liveTest) => liveTest.close()).toList(); 436 var futures = allLiveTests.map((liveTest) => liveTest.close()).toList();
449 437
450 // Closing the load pool will close the test suites as soon as their tests 438 // Closing the load pool will close the test suites as soon as their tests
451 // are done. For browser suites this is effectively immediate since their 439 // are done. For browser suites this is effectively immediate since their
452 // tests shut down as soon as they're closed, but for VM suites we may need 440 // tests shut down as soon as they're closed, but for VM suites we may need
453 // to wait for tearDowns or tearDownAlls to run. 441 // to wait for tearDowns or tearDownAlls to run.
454 futures.add(_loadPool.close()); 442 futures.add(_loadPool.close());
455 await Future.wait(futures, eagerError: true); 443 await Future.wait(futures, eagerError: true);
456 } 444 }
457 } 445 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698