Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions eng/targetingpacks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@
<Target Name="UpdateLocalAppHostPack"
Condition="'$(UseLocalAppHostPack)' == 'true'"
AfterTargets="ResolveFrameworkReferences">
<PropertyGroup Condition="'$(UseBootstrapLayout)' != 'true'">
<LocalRefPackDir>$(MicrosoftNetCoreAppRefPackDir)</LocalRefPackDir>
<LocalRuntimePackDir>$(MicrosoftNetCoreAppRuntimePackDir)</LocalRuntimePackDir>
</PropertyGroup>
<PropertyGroup Condition="'$(UseBootstrapLayout)' == 'true'">
<LocalRefPackDir>$(BootstrapRefPackDir)</LocalRefPackDir>
<LocalRuntimePackDir>$(BootstrapRuntimePackDir)</LocalRuntimePackDir>
</PropertyGroup>
<PropertyGroup>
<AppHostSourcePath>$(LocalAppHostPath)</AppHostSourcePath>
<SingleFileHostSourcePath>$(LocalSingleFileHostPath)</SingleFileHostSourcePath>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that we need to make sure that LocalAppHostPath is set to the bootstrapped one.

For the Host xunit tests, we should also set those projects to have UseBoootstrapLayout=true when UseBootstrap=true.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
Expand Down
31 changes: 17 additions & 14 deletions src/installer/tests/AppHost.Bundle.Tests/AppLaunch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private void RunTheApp(string path, bool selfContained)
Command.Create(path)
.CaptureStdErr()
.CaptureStdOut()
.DotNetRoot(selfContained ? null : TestContext.BuiltDotNet.BinPath)
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World!");
Expand Down Expand Up @@ -75,9 +75,9 @@ private void RunApp(bool selfContained)
if (OperatingSystem.IsWindows())
{
// StandaloneApp sets FileVersion to NETCoreApp version. On Windows, this should be copied to singlefilehost resources.
string expectedVersion = TestContext.MicrosoftNETCoreAppVersion.Contains('-')
? TestContext.MicrosoftNETCoreAppVersion[..TestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
: TestContext.MicrosoftNETCoreAppVersion;
string expectedVersion = HostTestContext.MicrosoftNETCoreAppVersion.Contains('-')
? HostTestContext.MicrosoftNETCoreAppVersion[..HostTestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
: HostTestContext.MicrosoftNETCoreAppVersion;
Assert.Equal(expectedVersion, System.Diagnostics.FileVersionInfo.GetVersionInfo(singleFile).FileVersion);
}
}
Expand All @@ -103,14 +103,17 @@ private void NonAsciiCharacterSelfContainedApp()
if (OperatingSystem.IsWindows())
{
// StandaloneApp sets FileVersion to NETCoreApp version. On Windows, this should be copied to singlefilehost resources.
string expectedVersion = TestContext.MicrosoftNETCoreAppVersion.Contains('-')
? TestContext.MicrosoftNETCoreAppVersion[..TestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
: TestContext.MicrosoftNETCoreAppVersion;
string expectedVersion = HostTestContext.MicrosoftNETCoreAppVersion.Contains('-')
? HostTestContext.MicrosoftNETCoreAppVersion[..HostTestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
: HostTestContext.MicrosoftNETCoreAppVersion;
Assert.Equal(expectedVersion, System.Diagnostics.FileVersionInfo.GetVersionInfo(singleFile).FileVersion);
}
}

[ConditionalTheory(typeof(Binaries.CetCompat), nameof(Binaries.CetCompat.IsSupported))]
[Theory(
SkipType = typeof(Binaries.CetCompat),
SkipUnless = nameof(Binaries.CetCompat.IsSupported),
Skip = "CET is not supported on this platform")]
[InlineData(true)]
[InlineData(false)]
public void DisableCetCompat(bool selfContained)
Expand All @@ -124,12 +127,12 @@ public void DisableCetCompat(bool selfContained)
Command.Create(singleFile)
.CaptureStdErr()
.CaptureStdOut()
.DotNetRoot(TestContext.BuiltDotNet.BinPath, TestContext.BuildArchitecture)
.DotNetRoot(HostTestContext.BuiltDotNet.BinPath, HostTestContext.BuildArchitecture)
.MultilevelLookup(false)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
.And.HaveStdOutContaining(TestContext.MicrosoftNETCoreAppVersion);
.And.HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
}

[Theory]
Expand Down Expand Up @@ -158,7 +161,7 @@ public void FrameworkDependent_NoBundleEntryPoint()

using (var dotnetWithMockHostFxr = TestArtifact.Create("mockhostfxrFrameworkMissingFailure"))
{
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, TestContext.BuiltDotNet.BinPath, null)
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, HostTestContext.BuiltDotNet.BinPath, null)
.RemoveHostFxr()
.AddMockHostFxr(new Version(2, 2, 0))
.Build();
Expand All @@ -177,7 +180,7 @@ public void FrameworkDependent_NoBundleEntryPoint()
}

[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // GUI app host is only supported on Windows.
[PlatformSpecific(TestPlatforms.Windows)]
public void FrameworkDependent_GUI_DownlevelHostFxr_ErrorDialog()
{
var singleFile = sharedTestState.FrameworkDependentApp.Bundle();
Expand All @@ -188,14 +191,14 @@ public void FrameworkDependent_GUI_DownlevelHostFxr_ErrorDialog()
{
string expectedErrorCode = Constants.ErrorCode.BundleExtractionFailure.ToString("x");

var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, TestContext.BuiltDotNet.BinPath, null)
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, HostTestContext.BuiltDotNet.BinPath, null)
.RemoveHostFxr()
.AddMockHostFxr(new Version(5, 0, 0))
.Build();

Command command = Command.Create(singleFile)
.EnableTracingAndCaptureOutputs()
.DotNetRoot(dotnet.BinPath, TestContext.BuildArchitecture)
.DotNetRoot(dotnet.BinPath, HostTestContext.BuildArchitecture)
.Start();

WindowsUtils.WaitForPopupFromProcess(command.Process);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private FluentAssertions.AndConstraint<CommandResultAssertions> RunTheApp(string
{
CommandResult result = Command.Create(path)
.EnableTracingAndCaptureOutputs()
.DotNetRoot(selfContained ? null : TestContext.BuiltDotNet.BinPath)
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
.MultilevelLookup(false)
.Execute();
if (deleteApp)
Expand Down Expand Up @@ -142,8 +142,7 @@ public void FrameworkDependent_Targeting50(BundleOptions options)
}
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/54234")]
[Fact(Skip = "https://github.com/dotnet/runtime/issues/54234")]
// NOTE: when enabling this test take a look at commented code marked by "ACTIVE ISSUE:" in SharedTestState
public void SelfContained_R2R_Composite()
{
Expand Down
4 changes: 2 additions & 2 deletions src/installer/tests/AppHost.Bundle.Tests/NativeLibraries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private void PInvoke(bool selfContained, bool bundleNative)
Command.Create(app, "load_native_library_pinvoke")
.CaptureStdErr()
.CaptureStdOut()
.DotNetRoot(selfContained ? null : TestContext.BuiltDotNet.BinPath)
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
// Specify an extraction root that will get cleaned up by the test app artifact
.EnvironmentVariable(Constants.BundleExtractBase.EnvironmentVariable, extractionRoot)
.Execute()
Expand Down Expand Up @@ -66,7 +66,7 @@ private void TryLoad(bool selfContained, bool bundleNative)
Command.Create(app, "load_native_library_api")
.CaptureStdErr()
.CaptureStdOut()
.DotNetRoot(selfContained ? null : TestContext.BuiltDotNet.BinPath)
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
// Specify an extraction root that will get cleaned up by the test app artifact
.EnvironmentVariable(Constants.BundleExtractBase.EnvironmentVariable, extractionRoot)
.Execute()
Expand Down
9 changes: 4 additions & 5 deletions src/installer/tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
<PropertyGroup>
<TestArtifactsOutputRoot>$(ArtifactsDir)tests\host\$(TargetOS).$(TargetArchitecture).$(Configuration)\</TestArtifactsOutputRoot>
<TestInfraTargetFramework>$(NetCoreAppToolCurrent)</TestInfraTargetFramework>
<TestCaseFilter>category!=failing</TestCaseFilter>
<TestRunnerAdditionalArguments>--filter $(TestCaseFilter) -v detailed</TestRunnerAdditionalArguments>
<TestCaseFilter>/[category!=failing]</TestCaseFilter>
<TestRunnerAdditionalArguments>--filter-query $(TestCaseFilter)</TestRunnerAdditionalArguments>
<!-- Enable crash and hang dumps -->
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --blame-crash-dump-type full</TestRunnerAdditionalArguments>
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --blame-hang-timeout 5m --blame-hang-dump-type full</TestRunnerAdditionalArguments>
<UseVSTestRunner>true</UseVSTestRunner>
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --crashdump</TestRunnerAdditionalArguments>
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --hangdump --hangdump-timeout 5m --hangdump-type full</TestRunnerAdditionalArguments>
<RunAnalyzers>false</RunAnalyzers>
</PropertyGroup>

Expand Down
5 changes: 5 additions & 0 deletions src/installer/tests/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
<RunSettingsTestCaseFilter>$(TestCaseFilter)</RunSettingsTestCaseFilter>
</PropertyGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<PackageReference Include="Microsoft.Testing.Extensions.CrashDump" Version="1.7.3" />
<PackageReference Include="Microsoft.Testing.Extensions.HangDump" Version="1.7.3" />
</ItemGroup>

<Import Project="$(RepositoryEngineeringDir)testing\runsettings.targets"
Condition="'$(IsTestProject)' == 'true'" />

Expand Down
4 changes: 2 additions & 2 deletions src/installer/tests/HostActivation.Tests/Breadcrumbs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Breadcrumbs(SharedTestState fixture)
[Fact]
public void BreadcrumbThreadFinishes()
{
TestContext.BuiltDotNet.Exec(sharedTestState.App.AppDll)
HostTestContext.BuiltDotNet.Exec(sharedTestState.App.AppDll)
.EnvironmentVariable(Constants.Breadcrumbs.EnvironmentVariable, sharedTestState.BreadcrumbLocation)
.EnableTracingAndCaptureOutputs()
.Execute()
Expand All @@ -34,7 +34,7 @@ public void BreadcrumbThreadFinishes()
[Fact]
public void UnhandledException_BreadcrumbThreadDoesNotFinish()
{
TestContext.BuiltDotNet.Exec(sharedTestState.App.AppDll, "throw_exception")
HostTestContext.BuiltDotNet.Exec(sharedTestState.App.AppDll, "throw_exception")
.EnvironmentVariable(Constants.Breadcrumbs.EnvironmentVariable, sharedTestState.BreadcrumbLocation)
.EnableTracingAndCaptureOutputs()
.DisableDumps() // Expected to throw an exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,24 @@ public class SharedTestState : SharedTestStateBase
public SharedTestState()
{
DotNetWithNetCoreApp = DotNet("WithNetCoreApp")
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(TestContext.MicrosoftNETCoreAppVersion)
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(HostTestContext.MicrosoftNETCoreAppVersion)
.Build();

string nativeDependencyRelPath = $"{TestContext.BuildRID}/{Binaries.GetSharedLibraryFileNameForCurrentPlatform("native")}";
FrameworkReferenceApp = CreateFrameworkReferenceApp(Constants.MicrosoftNETCoreApp, TestContext.MicrosoftNETCoreAppVersion, b => b
string nativeDependencyRelPath = $"{HostTestContext.BuildRID}/{Binaries.GetSharedLibraryFileNameForCurrentPlatform("native")}";
FrameworkReferenceApp = CreateFrameworkReferenceApp(Constants.MicrosoftNETCoreApp, HostTestContext.MicrosoftNETCoreAppVersion, b => b
.WithProject(DependencyName, DependencyVersion, p => p
.WithAssemblyGroup(null, g => g
.WithAsset($"{DependencyName}.dll", f => f.NotOnDisk()))
.WithNativeLibraryGroup(TestContext.BuildRID, g => g
.WithNativeLibraryGroup(HostTestContext.BuildRID, g => g
.WithAsset(nativeDependencyRelPath, f => f.NotOnDisk()))));
RuntimeConfig.FromFile(FrameworkReferenceApp.RuntimeConfigJson)
.WithTfm(TestContext.Tfm)
.WithTfm(HostTestContext.Tfm)
.Save();

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

AdditionalProbingPath_ArchTfm = Path.Combine(AdditionalProbingPath, TestContext.BuildArchitecture, TestContext.Tfm);
AdditionalProbingPath_ArchTfm = Path.Combine(AdditionalProbingPath, HostTestContext.BuildArchitecture, HostTestContext.Tfm);
(DependencyPath_ArchTfm, NativeDependencyDirectory_ArchTfm) = AddDependencies(AdditionalProbingPath_ArchTfm);

(string, string) AddDependencies(string probeDir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public class SharedTestState : SharedTestStateBase
public SharedTestState()
{
DotNetWithNetCoreApp = DotNet("WithNetCoreApp")
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(TestContext.MicrosoftNETCoreAppVersion)
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(HostTestContext.MicrosoftNETCoreAppVersion)
.Build();

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ private void RuntimeAssemblies(bool isSelfContained, bool useLocalPath)
{
// Add RID-specific assembly
(string ridPath, string localRidPath) = GetPaths(libraryType, true);
b.WithRuntimeLibrary(libraryType, $"{library}-{TestContext.BuildRID}", "1.0.0", p => p
.WithAssemblyGroup(TestContext.BuildRID, g => g
b.WithRuntimeLibrary(libraryType, $"{library}-{HostTestContext.BuildRID}", "1.0.0", p => p
.WithAssemblyGroup(HostTestContext.BuildRID, g => g
.WithAsset(ridPath, useLocalPath ? f => f.WithLocalPath(localRidPath) : null)));
}
}
Expand Down Expand Up @@ -114,7 +114,7 @@ private void RuntimeAssemblies(bool isSelfContained, bool useLocalPath)
static (string Path, string LocalPath) GetPaths(RuntimeLibraryType libraryType, bool useRid)
{
string library = $"Test{libraryType}";
string path = useRid ? $"lib/{TestContext.BuildRID}/{library}-{TestContext.BuildRID}.dll" : $"lib/{library}.dll";
string path = useRid ? $"lib/{HostTestContext.BuildRID}/{library}-{HostTestContext.BuildRID}.dll" : $"lib/{library}.dll";
return (path, $"{libraryType}/{path}");
}
}
Expand All @@ -137,9 +137,9 @@ private void NativeLibraries(bool isSelfContained, bool useLocalPath)
{
// Add RID-specific native library
(string ridPath, string localRidPath) = GetPaths(libraryType, true);
b.WithRuntimeLibrary(libraryType, $"{library}-{TestContext.BuildRID}", "1.0.0", p => p
.WithNativeLibraryGroup(TestContext.BuildRID, g => g
.WithAsset($"{ridPath}/{library}-{TestContext.BuildRID}.native", useLocalPath ? f => f.WithLocalPath($"{localRidPath}/{library}-{TestContext.BuildRID}.native") : null)));
b.WithRuntimeLibrary(libraryType, $"{library}-{HostTestContext.BuildRID}", "1.0.0", p => p
.WithNativeLibraryGroup(HostTestContext.BuildRID, g => g
.WithAsset($"{ridPath}/{library}-{HostTestContext.BuildRID}.native", useLocalPath ? f => f.WithLocalPath($"{localRidPath}/{library}-{HostTestContext.BuildRID}.native") : null)));
}
}

Expand Down Expand Up @@ -184,7 +184,7 @@ private void NativeLibraries(bool isSelfContained, bool useLocalPath)

static (string Path, string LocalPath) GetPaths(NetCoreAppBuilder.RuntimeLibraryType libraryType, bool useRid)
{
string path = useRid ? $"native/{TestContext.BuildRID}" : "native";
string path = useRid ? $"native/{HostTestContext.BuildRID}" : "native";
return (path, $"{libraryType}/{path}");
}
}
Expand Down Expand Up @@ -245,7 +245,7 @@ private static TestApp CreateApp(bool isSelfContained, Action<NetCoreAppBuilder>
}
else
{
app.PopulateFrameworkDependent(Constants.MicrosoftNETCoreApp, TestContext.MicrosoftNETCoreAppVersion, customizer);
app.PopulateFrameworkDependent(Constants.MicrosoftNETCoreApp, HostTestContext.MicrosoftNETCoreAppVersion, customizer);
}
return app;
}
Expand All @@ -257,7 +257,7 @@ public class SharedTestState : SharedTestStateBase
public SharedTestState()
{
DotNetWithNetCoreApp = DotNet("WithNetCoreApp")
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(TestContext.MicrosoftNETCoreAppVersion)
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(HostTestContext.MicrosoftNETCoreAppVersion)
.Build();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected override void CustomizeDotNetWithNetCoreApp(DotNetBuilder builder)
HighWare,
"1.1.1",
runtimeConfig => runtimeConfig.WithFramework(Constants.MicrosoftNETCoreApp, "4.0.0"),
path => NetCoreAppBuilder.ForNETCoreApp(HighWare, TestContext.BuildRID)
path => NetCoreAppBuilder.ForNETCoreApp(HighWare, HostTestContext.BuildRID)
.WithProject(HighWare, "1.1.1", p => p
.WithAssemblyGroup(null, g => g
.WithAsset(TestAssemblyWithNoVersions + ".dll")
Expand Down
Loading