Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions src/installer/tests/HostActivation.Tests/DotnetArgValidation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void MuxerExec_MissingAppAssembly_Fails()
sharedTestState.BuiltDotNet.Exec("exec", assemblyName)
.CaptureStdOut()
.CaptureStdErr()
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail()
.And.HaveStdErrContaining($"The application to execute does not exist: '{assemblyName}'");
}
Expand All @@ -36,7 +36,7 @@ public void MuxerExec_MissingAppAssembly_BadExtension_Fails()
sharedTestState.BuiltDotNet.Exec("exec", assemblyName)
.CaptureStdOut()
.CaptureStdErr()
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail()
.And.HaveStdErrContaining($"The application to execute does not exist: '{assemblyName}'");
}
Expand All @@ -52,7 +52,7 @@ public void MuxerExec_BadExtension_Fails()
sharedTestState.BuiltDotNet.Exec("exec", assemblyName)
.CaptureStdOut()
.CaptureStdErr()
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail()
.And.HaveStdErrContaining($"dotnet exec needs a managed .dll or .exe extension. The application specified was '{assemblyName}'");
}
Expand All @@ -63,7 +63,7 @@ public void MissingArgumentValue_Fails()
sharedTestState.BuiltDotNet.Exec("--fx-version")
.CaptureStdOut()
.CaptureStdErr()
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail()
.And.HaveStdErrContaining($"Failed to parse supported options or their values:");
}
Expand All @@ -76,7 +76,7 @@ public void InvalidFileOrCommand_NoSDK_ListsPossibleIssues()
.WorkingDirectory(sharedTestState.BaseDirectory)
.CaptureStdOut()
.CaptureStdErr()
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail()
.And.HaveStdErrContaining($"The application '{fileName}' does not exist")
.And.FindAnySdk(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void ActivateDotnetTestXunitOnTestProject(
appDll)
.CaptureStdErr()
.CaptureStdOut()
.Execute(fExpectedToFail:true)
.Execute(expectedToFail:true)
.Should().Fail()
.And.HaveStdOutContaining("Total: 2")
.And.HaveStdOutContaining("Failed: 1");
Expand Down
36 changes: 12 additions & 24 deletions src/installer/tests/HostActivation.Tests/LightupAppActivation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void Dispose()
}
}

// Attempt to run the app with lightup deps.json specified but lightup library missing in the expected
// Attempt to run the app with lightup deps.json specified but lightup library missing in the expected
// probe locations.
[Fact]
public void Muxer_activation_of_LightupApp_NoLightupLib_Fails()
Expand All @@ -80,7 +80,7 @@ public void Muxer_activation_of_LightupApp_NoLightupLib_Fails()
dotnet.Exec("exec", "--additional-deps", libDepsJson, appDll)
.CaptureStdErr()
.CaptureStdOut()
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail()
.And.HaveStdErrContaining(
"Error:" + Environment.NewLine +
Expand Down Expand Up @@ -196,9 +196,7 @@ public void Muxer_activation_of_LightupApp_WithLightupLib_and_Roll_Backwards_Fro
// 8889.0.0
// Expected: 8888.0.4
dotnet.Exec("exec", "--additional-deps", baseDir, appDll)
.EnvironmentVariable("COREHOST_TRACE", "1")
.CaptureStdErr()
.CaptureStdOut()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello LightupClient")
Expand Down Expand Up @@ -256,9 +254,7 @@ public void Muxer_activation_of_LightupApp_WithLightupLib_and_Roll_Backwards_Fro
// 8888.0.5
// Expected: 8888.0.4
dotnet.Exec("exec", "--additional-deps", baseDir, appDll)
.EnvironmentVariable("COREHOST_TRACE", "1")
.CaptureStdErr()
.CaptureStdOut()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello LightupClient")
Expand Down Expand Up @@ -308,15 +304,13 @@ public void Muxer_activation_of_LightupApp_WithLightupLib_and_Roll_Backwards_Fai
// 8889.0.0
// Expected: fail since we only roll backward on patch, not minor
dotnet.Exec("exec", "--additional-deps", baseDir, appDll)
.EnvironmentVariable("COREHOST_TRACE", "1")
.CaptureStdErr()
.CaptureStdOut()
.Execute(fExpectedToFail: true)
.EnableTracingAndCaptureOutputs()
.Execute(expectedToFail: true)
.Should().Fail()
.And.HaveStdErrContaining($"No additional deps directory less than or equal to [8888.0.1] found with same major and minor version.");
}

// Attempt to run the app without lightup deps.json specified but lightup library present in the expected
// Attempt to run the app without lightup deps.json specified but lightup library present in the expected
// probe location (of being app-local).
[Fact]
public void Muxer_activation_of_LightupApp_WithLightupLib_NoLightupDepsJson_Fails()
Expand All @@ -339,7 +333,7 @@ public void Muxer_activation_of_LightupApp_WithLightupLib_NoLightupDepsJson_Fail
dotnet.Exec("exec", appDll)
.CaptureStdErr()
.CaptureStdOut()
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail()
.And.HaveStdOutContaining("Exception: Failed to load the lightup assembly!");
}
Expand Down Expand Up @@ -375,10 +369,8 @@ public void Additional_Deps_Lightup_Folder_With_Bad_JsonFile()

// Expected: a parsing error since the json file is bad.
dotnet.Exec("exec", "--additional-deps", additionalDepsRootPath, appDll)
.EnvironmentVariable("COREHOST_TRACE", "1")
.CaptureStdOut()
.CaptureStdErr()
.Execute(fExpectedToFail: true)
.EnableTracingAndCaptureOutputs()
.Execute(expectedToFail: true)
.Should().Fail()
.And.HaveStdErrContaining($"Error initializing the dependency resolver: An error occurred while parsing: {additionalDepsPath}");
}
Expand Down Expand Up @@ -426,9 +418,7 @@ public void SharedFx_With_Higher_Version_Wins_Against_Additional_Deps()
// Expected: the uber framework's version of System.Collections.Immutable is used instead of the additional-deps
string uberAssembly = Path.Combine(_uberFxBaseDir, "7777.0.0", "System.Collections.Immutable.dll");
dotnet.Exec("exec", "--additional-deps", additionalDepsPath, appDll)
.EnvironmentVariable("COREHOST_TRACE", "1")
.CaptureStdOut()
.CaptureStdErr()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
.And.HaveStdErrContaining($"Using specified additional deps.json: '{additionalDepsPath}'")
Expand Down Expand Up @@ -485,9 +475,7 @@ public void SharedFx_With_Lower_Version_Loses_Against_Additional_Deps()
// Expected: the additional dep's version of System.Collections.Immutable is used instead of the uber's assembly
string uberAssembly = Path.Combine(_uberFxBaseDir, "7777.0.0", "System.Collections.Immutable.dll");
dotnet.Exec("exec", "--additional-deps", additionalDepsPath, appDll)
.EnvironmentVariable("COREHOST_TRACE", "1")
.CaptureStdOut()
.CaptureStdErr()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
.And.HaveStdErrContaining($"Using specified additional deps.json: '{additionalDepsPath}'")
Expand Down
18 changes: 7 additions & 11 deletions src/installer/tests/HostActivation.Tests/MultilevelSDKLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MultilevelSDKLookup : IDisposable
private readonly string _regSdkBaseDir;
private readonly string _exeSelectedMessage;
private readonly string _regSelectedMessage;
private readonly string _multilevelDir;
private readonly TestArtifact _multilevelDir;

private const string _dotnetSdkDllMessageTerminator = "dotnet.dll]";

Expand All @@ -36,15 +36,15 @@ public MultilevelSDKLookup()
// The dotnetMultilevelSDKLookup dir will contain some folders and files that will be
// necessary to perform the tests
string baseMultilevelDir = Path.Combine(TestArtifact.TestArtifactsPath, "dotnetMultilevelSDKLookup");
_multilevelDir = SharedFramework.CalculateUniqueTestDirectory(baseMultilevelDir);
_multilevelDir = new TestArtifact(SharedFramework.CalculateUniqueTestDirectory(baseMultilevelDir));

// The tested locations will be the cwd, exe dir, and registered directory. cwd is no longer supported.
// All dirs will be placed inside the multilevel folder
_currentWorkingDir = Path.Combine(_multilevelDir, "cwd");
_exeDir = Path.Combine(_multilevelDir, "exe");
_regDir = Path.Combine(_multilevelDir, "reg");
_currentWorkingDir = Path.Combine(_multilevelDir.Location, "cwd");
_exeDir = Path.Combine(_multilevelDir.Location, "exe");
_regDir = Path.Combine(_multilevelDir.Location, "reg");

DotNet = new DotNetBuilder(_multilevelDir, Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"), "exe")
DotNet = new DotNetBuilder(_multilevelDir.Location, Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"), "exe")
.AddMicrosoftNETCoreAppFrameworkMockHostPolicy("9999.0.0")
.Build();

Expand All @@ -70,11 +70,7 @@ public MultilevelSDKLookup()
public void Dispose()
{
_testOnlyProductBehaviorMarker?.Dispose();

if (!TestArtifact.PreserveTestRuns())
{
Directory.Delete(_multilevelDir, true);
}
_multilevelDir.Dispose();
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion src/installer/tests/HostActivation.Tests/NativeHostApis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Breadcrumb_thread_does_not_finish_when_app_has_unhandled_exception()
dotnet.Exec(appDll)
.EnvironmentVariable("CORE_BREADCRUMBS", sharedTestState.BreadcrumbLocation)
.EnableTracingAndCaptureOutputs()
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail()
.And.HaveStdErrContaining("Unhandled exception.")
.And.HaveStdErrContaining("System.Exception: Goodbye World")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void RunApp_UnhandledException()
};

sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail()
.And.InitializeContextForApp(project.AppDll)
.And.ExecuteApplicationWithException(sharedState.NativeHostPath, project.AppDll);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void CallDelegateOnApplicationContext_UnhandledException()
};

sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail()
.And.InitializeContextForApp(appProject.AppDll)
.And.ExecuteFunctionPointerWithException(entryPoint, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public void CallDelegateOnComponentContext_UnhandledException()
};

sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail()
.And.InitializeContextForConfig(componentProject.RuntimeConfigJson)
.And.ExecuteComponentEntryPointWithException(entryPoint, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void Muxer_activation_of_Build_Output_Portable_DLL_with_DepsJson_having_A

dotnet.Exec("exec", appExe)
.CaptureStdErr()
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail()
.And.HaveStdErrContaining("has already been found but with a different file extension");
}
Expand Down Expand Up @@ -97,7 +97,7 @@ public void Muxer_Exec_activation_of_Build_Output_Portable_DLL_with_DepsJson_Loc
dotnet.Exec("exec", "--runtimeconfig", runtimeConfig, appDll)
.CaptureStdErr()
.CaptureStdOut()
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail();
}

Expand Down Expand Up @@ -242,7 +242,7 @@ public void Muxer_Exec_activation_of_Publish_Output_Portable_DLL_with_DepsJson_R
dotnet.Exec("exec", "--depsfile", depsJson, appDll)
.CaptureStdErr()
.CaptureStdOut()
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail();
}

Expand Down Expand Up @@ -479,14 +479,13 @@ public void AppHost_CLI_FrameworkDependent_MissingRuntimeFramework_ErrorReported
expectedUrlQuery = $"framework={Constants.MicrosoftNETCoreApp}&framework_version={sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}";
}

Command command = Command.Create(appExe)
CommandResult result = Command.Create(appExe)
.EnableTracingAndCaptureOutputs()
.DotNetRoot(invalidDotNet)
.MultilevelLookup(false)
.Start();
.Execute(expectedToFail: true);

var result = command.WaitForExit(true);
result.Should().Fail()
result.Should().Fail()
.And.HaveStdErrContaining($"https://aka.ms/dotnet-core-applaunch?{expectedUrlQuery}")
.And.HaveStdErrContaining(expectedStdErr);

Expand Down
15 changes: 6 additions & 9 deletions src/installer/tests/HostActivation.Tests/RuntimeProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ public class SharedTestState : IDisposable
public string FrameworkTestPropertyValue => "VALUE_FROM_FRAMEWORK";
public string HostFxrPathPropertyName => "HOSTFXR_PATH";

private readonly string copiedDotnet;
private readonly TestArtifact copiedDotnet;

public SharedTestState()
{
copiedDotnet = Path.Combine(TestArtifact.TestArtifactsPath, "runtimeProperties");
SharedFramework.CopyDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"), copiedDotnet);
copiedDotnet = new TestArtifact(Path.Combine(TestArtifact.TestArtifactsPath, "runtimeProperties"));
SharedFramework.CopyDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"), copiedDotnet.Location);

MockSDK = new DotNetBuilder(copiedDotnet, Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"), "exe")
MockSDK = new DotNetBuilder(copiedDotnet.Location, Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"), "exe")
.AddMicrosoftNETCoreAppFrameworkMockCoreClr("9999.0.0")
.AddMockSDK("9999.0.0-dev", "9999.0.0")
.Build();
Expand All @@ -147,7 +147,7 @@ public SharedTestState()
}
}");

RepoDirectories = new RepoDirectoriesProvider(builtDotnet: copiedDotnet);
RepoDirectories = new RepoDirectoriesProvider(builtDotnet: copiedDotnet.Location);

RuntimePropertiesFixture = new TestProjectFixture("RuntimeProperties", RepoDirectories)
.EnsureRestored()
Expand All @@ -165,10 +165,7 @@ public SharedTestState()
public void Dispose()
{
RuntimePropertiesFixture.Dispose();
if (!TestArtifact.PreserveTestRuns() && Directory.Exists(copiedDotnet))
{
Directory.Delete(copiedDotnet, true);
}
copiedDotnet.Dispose();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void Running_Publish_Output_Standalone_EXE_with_Unbound_AppHost_Fails()
int exitCode = Command.Create(appExe)
.CaptureStdErr()
.CaptureStdOut()
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.ExitCode;

if (OperatingSystem.IsWindows())
Expand Down Expand Up @@ -121,7 +121,7 @@ public void Running_Publish_Output_Standalone_EXE_By_Renaming_dotnet_exe_Fails()
int exitCode = Command.Create(appExe)
.CaptureStdErr()
.CaptureStdOut()
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.ExitCode;

if (OperatingSystem.IsWindows())
Expand Down Expand Up @@ -222,7 +222,7 @@ public void Running_Publish_Output_Standalone_EXE_With_DOTNET_ROOT_Fails()
Command.Create(appExe)
.EnableTracingAndCaptureOutputs()
.DotNetRoot(newOutDir)
.Execute(fExpectedToFail: true)
.Execute(expectedToFail: true)
.Should().Fail()
.And.HaveUsedDotNetRootInstallLocation(Path.GetFullPath(newOutDir), fixture.CurrentRid)
.And.HaveStdErrContaining($"The required library {RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("hostfxr")} could not be found.");
Expand Down
Loading