Skip to content

Commit 8e20ce4

Browse files
Revert "Move hosting tests to XUnit 3" (#120997)
Reverts #120234 This change appears to have broken the bootstrapped community builds.
1 parent 2c0254d commit 8e20ce4

File tree

62 files changed

+341
-381
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+341
-381
lines changed

src/installer/tests/AppHost.Bundle.Tests/AppHost.Bundle.Tests.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22

33
<PropertyGroup>
44
<Description>Apphost Bundle Tests</Description>
5-
<OutputType>Exe</OutputType>
6-
<RuntimeIdentifier>$(TargetRid)</RuntimeIdentifier>
75
<TargetFramework>$(TestInfraTargetFramework)</TargetFramework>
86
<AssemblyName>AppHost.Bundle.Tests</AssemblyName>
97
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
108
<!-- Reduce the length of the test output dir to make it more reliable on Windows. -->
119
<TestsOutputName>ahb</TestsOutputName>
1210
<!-- NuGet warns about a transitive P2P to System.Text.Json that can't be pruned.
1311
This is a false positive: https://github.com/NuGet/Home/issues/14103 -->
14-
<NoWarn>$(NoWarn);NU1511;xUnit1004</NoWarn>
15-
<TestRunnerName>XUnitV3</TestRunnerName>
12+
<NoWarn>$(NoWarn);NU1511</NoWarn>
1613
</PropertyGroup>
1714

1815
<ItemGroup>

src/installer/tests/AppHost.Bundle.Tests/AppLaunch.cs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private void RunTheApp(string path, bool selfContained)
2727
Command.Create(path)
2828
.CaptureStdErr()
2929
.CaptureStdOut()
30-
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
30+
.DotNetRoot(selfContained ? null : TestContext.BuiltDotNet.BinPath)
3131
.Execute()
3232
.Should().Pass()
3333
.And.HaveStdOutContaining("Hello World!");
@@ -75,9 +75,9 @@ private void RunApp(bool selfContained)
7575
if (OperatingSystem.IsWindows())
7676
{
7777
// StandaloneApp sets FileVersion to NETCoreApp version. On Windows, this should be copied to singlefilehost resources.
78-
string expectedVersion = HostTestContext.MicrosoftNETCoreAppVersion.Contains('-')
79-
? HostTestContext.MicrosoftNETCoreAppVersion[..HostTestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
80-
: HostTestContext.MicrosoftNETCoreAppVersion;
78+
string expectedVersion = TestContext.MicrosoftNETCoreAppVersion.Contains('-')
79+
? TestContext.MicrosoftNETCoreAppVersion[..TestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
80+
: TestContext.MicrosoftNETCoreAppVersion;
8181
Assert.Equal(expectedVersion, System.Diagnostics.FileVersionInfo.GetVersionInfo(singleFile).FileVersion);
8282
}
8383
}
@@ -103,17 +103,14 @@ private void NonAsciiCharacterSelfContainedApp()
103103
if (OperatingSystem.IsWindows())
104104
{
105105
// StandaloneApp sets FileVersion to NETCoreApp version. On Windows, this should be copied to singlefilehost resources.
106-
string expectedVersion = HostTestContext.MicrosoftNETCoreAppVersion.Contains('-')
107-
? HostTestContext.MicrosoftNETCoreAppVersion[..HostTestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
108-
: HostTestContext.MicrosoftNETCoreAppVersion;
106+
string expectedVersion = TestContext.MicrosoftNETCoreAppVersion.Contains('-')
107+
? TestContext.MicrosoftNETCoreAppVersion[..TestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
108+
: TestContext.MicrosoftNETCoreAppVersion;
109109
Assert.Equal(expectedVersion, System.Diagnostics.FileVersionInfo.GetVersionInfo(singleFile).FileVersion);
110110
}
111111
}
112112

113-
[Theory(
114-
SkipType = typeof(Binaries.CetCompat),
115-
SkipUnless = nameof(Binaries.CetCompat.IsSupported),
116-
Skip = "CET is not supported on this platform")]
113+
[ConditionalTheory(typeof(Binaries.CetCompat), nameof(Binaries.CetCompat.IsSupported))]
117114
[InlineData(true)]
118115
[InlineData(false)]
119116
public void DisableCetCompat(bool selfContained)
@@ -127,12 +124,12 @@ public void DisableCetCompat(bool selfContained)
127124
Command.Create(singleFile)
128125
.CaptureStdErr()
129126
.CaptureStdOut()
130-
.DotNetRoot(HostTestContext.BuiltDotNet.BinPath, HostTestContext.BuildArchitecture)
127+
.DotNetRoot(TestContext.BuiltDotNet.BinPath, TestContext.BuildArchitecture)
131128
.MultilevelLookup(false)
132129
.Execute()
133130
.Should().Pass()
134131
.And.HaveStdOutContaining("Hello World")
135-
.And.HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
132+
.And.HaveStdOutContaining(TestContext.MicrosoftNETCoreAppVersion);
136133
}
137134

138135
[Theory]
@@ -161,7 +158,7 @@ public void FrameworkDependent_NoBundleEntryPoint()
161158

162159
using (var dotnetWithMockHostFxr = TestArtifact.Create("mockhostfxrFrameworkMissingFailure"))
163160
{
164-
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, HostTestContext.BuiltDotNet.BinPath, null)
161+
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, TestContext.BuiltDotNet.BinPath, null)
165162
.RemoveHostFxr()
166163
.AddMockHostFxr(new Version(2, 2, 0))
167164
.Build();
@@ -180,7 +177,7 @@ public void FrameworkDependent_NoBundleEntryPoint()
180177
}
181178

182179
[Fact]
183-
[PlatformSpecific(TestPlatforms.Windows)]
180+
[PlatformSpecific(TestPlatforms.Windows)] // GUI app host is only supported on Windows.
184181
public void FrameworkDependent_GUI_DownlevelHostFxr_ErrorDialog()
185182
{
186183
var singleFile = sharedTestState.FrameworkDependentApp.Bundle();
@@ -191,14 +188,14 @@ public void FrameworkDependent_GUI_DownlevelHostFxr_ErrorDialog()
191188
{
192189
string expectedErrorCode = Constants.ErrorCode.BundleExtractionFailure.ToString("x");
193190

194-
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, HostTestContext.BuiltDotNet.BinPath, null)
191+
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, TestContext.BuiltDotNet.BinPath, null)
195192
.RemoveHostFxr()
196193
.AddMockHostFxr(new Version(5, 0, 0))
197194
.Build();
198195

199196
Command command = Command.Create(singleFile)
200197
.EnableTracingAndCaptureOutputs()
201-
.DotNetRoot(dotnet.BinPath, HostTestContext.BuildArchitecture)
198+
.DotNetRoot(dotnet.BinPath, TestContext.BuildArchitecture)
202199
.Start();
203200

204201
WindowsUtils.WaitForPopupFromProcess(command.Process);

src/installer/tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private FluentAssertions.AndConstraint<CommandResultAssertions> RunTheApp(string
2424
{
2525
CommandResult result = Command.Create(path)
2626
.EnableTracingAndCaptureOutputs()
27-
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
27+
.DotNetRoot(selfContained ? null : TestContext.BuiltDotNet.BinPath)
2828
.MultilevelLookup(false)
2929
.Execute();
3030
if (deleteApp)
@@ -142,7 +142,8 @@ public void FrameworkDependent_Targeting50(BundleOptions options)
142142
}
143143
}
144144

145-
[Fact(Skip = "https://github.com/dotnet/runtime/issues/54234")]
145+
[Fact]
146+
[ActiveIssue("https://github.com/dotnet/runtime/issues/54234")]
146147
// NOTE: when enabling this test take a look at commented code marked by "ACTIVE ISSUE:" in SharedTestState
147148
public void SelfContained_R2R_Composite()
148149
{

src/installer/tests/AppHost.Bundle.Tests/NativeLibraries.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private void PInvoke(bool selfContained, bool bundleNative)
3838
Command.Create(app, "load_native_library_pinvoke")
3939
.CaptureStdErr()
4040
.CaptureStdOut()
41-
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
41+
.DotNetRoot(selfContained ? null : TestContext.BuiltDotNet.BinPath)
4242
// Specify an extraction root that will get cleaned up by the test app artifact
4343
.EnvironmentVariable(Constants.BundleExtractBase.EnvironmentVariable, extractionRoot)
4444
.Execute()
@@ -66,7 +66,7 @@ private void TryLoad(bool selfContained, bool bundleNative)
6666
Command.Create(app, "load_native_library_api")
6767
.CaptureStdErr()
6868
.CaptureStdOut()
69-
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
69+
.DotNetRoot(selfContained ? null : TestContext.BuiltDotNet.BinPath)
7070
// Specify an extraction root that will get cleaned up by the test app artifact
7171
.EnvironmentVariable(Constants.BundleExtractBase.EnvironmentVariable, extractionRoot)
7272
.Execute()

src/installer/tests/Directory.Build.props

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
<PropertyGroup>
55
<TestArtifactsOutputRoot>$(ArtifactsDir)tests\host\$(TargetOS).$(TargetArchitecture).$(Configuration)\</TestArtifactsOutputRoot>
66
<TestInfraTargetFramework>$(NetCoreAppToolCurrent)</TestInfraTargetFramework>
7-
<TestCaseFilter>/[category!=failing]</TestCaseFilter>
8-
<TestRunnerAdditionalArguments>--filter-query $(TestCaseFilter)</TestRunnerAdditionalArguments>
7+
<TestCaseFilter>category!=failing</TestCaseFilter>
8+
<TestRunnerAdditionalArguments>--filter $(TestCaseFilter) -v detailed</TestRunnerAdditionalArguments>
99
<!-- Enable crash and hang dumps -->
10-
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --crashdump</TestRunnerAdditionalArguments>
11-
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --hangdump --hangdump-timeout 5m --hangdump-type full</TestRunnerAdditionalArguments>
10+
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --blame-crash-dump-type full</TestRunnerAdditionalArguments>
11+
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --blame-hang-timeout 5m --blame-hang-dump-type full</TestRunnerAdditionalArguments>
12+
<UseVSTestRunner>true</UseVSTestRunner>
1213
<RunAnalyzers>false</RunAnalyzers>
1314
</PropertyGroup>
1415

src/installer/tests/Directory.Build.targets

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@
9292
<RunSettingsTestCaseFilter>$(TestCaseFilter)</RunSettingsTestCaseFilter>
9393
</PropertyGroup>
9494

95-
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
96-
<PackageReference Include="Microsoft.Testing.Extensions.CrashDump" Version="1.7.3" />
97-
<PackageReference Include="Microsoft.Testing.Extensions.HangDump" Version="1.7.3" />
98-
</ItemGroup>
99-
10095
<Import Project="$(RepositoryEngineeringDir)testing\runsettings.targets"
10196
Condition="'$(IsTestProject)' == 'true'" />
10297

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public Breadcrumbs(SharedTestState fixture)
2222
[Fact]
2323
public void BreadcrumbThreadFinishes()
2424
{
25-
HostTestContext.BuiltDotNet.Exec(sharedTestState.App.AppDll)
25+
TestContext.BuiltDotNet.Exec(sharedTestState.App.AppDll)
2626
.EnvironmentVariable(Constants.Breadcrumbs.EnvironmentVariable, sharedTestState.BreadcrumbLocation)
2727
.EnableTracingAndCaptureOutputs()
2828
.Execute()
@@ -34,7 +34,7 @@ public void BreadcrumbThreadFinishes()
3434
[Fact]
3535
public void UnhandledException_BreadcrumbThreadDoesNotFinish()
3636
{
37-
HostTestContext.BuiltDotNet.Exec(sharedTestState.App.AppDll, "throw_exception")
37+
TestContext.BuiltDotNet.Exec(sharedTestState.App.AppDll, "throw_exception")
3838
.EnvironmentVariable(Constants.Breadcrumbs.EnvironmentVariable, sharedTestState.BreadcrumbLocation)
3939
.EnableTracingAndCaptureOutputs()
4040
.DisableDumps() // Expected to throw an exception

src/installer/tests/HostActivation.Tests/DependencyResolution/AdditionalProbingPath.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,24 @@ public class SharedTestState : SharedTestStateBase
111111
public SharedTestState()
112112
{
113113
DotNetWithNetCoreApp = DotNet("WithNetCoreApp")
114-
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(HostTestContext.MicrosoftNETCoreAppVersion)
114+
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(TestContext.MicrosoftNETCoreAppVersion)
115115
.Build();
116116

117-
string nativeDependencyRelPath = $"{HostTestContext.BuildRID}/{Binaries.GetSharedLibraryFileNameForCurrentPlatform("native")}";
118-
FrameworkReferenceApp = CreateFrameworkReferenceApp(Constants.MicrosoftNETCoreApp, HostTestContext.MicrosoftNETCoreAppVersion, b => b
117+
string nativeDependencyRelPath = $"{TestContext.BuildRID}/{Binaries.GetSharedLibraryFileNameForCurrentPlatform("native")}";
118+
FrameworkReferenceApp = CreateFrameworkReferenceApp(Constants.MicrosoftNETCoreApp, TestContext.MicrosoftNETCoreAppVersion, b => b
119119
.WithProject(DependencyName, DependencyVersion, p => p
120120
.WithAssemblyGroup(null, g => g
121121
.WithAsset($"{DependencyName}.dll", f => f.NotOnDisk()))
122-
.WithNativeLibraryGroup(HostTestContext.BuildRID, g => g
122+
.WithNativeLibraryGroup(TestContext.BuildRID, g => g
123123
.WithAsset(nativeDependencyRelPath, f => f.NotOnDisk()))));
124124
RuntimeConfig.FromFile(FrameworkReferenceApp.RuntimeConfigJson)
125-
.WithTfm(HostTestContext.Tfm)
125+
.WithTfm(TestContext.Tfm)
126126
.Save();
127127

128128
AdditionalProbingPath = Path.Combine(Location, "probe");
129129
(DependencyPath, NativeDependencyDirectory) = AddDependencies(AdditionalProbingPath);
130130

131-
AdditionalProbingPath_ArchTfm = Path.Combine(AdditionalProbingPath, HostTestContext.BuildArchitecture, HostTestContext.Tfm);
131+
AdditionalProbingPath_ArchTfm = Path.Combine(AdditionalProbingPath, TestContext.BuildArchitecture, TestContext.Tfm);
132132
(DependencyPath_ArchTfm, NativeDependencyDirectory_ArchTfm) = AddDependencies(AdditionalProbingPath_ArchTfm);
133133

134134
(string, string) AddDependencies(string probeDir)

src/installer/tests/HostActivation.Tests/DependencyResolution/DepsFile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ public class SharedTestState : SharedTestStateBase
9292
public SharedTestState()
9393
{
9494
DotNetWithNetCoreApp = DotNet("WithNetCoreApp")
95-
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(HostTestContext.MicrosoftNETCoreAppVersion)
95+
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(TestContext.MicrosoftNETCoreAppVersion)
9696
.Build();
9797

98-
FrameworkReferenceApp = CreateFrameworkReferenceApp(Constants.MicrosoftNETCoreApp, HostTestContext.MicrosoftNETCoreAppVersion, b => b
98+
FrameworkReferenceApp = CreateFrameworkReferenceApp(Constants.MicrosoftNETCoreApp, TestContext.MicrosoftNETCoreAppVersion, b => b
9999
.WithProject(DependencyName, "1.0.0", p => p
100100
.WithAssemblyGroup(null, g => g.WithAsset($"{DependencyName}.dll"))));
101101

src/installer/tests/HostActivation.Tests/DependencyResolution/LocalPath.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ private void RuntimeAssemblies(bool isSelfContained, bool useLocalPath)
6666
{
6767
// Add RID-specific assembly
6868
(string ridPath, string localRidPath) = GetPaths(libraryType, true);
69-
b.WithRuntimeLibrary(libraryType, $"{library}-{HostTestContext.BuildRID}", "1.0.0", p => p
70-
.WithAssemblyGroup(HostTestContext.BuildRID, g => g
69+
b.WithRuntimeLibrary(libraryType, $"{library}-{TestContext.BuildRID}", "1.0.0", p => p
70+
.WithAssemblyGroup(TestContext.BuildRID, g => g
7171
.WithAsset(ridPath, useLocalPath ? f => f.WithLocalPath(localRidPath) : null)));
7272
}
7373
}
@@ -114,7 +114,7 @@ private void RuntimeAssemblies(bool isSelfContained, bool useLocalPath)
114114
static (string Path, string LocalPath) GetPaths(RuntimeLibraryType libraryType, bool useRid)
115115
{
116116
string library = $"Test{libraryType}";
117-
string path = useRid ? $"lib/{HostTestContext.BuildRID}/{library}-{HostTestContext.BuildRID}.dll" : $"lib/{library}.dll";
117+
string path = useRid ? $"lib/{TestContext.BuildRID}/{library}-{TestContext.BuildRID}.dll" : $"lib/{library}.dll";
118118
return (path, $"{libraryType}/{path}");
119119
}
120120
}
@@ -137,9 +137,9 @@ private void NativeLibraries(bool isSelfContained, bool useLocalPath)
137137
{
138138
// Add RID-specific native library
139139
(string ridPath, string localRidPath) = GetPaths(libraryType, true);
140-
b.WithRuntimeLibrary(libraryType, $"{library}-{HostTestContext.BuildRID}", "1.0.0", p => p
141-
.WithNativeLibraryGroup(HostTestContext.BuildRID, g => g
142-
.WithAsset($"{ridPath}/{library}-{HostTestContext.BuildRID}.native", useLocalPath ? f => f.WithLocalPath($"{localRidPath}/{library}-{HostTestContext.BuildRID}.native") : null)));
140+
b.WithRuntimeLibrary(libraryType, $"{library}-{TestContext.BuildRID}", "1.0.0", p => p
141+
.WithNativeLibraryGroup(TestContext.BuildRID, g => g
142+
.WithAsset($"{ridPath}/{library}-{TestContext.BuildRID}.native", useLocalPath ? f => f.WithLocalPath($"{localRidPath}/{library}-{TestContext.BuildRID}.native") : null)));
143143
}
144144
}
145145

@@ -184,7 +184,7 @@ private void NativeLibraries(bool isSelfContained, bool useLocalPath)
184184

185185
static (string Path, string LocalPath) GetPaths(NetCoreAppBuilder.RuntimeLibraryType libraryType, bool useRid)
186186
{
187-
string path = useRid ? $"native/{HostTestContext.BuildRID}" : "native";
187+
string path = useRid ? $"native/{TestContext.BuildRID}" : "native";
188188
return (path, $"{libraryType}/{path}");
189189
}
190190
}
@@ -245,7 +245,7 @@ private static TestApp CreateApp(bool isSelfContained, Action<NetCoreAppBuilder>
245245
}
246246
else
247247
{
248-
app.PopulateFrameworkDependent(Constants.MicrosoftNETCoreApp, HostTestContext.MicrosoftNETCoreAppVersion, customizer);
248+
app.PopulateFrameworkDependent(Constants.MicrosoftNETCoreApp, TestContext.MicrosoftNETCoreAppVersion, customizer);
249249
}
250250
return app;
251251
}
@@ -257,7 +257,7 @@ public class SharedTestState : SharedTestStateBase
257257
public SharedTestState()
258258
{
259259
DotNetWithNetCoreApp = DotNet("WithNetCoreApp")
260-
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(HostTestContext.MicrosoftNETCoreAppVersion)
260+
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(TestContext.MicrosoftNETCoreAppVersion)
261261
.Build();
262262
}
263263
}

0 commit comments

Comments
 (0)