Skip to content
Draft
Changes from all 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
27 changes: 25 additions & 2 deletions src/installer/tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ private FluentAssertions.AndConstraint<CommandResultAssertions> RunTheApp(string
CommandResult result = Command.Create(path)
.EnableTracingAndCaptureOutputs()
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
.EnvironmentVariable(Constants.BundleExtractBase.EnvironmentVariable, GetExtractionRootPath(path))
.Execute();
if (deleteApp)
{
Expand All @@ -39,6 +40,20 @@ private FluentAssertions.AndConstraint<CommandResultAssertions> RunTheApp(string
.And.HaveStdOutContaining("Wow! We now say hello to the big world and you.");
}

private static string GetExtractionRootPath(string path)
{
string extractionRoot = Path.Combine(Path.GetDirectoryName(path), "extract");
// Native extraction must support the long-name content even when the test artifact path exceeds MAX_PATH.
if (OperatingSystem.IsWindows() && !extractionRoot.StartsWith(@"\\?\", StringComparison.Ordinal))
{
extractionRoot = extractionRoot.StartsWith(@"\\", StringComparison.Ordinal)
? @"\\?\UNC\" + extractionRoot[2..]
: @"\\?\" + extractionRoot;
}

return extractionRoot;
}

private static void DeleteExtractionDirectory(CommandResult result)
{
Assert.False(string.IsNullOrEmpty(result.StdErr), "Attempted to get extraction directory from empty stderr. Ensure tracing was enabled and stderr captured.");
Expand All @@ -64,7 +79,7 @@ private static void DeleteExtractionDirectory(CommandResult result)
[InlineData(BundleOptions.BundleAllContent)]
public void FrameworkDependent(BundleOptions options)
{
var singleFile = sharedTestState.FrameworkDependentApp.Bundle(options);
var singleFile = sharedTestState.FrameworkDependentApp.Bundle(options, out Manifest manifest);

// Run the bundled app
bool shouldExtract = options.HasFlag(BundleOptions.BundleAllContent);
Expand All @@ -73,6 +88,10 @@ public void FrameworkDependent(BundleOptions options)

if (shouldExtract)
{
sharedTestState.FrameworkDependentApp
.GetExtractionDir(GetExtractionRootPath(singleFile), manifest)
.Should().Exist();

// Run the bundled app again (reuse extracted files)
RunTheApp(singleFile, selfContained: false)
.And.ReuseExtraction();
Expand All @@ -86,7 +105,7 @@ public void FrameworkDependent(BundleOptions options)
[InlineData(BundleOptions.BundleAllContent | BundleOptions.EnableCompression)]
public void SelfContained(BundleOptions options)
{
var singleFile = sharedTestState.SelfContainedApp.Bundle(options);
var singleFile = sharedTestState.SelfContainedApp.Bundle(options, out Manifest manifest);

// Run the bundled app
bool shouldExtract = options.HasFlag(BundleOptions.BundleAllContent);
Expand All @@ -95,6 +114,10 @@ public void SelfContained(BundleOptions options)

if (shouldExtract)
{
sharedTestState.SelfContainedApp
.GetExtractionDir(GetExtractionRootPath(singleFile), manifest)
.Should().Exist();

// Run the bundled app again (reuse extracted files)
RunTheApp(singleFile, selfContained: true)
.And.ReuseExtraction();
Expand Down
Loading