Skip to content

Commit c17d51a

Browse files
committed
Add test
1 parent 7d1aa71 commit c17d51a

17 files changed

+80
-10
lines changed

src/installer/tests/HostActivation.Tests/FrameworkResolution/ApplyPatchesSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using Microsoft.DotNet.Cli.Build.Framework;
66
using Xunit;
77

8+
using static Microsoft.DotNet.CoreSetup.Test.Constants;
9+
810
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution
911
{
1012
public class ApplyPatchesSettings :

src/installer/tests/HostActivation.Tests/FrameworkResolution/ComplexHierarchies.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
using System;
77
using Xunit;
88

9+
using static Microsoft.DotNet.CoreSetup.Test.Constants;
10+
911
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution
1012
{
1113
public class ComplexHierarchies :

src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionBase.Settings.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public enum SettingLocation
8585
public static Func<TestSettings, TestSettings> RollForwardSetting(
8686
SettingLocation location,
8787
string value,
88-
string frameworkReferenceName = MicrosoftNETCoreApp)
88+
string frameworkReferenceName = Constants.MicrosoftNETCoreApp)
8989
{
9090
if (value == null || location == SettingLocation.None)
9191
{
@@ -114,7 +114,7 @@ public static Func<TestSettings, TestSettings> RollForwardSetting(
114114
public static Func<TestSettings, TestSettings> RollForwardOnNoCandidateFxSetting(
115115
SettingLocation location,
116116
int? value,
117-
string frameworkReferenceName = MicrosoftNETCoreApp)
117+
string frameworkReferenceName = Constants.MicrosoftNETCoreApp)
118118
{
119119
if (!value.HasValue || location == SettingLocation.None)
120120
{
@@ -143,7 +143,7 @@ public static Func<TestSettings, TestSettings> RollForwardOnNoCandidateFxSetting
143143
public static Func<TestSettings, TestSettings> ApplyPatchesSetting(
144144
SettingLocation location,
145145
bool? value,
146-
string frameworkReferenceName = MicrosoftNETCoreApp)
146+
string frameworkReferenceName = Constants.MicrosoftNETCoreApp)
147147
{
148148
if (!value.HasValue || location == SettingLocation.None)
149149
{

src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionBase.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution
1111
{
1212
public abstract partial class FrameworkResolutionBase
1313
{
14-
protected const string MicrosoftNETCoreApp = "Microsoft.NETCore.App";
15-
1614
public static class ResolvedFramework
1715
{
1816
public const string NotFound = "[not found]";
@@ -23,7 +21,6 @@ protected CommandResult RunTest(
2321
DotNetCli dotnet,
2422
TestApp app,
2523
TestSettings settings,
26-
Action<CommandResult> resultAction = null,
2724
bool? multiLevelLookup = false)
2825
{
2926
using (DotNetCliExtensions.DotNetCliCustomizer dotnetCustomizer = settings.DotnetCustomizer == null ? null : dotnet.Customize())
@@ -53,8 +50,6 @@ protected CommandResult RunTest(
5350
.Environment(settings.Environment)
5451
.Execute();
5552

56-
resultAction?.Invoke(result);
57-
5853
return result;
5954
}
6055
}

src/installer/tests/HostActivation.Tests/FrameworkResolution/FxVersionCLI.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using Microsoft.DotNet.Cli.Build.Framework;
66
using Xunit;
77

8+
using static Microsoft.DotNet.CoreSetup.Test.Constants;
9+
810
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution
911
{
1012
public class FXVersionCLI :

src/installer/tests/HostActivation.Tests/FrameworkResolution/IncludedFrameworksSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using Microsoft.DotNet.Cli.Build.Framework;
66
using Xunit;
77

8+
using static Microsoft.DotNet.CoreSetup.Test.Constants;
9+
810
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution
911
{
1012
public class IncludedFrameworksSettings :

src/installer/tests/HostActivation.Tests/FrameworkResolution/MultipleHives.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.DotNet.Cli.Build;
99
using Microsoft.DotNet.Cli.Build.Framework;
1010
using Xunit;
11+
using static Microsoft.DotNet.CoreSetup.Test.Constants;
1112

1213
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution
1314
{
@@ -217,6 +218,50 @@ public void FrameworkResolutionError(string tfm, bool? multiLevelLookup, bool ef
217218
.And.HaveStdErrContaining("Ignoring FX version [9999.9.9] without .deps.json");
218219
}
219220

221+
[Fact]
222+
public void FrameworkResolutionError_ListOtherArchitectures()
223+
{
224+
using (var registeredInstallLocationOverride = new RegisteredInstallLocationOverride(SharedState.DotNetMainHive.GreatestVersionHostFxrFilePath))
225+
using (var otherArchArtifact = TestArtifact.Create("otherArch"))
226+
{
227+
string requestedVersion = "9999.9.9";
228+
string[] otherArchs = ["arm64", "x64", "x86"];
229+
var installLocations = new (string, string)[otherArchs.Length];
230+
for (int i = 0; i < otherArchs.Length; i++)
231+
{
232+
string arch = otherArchs[i];
233+
234+
// Create a .NET install with Microsoft.NETCoreApp at the registered location
235+
var dotnet = new DotNetBuilder(otherArchArtifact.Location, TestContext.BuiltDotNet.BinPath, arch)
236+
.AddMicrosoftNETCoreAppFrameworkMockHostPolicy(requestedVersion)
237+
.Build();
238+
installLocations[i] = (arch, dotnet.BinPath);
239+
}
240+
241+
registeredInstallLocationOverride.SetInstallLocation(installLocations);
242+
243+
CommandResult result = RunTest(
244+
new TestSettings()
245+
.WithRuntimeConfigCustomizer(c => c.WithFramework(MicrosoftNETCoreApp, requestedVersion))
246+
.WithEnvironment(TestOnlyEnvironmentVariables.RegisteredConfigLocation, registeredInstallLocationOverride.PathValueOverride),
247+
multiLevelLookup: null);
248+
249+
result.ShouldFailToFindCompatibleFrameworkVersion(MicrosoftNETCoreApp, requestedVersion)
250+
.And.HaveStdErrContaining("The following frameworks for other architectures were found:");
251+
252+
// Error message should list framework found for other architectures
253+
foreach ((string arch, string path) in installLocations)
254+
{
255+
if (arch == TestContext.BuildArchitecture)
256+
continue;
257+
258+
string expectedPath = System.Text.RegularExpressions.Regex.Escape(Path.Combine(path, "shared", MicrosoftNETCoreApp));
259+
result.Should()
260+
.HaveStdErrMatching($@"{arch}\s*{requestedVersion} at \[{expectedPath}\]", System.Text.RegularExpressions.RegexOptions.Multiline);
261+
}
262+
}
263+
}
264+
220265
private CommandResult RunTest(Func<RuntimeConfig, RuntimeConfig> runtimeConfig, bool? multiLevelLookup = true)
221266
=> RunTest(new TestSettings().WithRuntimeConfigCustomizer(runtimeConfig), multiLevelLookup);
222267

src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardAndRollForwardOnNoCandidateFxSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using Microsoft.DotNet.Cli.Build.Framework;
66
using Xunit;
77

8+
using static Microsoft.DotNet.CoreSetup.Test.Constants;
9+
810
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution
911
{
1012
public class RollForwardAndRollForwardOnNoCandidateFxSettings :

src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardMultipleFrameworks.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
using System;
77
using Xunit;
88

9+
using static Microsoft.DotNet.CoreSetup.Test.Constants;
10+
911
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution
1012
{
1113
public class RollForwardMultipleFrameworks :

src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardOnNoCandidateFx.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System;
45
using Microsoft.DotNet.Cli.Build;
56
using Microsoft.DotNet.Cli.Build.Framework;
6-
using System;
77
using Xunit;
88

9+
using static Microsoft.DotNet.CoreSetup.Test.Constants;
10+
911
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution
1012
{
1113
public class RollForwardOnNoCandidateFx :

0 commit comments

Comments
 (0)