Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ToolTaskThatTimeoutAndRetry test after change powershell.exe to cmd.exe #8800

Merged
merged 6 commits into from
May 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Utilities.UnitTests/ToolTask_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ protected override string GenerateCommandLineCommands()
/// predefined amount of time. The first execution may time out, but all following ones won't. It is expected
/// that all following executions return success.
/// </remarks>
[Theory(Skip = "https://github.com/dotnet/msbuild/issues/8750")]
[Theory]
[InlineData(1, 1, 1, -1)] // Normal case, no repeat.
[InlineData(3, 1, 1, -1)] // Repeat without timeout.
[InlineData(3, 10000, 1, 1000)] // Repeat with timeout.
Expand Down Expand Up @@ -886,8 +886,8 @@ public void ToolTaskThatTimeoutAndRetry(int repeats, int initialDelay, int follo
/// </remarks>
private sealed class ToolTaskThatSleeps : ToolTask
{
// PowerShell command to sleep:
private readonly string _powerShellSleep = "-NoProfile -ExecutionPolicy RemoteSigned -Command \"Start-Sleep -Milliseconds {0}\"";
// Windows prompt command to sleep:
private readonly string _windowsSleep = "/c start /wait timeout {0}";

// UNIX command to sleep:
private readonly string _unixSleep = "-c \"sleep {0}\"";
Expand All @@ -898,8 +898,8 @@ private sealed class ToolTaskThatSleeps : ToolTask
public ToolTaskThatSleeps()
: base()
{
// Determines shell to use: PowerShell for Windows, sh for UNIX-like systems:
_pathToShell = NativeMethodsShared.IsUnixLike ? "/bin/sh" : FindOnPath("PowerShell.exe");
// Determines shell to use: cmd for Windows, sh for UNIX-like systems:
_pathToShell = NativeMethodsShared.IsUnixLike ? "/bin/sh" : "cmd.exe";
}

/// <summary>
Expand Down Expand Up @@ -940,7 +940,7 @@ public ToolTaskThatSleeps()
protected override string GenerateCommandLineCommands() =>
NativeMethodsShared.IsUnixLike ?
string.Format(_unixSleep, RepeatCount < 2 ? InitialDelay / 1000.0 : FollowupDelay / 1000.0) :
string.Format(_powerShellSleep, RepeatCount < 2 ? InitialDelay : FollowupDelay);
string.Format(_windowsSleep, RepeatCount < 2 ? InitialDelay / 1000.0 : FollowupDelay / 1000.0);

/// <summary>
/// Ensures that test parameters make sense.
Expand Down