Skip to content

Commit 684efac

Browse files
NoProfile in ToolTaskThatTimeoutAndRetry test (#8659)
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.
1 parent ac3f5ad commit 684efac

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Utilities.UnitTests/ToolTask_Tests.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,10 +846,12 @@ public void ToolTaskThatTimeoutAndRetry(int repeats, int initialDelay, int follo
846846
{
847847
using var env = TestEnvironment.Create(_output);
848848

849+
MockEngine engine = new();
850+
849851
// Task under test:
850852
var task = new ToolTaskThatSleeps
851853
{
852-
BuildEngine = new MockEngine(),
854+
BuildEngine = engine,
853855
InitialDelay = initialDelay,
854856
FollowupDelay = followupDelay,
855857
Timeout = timeout
@@ -861,6 +863,9 @@ public void ToolTaskThatTimeoutAndRetry(int repeats, int initialDelay, int follo
861863
{
862864
// Execute the task:
863865
result = task.Execute();
866+
867+
_output.WriteLine(engine.Log);
868+
864869
task.RepeatCount.ShouldBe(i);
865870

866871
// 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
882887
private sealed class ToolTaskThatSleeps : ToolTask
883888
{
884889
// PowerShell command to sleep:
885-
private readonly string _powerShellSleep = "-ExecutionPolicy RemoteSigned -Command \"Start-Sleep -Milliseconds {0}\"";
890+
private readonly string _powerShellSleep = "-NoProfile -ExecutionPolicy RemoteSigned -Command \"Start-Sleep -Milliseconds {0}\"";
886891

887892
// UNIX command to sleep:
888893
private readonly string _unixSleep = "-c \"sleep {0}\"";

0 commit comments

Comments
 (0)