diff --git a/src/installer/tests/HostActivation.Tests/InstallLocationCommandResultExtensions.cs b/src/installer/tests/HostActivation.Tests/InstallLocationCommandResultExtensions.cs index 71d2616007c66..c85b7d3e56cc5 100644 --- a/src/installer/tests/HostActivation.Tests/InstallLocationCommandResultExtensions.cs +++ b/src/installer/tests/HostActivation.Tests/InstallLocationCommandResultExtensions.cs @@ -7,6 +7,7 @@ using FluentAssertions; using Microsoft.DotNet.Cli.Build.Framework; using Microsoft.DotNet.CoreSetup.Test; +using Xunit; namespace HostActivation.Tests { @@ -14,16 +15,20 @@ internal static class InstallLocationCommandResultExtensions { private static bool IsRunningInWoW64(string rid) => OperatingSystem.IsWindows() && Environment.Is64BitOperatingSystem && rid.Equals("win-x86"); - public static AndConstraint HaveUsedDotNetRootInstallLocation(this CommandResultAssertions assertion, string installLocation) + public static AndConstraint HaveUsedDotNetRootInstallLocation(this CommandResultAssertions assertion, string installLocation, string rid) { - return assertion.HaveUsedDotNetRootInstallLocation(installLocation, null, null); + return assertion.HaveUsedDotNetRootInstallLocation(installLocation, rid, null); } public static AndConstraint HaveUsedDotNetRootInstallLocation(this CommandResultAssertions assertion, string installLocation, - string arch, - string rid) + string rid, + string arch) { + // If no arch is passed and we are on Windows, we need the used RID for determining whether or not we are running on WoW64. + if (string.IsNullOrEmpty(arch)) + Assert.NotNull(rid); + string expectedEnvironmentVariable = !string.IsNullOrEmpty(arch) ? $"DOTNET_ROOT_{arch.ToUpper()}" : IsRunningInWoW64(rid) ? "DOTNET_ROOT(x86)" : "DOTNET_ROOT"; diff --git a/src/installer/tests/HostActivation.Tests/MultiArchInstallLocation.cs b/src/installer/tests/HostActivation.Tests/MultiArchInstallLocation.cs index d12efb7a5cfbd..c1b00cafd4e6a 100644 --- a/src/installer/tests/HostActivation.Tests/MultiArchInstallLocation.cs +++ b/src/installer/tests/HostActivation.Tests/MultiArchInstallLocation.cs @@ -33,7 +33,7 @@ public void EnvironmentVariable_CurrentArchitectureIsUsedIfEnvVarSet() .DotNetRoot(fixture.BuiltDotnet.BinPath, arch) .Execute() .Should().Pass() - .And.HaveUsedDotNetRootInstallLocation(fixture.BuiltDotnet.BinPath, arch, fixture.CurrentRid); + .And.HaveUsedDotNetRootInstallLocation(fixture.BuiltDotnet.BinPath, fixture.CurrentRid, arch); } [Fact] @@ -49,7 +49,7 @@ public void EnvironmentVariable_IfNoArchSpecificEnvVarIsFoundDotnetRootIsUsed() .DotNetRoot(fixture.BuiltDotnet.BinPath) .Execute() .Should().Pass() - .And.HaveUsedDotNetRootInstallLocation(fixture.BuiltDotnet.BinPath); + .And.HaveUsedDotNetRootInstallLocation(fixture.BuiltDotnet.BinPath, fixture.CurrentRid); } [Fact] @@ -67,7 +67,7 @@ public void EnvironmentVariable_ArchSpecificDotnetRootIsUsedOverDotnetRoot() .DotNetRoot(dotnet, arch) .Execute() .Should().Pass() - .And.HaveUsedDotNetRootInstallLocation(dotnet, arch, fixture.CurrentRid) + .And.HaveUsedDotNetRootInstallLocation(dotnet, fixture.CurrentRid, arch) .And.NotHaveStdErrContaining("Using environment variable DOTNET_ROOT="); }