Skip to content

Commit 4c52a0c

Browse files
Addressing comments
1 parent 5d3d117 commit 4c52a0c

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

src/SourceBuild/content/test/Microsoft.DotNet.Installer.Tests/Config.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
namespace Microsoft.DotNet.Installer.Tests;
1111

12+
public enum Architecture
13+
{
14+
X64,
15+
Arm64
16+
}
17+
1218
public static class Config
1319
{
1420
public static string AssetsDirectory { get; } = GetRuntimeConfig(AssetsDirectorySwitch);
@@ -20,7 +26,7 @@ public static class Config
2026
public static string ScenarioTestsNuGetConfigPath { get; } = GetRuntimeConfig(ScenarioTestsNuGetConfigSwitch);
2127
const string ScenarioTestsNuGetConfigSwitch = RuntimeConfigSwitchPrefix + nameof(ScenarioTestsNuGetConfigPath);
2228

23-
public static string Architecture { get; } = GetRuntimeConfig(ArchitectureSwitch);
29+
public static Architecture Architecture { get; } = GetArchitecture(GetRuntimeConfig(ArchitectureSwitch));
2430
const string ArchitectureSwitch = RuntimeConfigSwitchPrefix + nameof(Architecture);
2531

2632
public static bool TestRpmPackages { get; } = TryGetRuntimeConfig(TestRpmPackagesSwitch, out bool value) ? value : false;
@@ -34,6 +40,13 @@ public static class Config
3440

3541
public const string RuntimeConfigSwitchPrefix = "Microsoft.DotNet.Installer.Tests.";
3642

43+
public static Architecture GetArchitecture(string architecture) => architecture switch
44+
{
45+
"x64" => Architecture.X64,
46+
"arm64" => Architecture.Arm64,
47+
_ => throw new ArgumentException($"Unknown architecture: {architecture}")
48+
};
49+
3750
public static string GetRuntimeConfig(string key)
3851
{
3952
return TryGetRuntimeConfig(key, out string? value) ? value : throw new InvalidOperationException($"Runtime config setting '{key}' must be specified");

src/SourceBuild/content/test/Microsoft.DotNet.Installer.Tests/LinuxInstallerTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public LinuxInstallerTests(ITestOutputHelper outputHelper)
5555
_contextDir = Path.Combine(_tmpDir, Path.GetRandomFileName());
5656
Directory.CreateDirectory(_contextDir);
5757

58-
_excludeLinuxArch = Config.Architecture == "x64" ? "arm64" : "x64";
58+
_excludeLinuxArch = Config.Architecture == Architecture.X64 ? "arm64" : "x64";
5959
}
6060

6161
public void Dispose()
@@ -96,7 +96,7 @@ public void DebTest(string repo, string tag)
9696
private void InitializeContext(PackageType packageType)
9797
{
9898
string packageArchitecture =
99-
Config.Architecture == "x64" ?
99+
Config.Architecture == Architecture.X64 ?
100100
"x64" :
101101
packageType == PackageType.Rpm ?
102102
"aarch64" :
@@ -117,7 +117,7 @@ private void InitializeContext(PackageType packageType)
117117
File.Copy(rpmPackage, Path.Combine(_contextDir, Path.GetFileName(rpmPackage)));
118118
}
119119

120-
if (Config.Architecture == "x64")
120+
if (Config.Architecture == Architecture.X64)
121121
{
122122
DownloadFileAsync(NetStandard21RpmPackage, Path.Combine(_contextDir, Path.GetFileName(NetStandard21RpmPackage))).Wait();
123123
}
@@ -131,7 +131,7 @@ private void InitializeContext(PackageType packageType)
131131
File.Copy(debPackage, Path.Combine(_contextDir, Path.GetFileName(debPackage)));
132132
}
133133

134-
if (Config.Architecture == "x64")
134+
if (Config.Architecture == Architecture.X64)
135135
{
136136
DownloadFileAsync(NetStandard21DebPackage, Path.Combine(_contextDir, Path.GetFileName(NetStandard21DebPackage))).Wait();
137137
}
@@ -286,7 +286,7 @@ private List<string> GetPackageList(string baseImage, PackageType packageType)
286286
AddPackage(packageList, "aspnetcore-runtime-", packageType);
287287
AddPackage(packageList, "aspnetcore-targeting-pack-", packageType);
288288
AddPackage(packageList, "dotnet-apphost-pack-", packageType);
289-
if (Config.Architecture == "x64")
289+
if (Config.Architecture == Architecture.X64)
290290
{
291291
// netstandard package exists for x64 only
292292
AddPackage(packageList, "netstandard-targeting-pack-", packageType);

src/SourceBuild/content/test/tests.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</PropertyGroup>
2222

2323
<ItemGroup Condition="'$(TestInstallerPackages)' == 'true'">
24-
<ProjectReference Condition="'$(TestRpmPackages)' == 'true' or '$(TestDebPackages)' == 'true'" Include="Microsoft.DotNet.Installer.Tests\Microsoft.DotNet.Installer.Tests.csproj" BuildInParallel="false" />
24+
<ProjectReference Include="Microsoft.DotNet.Installer.Tests\Microsoft.DotNet.Installer.Tests.csproj" BuildInParallel="false" />
2525
</ItemGroup>
2626

2727
<ItemGroup Condition="'$(TestInstallerPackages)' != 'true'">

0 commit comments

Comments
 (0)