Skip to content

Commit

Permalink
Pass RID
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateo Torres Ruiz committed Jun 22, 2021
1 parent a04b846 commit 2402b61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,28 @@
using FluentAssertions;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.DotNet.CoreSetup.Test;
using Xunit;

namespace HostActivation.Tests
{
internal static class InstallLocationCommandResultExtensions
{
private static bool IsRunningInWoW64(string rid) => OperatingSystem.IsWindows() && Environment.Is64BitOperatingSystem && rid.Equals("win-x86");

public static AndConstraint<CommandResultAssertions> HaveUsedDotNetRootInstallLocation(this CommandResultAssertions assertion, string installLocation)
public static AndConstraint<CommandResultAssertions> HaveUsedDotNetRootInstallLocation(this CommandResultAssertions assertion, string installLocation, string rid)
{
return assertion.HaveUsedDotNetRootInstallLocation(installLocation, null, null);
return assertion.HaveUsedDotNetRootInstallLocation(installLocation, rid, null);
}

public static AndConstraint<CommandResultAssertions> 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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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=");
}

Expand Down

0 comments on commit 2402b61

Please sign in to comment.