Skip to content

Commit b79d4c4

Browse files
authored
Add --arch option for --list-runtimes and --list-sdks in host (#116078)
Allow specifying --arch <arch> for --list-runtimes and --list-sdks commands in host. Must be in the order --list-runtimes/sdks --arch <arch>. - If not specified, behaviour remains the same - list runtimes/SDKs for the invoked dotnet (for SDKs, any paths specified any found global.json are respected). - If specified and not the same as the host architecture, searches for registered or default install locations for that architecture and lists runtimes/SDKs found there. - If specified and the same as the host architecture, behaves the same as if not specified - note that this means it will not search for registered/default installs of the host architecture and only list runtimes/SDKs relative to the invoked dotnet. New tests are in a HostCommands test class. This also moves some existing tests for host commands into the new class. This does remove tests running the host commands with the multi-level lookup environment variable set, but I don't think those are interesting anymore - it has been disabled since 7.0 and should always be disabled (unlike for actually running an app, where it can be based on the tfm).
1 parent 30082a4 commit b79d4c4

File tree

16 files changed

+407
-186
lines changed

16 files changed

+407
-186
lines changed

src/installer/tests/HostActivation.Tests/DotnetArgValidation.cs

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
using System;
55
using System.IO;
6-
using System.Text;
7-
using Microsoft.DotNet.Cli.Build;
86
using Microsoft.DotNet.TestUtils;
97
using Xunit;
108

@@ -83,52 +81,6 @@ public void InvalidFileOrCommand_NoSDK_ListsPossibleIssues()
8381
.And.FindAnySdk(false);
8482
}
8583

86-
[Fact]
87-
public void DotNetInfo_NoSDK()
88-
{
89-
TestContext.BuiltDotNet.Exec("--info")
90-
.CaptureStdOut()
91-
.CaptureStdErr()
92-
.Execute()
93-
.Should().Pass()
94-
.And.HaveStdOutMatching($@"Architecture:\s*{TestContext.BuildArchitecture}")
95-
.And.HaveStdOutMatching($@"RID:\s*{TestContext.BuildRID}");
96-
}
97-
98-
[Fact]
99-
public void DotNetInfo_Utf8Path()
100-
{
101-
string installLocation = Encoding.UTF8.GetString("utf8-龯蝌灋齅ㄥ䶱"u8);
102-
DotNetCli dotnet = new DotNetBuilder(sharedTestState.BaseDirectory.Location, TestContext.BuiltDotNet.BinPath, installLocation)
103-
.Build();
104-
105-
var result = dotnet.Exec("--info")
106-
.DotNetRoot(Path.Combine(sharedTestState.BaseDirectory.Location, installLocation))
107-
.CaptureStdErr()
108-
.CaptureStdOut(Encoding.UTF8)
109-
.Execute();
110-
111-
result.Should().Pass()
112-
.And.HaveStdOutMatching($@"DOTNET_ROOT.*{installLocation}");
113-
}
114-
115-
[Fact]
116-
public void DotNetInfo_WithSDK()
117-
{
118-
DotNetCli dotnet = new DotNetBuilder(sharedTestState.BaseDirectory.Location, TestContext.BuiltDotNet.BinPath, "withSdk")
119-
.AddMicrosoftNETCoreAppFrameworkMockHostPolicy("1.0.0")
120-
.AddMockSDK("1.0.0", "1.0.0")
121-
.Build();
122-
123-
dotnet.Exec("--info")
124-
.WorkingDirectory(sharedTestState.BaseDirectory.Location)
125-
.CaptureStdOut()
126-
.CaptureStdErr()
127-
.Execute()
128-
.Should().Pass()
129-
.And.NotHaveStdOutMatching($@"RID:\s*{TestContext.BuildRID}");
130-
}
131-
13284
// Return a non-existent path that contains a mix of / and \
13385
private string GetNonexistentAndUnnormalizedPath()
13486
{

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

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -138,55 +138,6 @@ private List<FrameworkInfo> GetExpectedFrameworks(bool? multiLevelLookup)
138138
return expectedList;
139139
}
140140

141-
[Theory]
142-
[InlineData(true)]
143-
[InlineData(null)]
144-
[InlineData(false)]
145-
public void ListRuntimes(bool? multiLevelLookup)
146-
{
147-
// Multi-level lookup is only supported on Windows.
148-
if (!OperatingSystem.IsWindows() && multiLevelLookup != false)
149-
return;
150-
151-
string expectedOutput = string.Join(
152-
string.Empty,
153-
GetExpectedFrameworks(false) // MLL Is always disabled for dotnet --list-runtimes
154-
.Select(t => $"{MicrosoftNETCoreApp} {t.Version} [{Path.Combine(t.Path, "shared", MicrosoftNETCoreApp)}]{Environment.NewLine}"));
155-
156-
// !!IMPORTANT!!: This test verifies the exact match of the entire output of the command (not a substring!)
157-
// This is important as the output of --list-runtimes is considered machine readable and thus must not change even in a minor way (unintentionally)
158-
RunTest(
159-
new TestSettings().WithCommandLine("--list-runtimes"),
160-
multiLevelLookup,
161-
testApp: null)
162-
.Should().HaveStdOut(expectedOutput)
163-
.And.HaveStdErrContaining("Ignoring FX version [9999.9.9] without .deps.json");
164-
}
165-
166-
[Theory]
167-
[InlineData(true)]
168-
[InlineData(null)]
169-
[InlineData(false)]
170-
public void DotnetInfo(bool? multiLevelLookup)
171-
{
172-
// Multi-level lookup is only supported on Windows.
173-
if (!OperatingSystem.IsWindows() && multiLevelLookup != false)
174-
return;
175-
176-
string expectedOutput =
177-
$".NET runtimes installed:{Environment.NewLine}" +
178-
string.Join(string.Empty,
179-
GetExpectedFrameworks(false) // MLL is always disabled for dotnet --info
180-
.Select(t => $" {MicrosoftNETCoreApp} {t.Version} [{Path.Combine(t.Path, "shared", MicrosoftNETCoreApp)}]{Environment.NewLine}"));
181-
182-
RunTest(
183-
new TestSettings().WithCommandLine("--info"),
184-
multiLevelLookup,
185-
testApp: null)
186-
.Should().HaveStdOutContaining(expectedOutput)
187-
.And.HaveStdErrContaining("Ignoring FX version [9999.9.9] without .deps.json");
188-
}
189-
190141
[Theory]
191142
[InlineData("net6.0", true, true)]
192143
[InlineData("net6.0", null, true)]

0 commit comments

Comments
 (0)