From 01eda9c5bdd2e6ded4f7aa00a81533df575625e3 Mon Sep 17 00:00:00 2001 From: Adityanr <48587119+Adityanr@users.noreply.github.com> Date: Thu, 21 Oct 2021 00:07:35 +0530 Subject: [PATCH 1/4] Convert path to lowercase to repair flaky unit test fact FindOnPathSucceeds() at ToolTask_Tests.cs --- src/Utilities.UnitTests/ToolTask_Tests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utilities.UnitTests/ToolTask_Tests.cs b/src/Utilities.UnitTests/ToolTask_Tests.cs index f683c61ca7d..d4ac4233b3c 100644 --- a/src/Utilities.UnitTests/ToolTask_Tests.cs +++ b/src/Utilities.UnitTests/ToolTask_Tests.cs @@ -683,7 +683,7 @@ public void FindOnPathSucceeds() string shellName; if (NativeMethodsShared.IsWindows) { - expectedCmdPath = new[] { Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "cmd.exe") }; + expectedCmdPath = new[] { Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System).ToLower(), "cmd.exe") }; shellName = "cmd.exe"; } else @@ -692,7 +692,7 @@ public void FindOnPathSucceeds() shellName = "sh"; } - string cmdPath = ToolTask.FindOnPath(shellName); + string cmdPath = ToolTask.FindOnPath(shellName).ToLower(); cmdPath.ShouldBeOneOf(expectedCmdPath); } From a35df793e6afdd5e585f7a987e57aeb155fa569b Mon Sep 17 00:00:00 2001 From: Adityanr <48587119+Adityanr@users.noreply.github.com> Date: Thu, 21 Oct 2021 01:25:43 +0530 Subject: [PATCH 2/4] toLower() to toUpperInvariant() fix --- src/Utilities.UnitTests/ToolTask_Tests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utilities.UnitTests/ToolTask_Tests.cs b/src/Utilities.UnitTests/ToolTask_Tests.cs index d4ac4233b3c..afe77a695ac 100644 --- a/src/Utilities.UnitTests/ToolTask_Tests.cs +++ b/src/Utilities.UnitTests/ToolTask_Tests.cs @@ -683,7 +683,7 @@ public void FindOnPathSucceeds() string shellName; if (NativeMethodsShared.IsWindows) { - expectedCmdPath = new[] { Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System).ToLower(), "cmd.exe") }; + expectedCmdPath = new[] { Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "cmd.exe").ToUpperInvariant() }; shellName = "cmd.exe"; } else @@ -692,7 +692,7 @@ public void FindOnPathSucceeds() shellName = "sh"; } - string cmdPath = ToolTask.FindOnPath(shellName).ToLower(); + string cmdPath = ToolTask.FindOnPath(shellName).ToUpperInvariant(); cmdPath.ShouldBeOneOf(expectedCmdPath); } From f76629f5b4f892e9b69fa1e58825e238d083c892 Mon Sep 17 00:00:00 2001 From: Adityanr <48587119+Adityanr@users.noreply.github.com> Date: Thu, 21 Oct 2021 01:49:16 +0530 Subject: [PATCH 3/4] pass linux and macos unit tests --- src/Utilities.UnitTests/ToolTask_Tests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utilities.UnitTests/ToolTask_Tests.cs b/src/Utilities.UnitTests/ToolTask_Tests.cs index afe77a695ac..35eca04b9ad 100644 --- a/src/Utilities.UnitTests/ToolTask_Tests.cs +++ b/src/Utilities.UnitTests/ToolTask_Tests.cs @@ -688,7 +688,7 @@ public void FindOnPathSucceeds() } else { - expectedCmdPath = new[] { "/bin/sh", "/usr/bin/sh" }; + expectedCmdPath = new[] { "/bin/sh".ToUpperInvariant(), "/usr/bin/sh".ToUpperInvariant() }; shellName = "sh"; } From 9e2f62902658162f982cd7fba83325b11094f038 Mon Sep 17 00:00:00 2001 From: Adityanr <48587119+Adityanr@users.noreply.github.com> Date: Thu, 21 Oct 2021 02:36:42 +0530 Subject: [PATCH 4/4] code refactored --- src/Utilities.UnitTests/ToolTask_Tests.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Utilities.UnitTests/ToolTask_Tests.cs b/src/Utilities.UnitTests/ToolTask_Tests.cs index 35eca04b9ad..3b5d3eb6085 100644 --- a/src/Utilities.UnitTests/ToolTask_Tests.cs +++ b/src/Utilities.UnitTests/ToolTask_Tests.cs @@ -681,19 +681,20 @@ public void FindOnPathSucceeds() { string[] expectedCmdPath; string shellName; + string cmdPath; if (NativeMethodsShared.IsWindows) { expectedCmdPath = new[] { Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "cmd.exe").ToUpperInvariant() }; shellName = "cmd.exe"; + cmdPath = ToolTask.FindOnPath(shellName).ToUpperInvariant(); } else { - expectedCmdPath = new[] { "/bin/sh".ToUpperInvariant(), "/usr/bin/sh".ToUpperInvariant() }; + expectedCmdPath = new[] { "/bin/sh", "/usr/bin/sh" }; shellName = "sh"; + cmdPath = ToolTask.FindOnPath(shellName); } - string cmdPath = ToolTask.FindOnPath(shellName).ToUpperInvariant(); - cmdPath.ShouldBeOneOf(expectedCmdPath); }