Skip to content

Commit 4909904

Browse files
authored
Revert "Revert "Move hosting tests to XUnit 3"" (#121072)
Reverts #120997
1 parent f204e02 commit 4909904

File tree

68 files changed

+414
-362
lines changed

Some content is hidden

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

68 files changed

+414
-362
lines changed

src/installer/Directory.Build.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,12 @@
1313
The NuGet fallback folder can/will contain packages we are building in this repo, and we
1414
want to ensure we use the correct packages. -->
1515
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
16+
<UseBootstrapLayout Condition="'$(UseBootstrap)' == 'true'">true</UseBootstrapLayout>
17+
</PropertyGroup>
18+
19+
<!-- Bootstrap layout is used when we don't have an LKG apphost to rely on, like on freebsd. -->
20+
<PropertyGroup Condition="'$(UseBootstrapLayout)' == 'true'">
21+
<UseLocalAppHostPack Condition="'$(UseBootstrapLayout)' == 'true'">true</UseLocalAppHostPack>
22+
<UseLocalTargetingRuntimePack Condition="'$(UseBootstrapLayout)' == 'true'">false</UseLocalTargetingRuntimePack>
1623
</PropertyGroup>
1724
</Project>

src/installer/Directory.Build.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<Project>
22

3+
<Import Project="$(RepositoryEngineeringDir)targetingpacks.targets" Condition="'$(UseBootstrapLayout)' == 'true'" />
4+
35
<PropertyGroup>
46
<InstallerName>$(InstallerName)</InstallerName>
57
</PropertyGroup>

src/installer/pkg/sfx/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<EnsureRuntimeIdentifierSet>true</EnsureRuntimeIdentifierSet>
4+
<UseLocalTargetingRuntimePack>true</UseLocalTargetingRuntimePack>
45
</PropertyGroup>
56

67
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props, $(MSBuildThisFileDirectory)..))" />

src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
<Import Project="$(Crossgen2SdkOverridePropsPath)" Condition="'$(PublishReadyToRun)' == 'true' and '$(Crossgen2SdkOverridePropsPath)' != ''" />
8787
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
8888
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.SharedFramework.Sdk" />
89-
<Import Project="$(RepositoryEngineeringDir)targetingpacks.targets" />
9089
<Import Project="$(RepositoryEngineeringDir)codeOptimization.targets" />
9190
<Import Project="$(Crossgen2SdkOverrideTargetsPath)" Condition="'$(PublishReadyToRun)' == 'true' and '$(Crossgen2SdkOverrideTargetsPath)' != ''" />
9291
</Project>

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

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

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

1518
<ItemGroup>

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

Lines changed: 19 additions & 16 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 : TestContext.BuiltDotNet.BinPath)
30+
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
3131
.Execute()
3232
.Should().Pass()
3333
.And.HaveStdOutContaining("Hello World!");
@@ -75,10 +75,10 @@ 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 = TestContext.MicrosoftNETCoreAppVersion.Contains('-')
79-
? TestContext.MicrosoftNETCoreAppVersion[..TestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
80-
: TestContext.MicrosoftNETCoreAppVersion;
81-
Assert.Equal(expectedVersion, System.Diagnostics.FileVersionInfo.GetVersionInfo(singleFile).FileVersion);
78+
string expectedVersion = HostTestContext.MicrosoftNETCoreAppVersion.Contains('-')
79+
? HostTestContext.MicrosoftNETCoreAppVersion[..HostTestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
80+
: HostTestContext.MicrosoftNETCoreAppVersion;
81+
Assert.Equal($"{expectedVersion}.0", System.Diagnostics.FileVersionInfo.GetVersionInfo(singleFile).FileVersion);
8282
}
8383
}
8484

@@ -103,14 +103,17 @@ 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 = TestContext.MicrosoftNETCoreAppVersion.Contains('-')
107-
? TestContext.MicrosoftNETCoreAppVersion[..TestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
108-
: TestContext.MicrosoftNETCoreAppVersion;
109-
Assert.Equal(expectedVersion, System.Diagnostics.FileVersionInfo.GetVersionInfo(singleFile).FileVersion);
106+
string expectedVersion = HostTestContext.MicrosoftNETCoreAppVersion.Contains('-')
107+
? HostTestContext.MicrosoftNETCoreAppVersion[..HostTestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
108+
: HostTestContext.MicrosoftNETCoreAppVersion;
109+
Assert.Equal($"{expectedVersion}.0", System.Diagnostics.FileVersionInfo.GetVersionInfo(singleFile).FileVersion);
110110
}
111111
}
112112

113-
[ConditionalTheory(typeof(Binaries.CetCompat), nameof(Binaries.CetCompat.IsSupported))]
113+
[Theory(
114+
SkipType = typeof(Binaries.CetCompat),
115+
SkipUnless = nameof(Binaries.CetCompat.IsSupported),
116+
Skip = "CET is not supported on this platform")]
114117
[InlineData(true)]
115118
[InlineData(false)]
116119
public void DisableCetCompat(bool selfContained)
@@ -124,12 +127,12 @@ public void DisableCetCompat(bool selfContained)
124127
Command.Create(singleFile)
125128
.CaptureStdErr()
126129
.CaptureStdOut()
127-
.DotNetRoot(TestContext.BuiltDotNet.BinPath, TestContext.BuildArchitecture)
130+
.DotNetRoot(HostTestContext.BuiltDotNet.BinPath, HostTestContext.BuildArchitecture)
128131
.MultilevelLookup(false)
129132
.Execute()
130133
.Should().Pass()
131134
.And.HaveStdOutContaining("Hello World")
132-
.And.HaveStdOutContaining(TestContext.MicrosoftNETCoreAppVersion);
135+
.And.HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
133136
}
134137

135138
[Theory]
@@ -158,7 +161,7 @@ public void FrameworkDependent_NoBundleEntryPoint()
158161

159162
using (var dotnetWithMockHostFxr = TestArtifact.Create("mockhostfxrFrameworkMissingFailure"))
160163
{
161-
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, TestContext.BuiltDotNet.BinPath, null)
164+
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, HostTestContext.BuiltDotNet.BinPath, null)
162165
.RemoveHostFxr()
163166
.AddMockHostFxr(new Version(2, 2, 0))
164167
.Build();
@@ -177,7 +180,7 @@ public void FrameworkDependent_NoBundleEntryPoint()
177180
}
178181

179182
[Fact]
180-
[PlatformSpecific(TestPlatforms.Windows)] // GUI app host is only supported on Windows.
183+
[PlatformSpecific(TestPlatforms.Windows)]
181184
public void FrameworkDependent_GUI_DownlevelHostFxr_ErrorDialog()
182185
{
183186
var singleFile = sharedTestState.FrameworkDependentApp.Bundle();
@@ -188,14 +191,14 @@ public void FrameworkDependent_GUI_DownlevelHostFxr_ErrorDialog()
188191
{
189192
string expectedErrorCode = Constants.ErrorCode.BundleExtractionFailure.ToString("x");
190193

191-
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, TestContext.BuiltDotNet.BinPath, null)
194+
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, HostTestContext.BuiltDotNet.BinPath, null)
192195
.RemoveHostFxr()
193196
.AddMockHostFxr(new Version(5, 0, 0))
194197
.Build();
195198

196199
Command command = Command.Create(singleFile)
197200
.EnableTracingAndCaptureOutputs()
198-
.DotNetRoot(dotnet.BinPath, TestContext.BuildArchitecture)
201+
.DotNetRoot(dotnet.BinPath, HostTestContext.BuildArchitecture)
199202
.Start();
200203

201204
WindowsUtils.WaitForPopupFromProcess(command.Process);

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

Lines changed: 1 addition & 1 deletion
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 : TestContext.BuiltDotNet.BinPath)
27+
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
2828
.MultilevelLookup(false)
2929
.Execute();
3030
if (deleteApp)

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 : TestContext.BuiltDotNet.BinPath)
41+
.DotNetRoot(selfContained ? null : HostTestContext.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 : TestContext.BuiltDotNet.BinPath)
69+
.DotNetRoot(selfContained ? null : HostTestContext.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/Assets/Projects/Directory.Build.targets

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<Project>
2+
<Import Project="$(RepositoryEngineeringDir)liveBuilds.targets" />
23
<Import Project="$(RepositoryEngineeringDir)targetingpacks.targets" />
34

4-
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets, $(MSBuildThisFileDirectory)..))" />
5-
65
<PropertyGroup>
7-
<UseAppHost Condition="'$(UseAppHost)' == '' and '$(SelfContained)' != 'true'">false</UseAppHost>
6+
<UseAppHost Condition="'$(SelfContained)' != 'true'">false</UseAppHost>
87
</PropertyGroup>
98

109
<!-- Override target from targetingpacks.targets. Use Version instead of ProductVersion (written into runtimeconfig.json).

src/installer/tests/Directory.Build.props

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

0 commit comments

Comments
 (0)