From 49300273e0471680dd50235050272b482f75cf3b Mon Sep 17 00:00:00 2001 From: benbierens Date: Tue, 31 Oct 2023 15:33:00 +0100 Subject: [PATCH] Cleanup continuous tests nicely even if no tests were selected for running. --- .../ContinuousTestRunner.cs | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Tests/CodexContinuousTests/ContinuousTestRunner.cs b/Tests/CodexContinuousTests/ContinuousTestRunner.cs index 2566d1d..8461f7f 100644 --- a/Tests/CodexContinuousTests/ContinuousTestRunner.cs +++ b/Tests/CodexContinuousTests/ContinuousTestRunner.cs @@ -53,22 +53,25 @@ namespace ContinuousTests if (!filteredTests.Any()) { overviewLog.Log("No tests selected."); - return; + Cancellation.Cts.Cancel(); } - var testLoops = filteredTests.Select(t => new TestLoop(entryPointFactory, taskFactory, config, overviewLog, t.GetType(), t.RunTestEvery, startupChecker, cancelToken)).ToArray(); - - foreach (var testLoop in testLoops) + else { - if (cancelToken.IsCancellationRequested) break; + var testLoops = filteredTests.Select(t => new TestLoop(entryPointFactory, taskFactory, config, overviewLog, t.GetType(), t.RunTestEvery, startupChecker, cancelToken)).ToArray(); - overviewLog.Log("Launching test-loop for " + testLoop.Name); - testLoop.Begin(); - Thread.Sleep(TimeSpan.FromSeconds(5)); + foreach (var testLoop in testLoops) + { + if (cancelToken.IsCancellationRequested) break; + + overviewLog.Log("Launching test-loop for " + testLoop.Name); + testLoop.Begin(); + Thread.Sleep(TimeSpan.FromSeconds(5)); + } + + overviewLog.Log("Finished launching test-loops."); + WaitUntilFinished(overviewLog, statusLog, startTime, testLoops); + overviewLog.Log("Stopping all test-loops..."); } - - overviewLog.Log("Finished launching test-loops."); - WaitUntilFinished(overviewLog, statusLog, startTime, testLoops); - overviewLog.Log("Stopping all test-loops..."); taskFactory.WaitAll(); overviewLog.Log("All tasks cancelled.");