From fa69c80b41d3a00620f07428f6dce8bb6435072e Mon Sep 17 00:00:00 2001 From: Rainer Sigwald Date: Wed, 12 Apr 2023 15:18:03 -0500 Subject: [PATCH] NoProfile in ToolTaskThatTimeoutAndRetry test This failed for me in an unrelated PR and on my dev box and at least on my dev box it was because sometimes my PowerShell profile took longer than 1 second to process. Pass -NoProfile to avoid that time entirely when it's not necessary. In addition, save the engine's log to the test log to give some clues if the test fails again. --- src/Utilities.UnitTests/ToolTask_Tests.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Utilities.UnitTests/ToolTask_Tests.cs b/src/Utilities.UnitTests/ToolTask_Tests.cs index 06811207770..76d4dd912fb 100644 --- a/src/Utilities.UnitTests/ToolTask_Tests.cs +++ b/src/Utilities.UnitTests/ToolTask_Tests.cs @@ -846,10 +846,12 @@ public void ToolTaskThatTimeoutAndRetry(int repeats, int initialDelay, int follo { using var env = TestEnvironment.Create(_output); + MockEngine engine = new(); + // Task under test: var task = new ToolTaskThatSleeps { - BuildEngine = new MockEngine(), + BuildEngine = engine, InitialDelay = initialDelay, FollowupDelay = followupDelay, Timeout = timeout @@ -861,6 +863,9 @@ public void ToolTaskThatTimeoutAndRetry(int repeats, int initialDelay, int follo { // Execute the task: result = task.Execute(); + + _output.WriteLine(engine.Log); + task.RepeatCount.ShouldBe(i); // The first execution may fail (timeout), but all following ones should succeed: @@ -882,7 +887,7 @@ public void ToolTaskThatTimeoutAndRetry(int repeats, int initialDelay, int follo private sealed class ToolTaskThatSleeps : ToolTask { // PowerShell command to sleep: - private readonly string _powerShellSleep = "-ExecutionPolicy RemoteSigned -Command \"Start-Sleep -Milliseconds {0}\""; + private readonly string _powerShellSleep = "-NoProfile -ExecutionPolicy RemoteSigned -Command \"Start-Sleep -Milliseconds {0}\""; // UNIX command to sleep: private readonly string _unixSleep = "-c \"sleep {0}\"";