@@ -36,15 +36,10 @@ import 'util/iterable_set.dart';
36
36
///
37
37
/// The engine has some special logic for [LoadSuite] s and the tests they
38
38
/// contain, referred to as "load tests". Load tests exist to provide visibility
39
- /// into the process of loading test files, but as long as that process is
40
- /// proceeding normally users usually don't care about it, so the engine only
41
- /// surfaces running load tests (that is, includes them in [liveTests] and other
42
- /// collections) under specific circumstances.
43
- ///
44
- /// If only load tests are running, exactly one load test will be in [active]
45
- /// and [liveTests] . If this test passes, it will be removed from both [active]
46
- /// and [liveTests] and *will not* be added to [passed] . If at any point a load
47
- /// test fails, it will be added to [failed] and [liveTests] .
39
+ /// into the process of loading test files. As long as that process is
40
+ /// proceeding normally users usually don't care about it, so the engine does
41
+ /// not include them in [liveTests] and other collections.
42
+ /// If a load test fails, it will be added to [failed] and [liveTests] .
48
43
///
49
44
/// The test suite loaded by a load suite will be automatically be run by the
50
45
/// engine; it doesn't need to be added to [suiteSink] manually.
@@ -174,22 +169,22 @@ class Engine {
174
169
Set <LiveTest > get failed => _failedGroup.set ;
175
170
final _failedGroup = UnionSetController <LiveTest >(disjoint: true );
176
171
177
- /// The tests that are still running, in the order they begain running.
172
+ /// The tests that are still running, in the order they began running.
178
173
List <LiveTest > get active => UnmodifiableListView (_active);
179
174
final _active = QueueList <LiveTest >();
180
175
176
+ /// The tests from [LoadSuite] s that are still running, in the order they
177
+ /// began running.
178
+ List <LiveTest > get activeSuiteLoads =>
179
+ UnmodifiableListView (_activeSuiteLoads);
180
+ final _activeSuiteLoads = < LiveTest > {};
181
+
181
182
/// The set of tests that have been marked for restarting.
182
183
///
183
184
/// This is always a subset of [active] . Once a test in here has finished
184
185
/// running, it's run again.
185
186
final _restarted = < LiveTest > {};
186
187
187
- /// The tests from [LoadSuite] s that are still running, in the order they
188
- /// began running.
189
- ///
190
- /// This is separate from [active] because load tests aren't always surfaced.
191
- final _activeLoadTests = < LiveTest > {};
192
-
193
188
/// Whether this engine is idle—that is, not currently executing a test.
194
189
bool get isIdle => _group.isIdle;
195
190
@@ -356,21 +351,11 @@ class Engine {
356
351
await _onUnpaused;
357
352
_active.add (liveTest);
358
353
359
- // If there were no active non-load tests, the current active test would
360
- // have been a load test. In that case, remove it, since now we have a
361
- // non-load test to add.
362
- if (_active.first.suite is LoadSuite ) _active.removeFirst ();
363
-
364
354
var subscription = liveTest.onStateChange.listen (null );
365
355
subscription
366
356
..onData ((state) {
367
357
if (state.status != Status .complete) return ;
368
358
_active.remove (liveTest);
369
-
370
- // If we're out of non-load tests, surface a load test.
371
- if (_active.isEmpty && _activeLoadTests.isNotEmpty) {
372
- _active.add (_activeLoadTests.first);
373
- }
374
359
})
375
360
..onDone (() {
376
361
_subscriptions.remove (subscription);
@@ -425,7 +410,7 @@ class Engine {
425
410
///
426
411
/// Returns the same future as [LiveTest.close] .
427
412
Future restartTest (LiveTest liveTest) async {
428
- if (_activeLoadTests .contains (liveTest)) {
413
+ if (_activeSuiteLoads .contains (liveTest)) {
429
414
throw ArgumentError ("Can't restart a load test." );
430
415
}
431
416
@@ -447,24 +432,13 @@ class Engine {
447
432
_addLiveSuite (controller.liveSuite);
448
433
449
434
var liveTest = suite.test.load (suite);
450
- _activeLoadTests.add (liveTest);
451
-
452
- // Only surface the load test if there are no other tests currently running.
453
- if (_active.isEmpty) _active.add (liveTest);
435
+ _activeSuiteLoads.add (liveTest);
454
436
455
437
var subscription = liveTest.onStateChange.listen (null );
456
438
subscription
457
439
..onData ((state) {
458
440
if (state.status != Status .complete) return ;
459
- _activeLoadTests.remove (liveTest);
460
-
461
- // Only one load test will be active at any given time, and it will always
462
- // be the only active test. Remove it and, if possible, surface another
463
- // load test.
464
- if (_active.isNotEmpty && _active.first.suite == suite) {
465
- _active.remove (liveTest);
466
- if (_activeLoadTests.isNotEmpty) _active.add (_activeLoadTests.last);
467
- }
441
+ _activeSuiteLoads.remove (liveTest);
468
442
})
469
443
..onDone (() {
470
444
_subscriptions.remove (subscription);
@@ -547,7 +521,7 @@ class Engine {
547
521
548
522
// Close the running tests first so that we're sure to wait for them to
549
523
// finish before we close their suites and cause them to become unloaded.
550
- var allLiveTests = liveTests.toSet ()..addAll (_activeLoadTests );
524
+ var allLiveTests = liveTests.toSet ()..addAll (_activeSuiteLoads );
551
525
var futures = allLiveTests.map ((liveTest) => liveTest.close ()).toList ();
552
526
553
527
// Closing the run pool will close the test suites as soon as their tests
0 commit comments