From 73c49b42c6a0c8e171d7c4b258b56ea2ac7da90b Mon Sep 17 00:00:00 2001 From: benbierens Date: Mon, 2 Oct 2023 09:24:01 +0200 Subject: [PATCH] Fixes incorrect log message when test run gets cancelled. --- .../ContinuousTestRunner.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Tests/CodexContinuousTests/ContinuousTestRunner.cs b/Tests/CodexContinuousTests/ContinuousTestRunner.cs index 1132106a..be7c6404 100644 --- a/Tests/CodexContinuousTests/ContinuousTestRunner.cs +++ b/Tests/CodexContinuousTests/ContinuousTestRunner.cs @@ -59,9 +59,9 @@ namespace ContinuousTests overviewLog.Log("Finished launching test-loops."); WaitUntilFinished(overviewLog, statusLog, startTime, testLoops); - overviewLog.Log("Cancelling all test-loops..."); + overviewLog.Log("Stopping all test-loops..."); taskFactory.WaitAll(); - overviewLog.Log("All tasks cancelled."); + overviewLog.Log("All tasks finished."); } private void WaitUntilFinished(LogSplitter overviewLog, StatusLog statusLog, DateTime startTime, TestLoop[] testLoops) @@ -72,16 +72,20 @@ namespace ContinuousTests if (config.TargetDurationSeconds > 0) { var targetDuration = TimeSpan.FromSeconds(config.TargetDurationSeconds); - cancelToken.WaitHandle.WaitOne(targetDuration); - Cancellation.Cts.Cancel(); - overviewLog.Log($"Congratulations! The targer duration has been reached! ({Time.FormatDuration(targetDuration)})"); - statusLog.ConcludeTest("Passed", testDuration, testData); + var wasCancelled = cancelToken.WaitHandle.WaitOne(targetDuration); + if (!wasCancelled) + { + Cancellation.Cts.Cancel(); + overviewLog.Log($"Congratulations! The targer duration has been reached! ({Time.FormatDuration(targetDuration)})"); + statusLog.ConcludeTest("Passed", testDuration, testData); + return; + } } else { cancelToken.WaitHandle.WaitOne(); - statusLog.ConcludeTest("Failed", testDuration, testData); } + statusLog.ConcludeTest("Failed", testDuration, testData); } private Dictionary FormatTestRuns(TestLoop[] testLoops)