Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/installer/tests/AppHost.Bundle.Tests/AppLaunch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void FrameworkDependent_GUI_DownlevelHostFxr_ErrorDialog()
command.Process.Kill();

command
.WaitForExit(true)
.WaitForExit()
.Should().Fail()
.And.HaveStdErrContaining("Bundle header version compatibility check failed.")
.And.HaveStdErrContaining($"Showing error dialog for application: '{Path.GetFileName(singleFile)}' - error code: 0x{expectedErrorCode}")
Expand Down
4 changes: 2 additions & 2 deletions src/installer/tests/AppHost.Bundle.Tests/BundleRename.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public BundleRename(SharedTestState fixture)
[Theory]
[ActiveIssue("https://github.com/dotnet/runtime/issues/38013")]
[InlineData(true)] // Test renaming the single-exe when contents are extracted
[InlineData(false)] // Test renaming the single-exe when contents are not extracted
[InlineData(false)] // Test renaming the single-exe when contents are not extracted
private void Bundle_can_be_renamed_while_running(bool testExtraction)
{
string singleFile = sharedTestState.App.Bundle(testExtraction ? BundleOptions.BundleAllContent : BundleOptions.None);
Expand Down Expand Up @@ -51,7 +51,7 @@ private void Bundle_can_be_renamed_while_running(bool testExtraction)
File.Move(singleFile, renameFile);
File.Create(resumeFile).Close();

singleExe.WaitForExit(expectedToFail: false, twoMinutes)
singleExe.WaitForExit(twoMinutes)
.Should().Pass()
.And.HaveStdOutContaining("Hello World!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.DotNet.Cli.Build.Framework;
using System;
using System.IO;
using System.Runtime.CompilerServices;

namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution
{
Expand Down Expand Up @@ -44,12 +45,12 @@ protected virtual void CustomizeDotNetWithNetCoreApp(DotNetBuilder builder)
{
}

public CommandResult RunComponentResolutionTest(TestApp component, Action<Command> commandCustomizer = null)
public CommandResult RunComponentResolutionTest(TestApp component, Action<Command> commandCustomizer = null, [CallerMemberName] string caller = "")
{
return RunComponentResolutionTest(component.AppDll, FrameworkReferenceApp, DotNetWithNetCoreApp.GreatestVersionHostFxrPath, commandCustomizer);
return RunComponentResolutionTest(component.AppDll, FrameworkReferenceApp, DotNetWithNetCoreApp.GreatestVersionHostFxrPath, commandCustomizer, caller);
}

public CommandResult RunComponentResolutionTest(string componentPath, TestApp hostApp, string hostFxrFolder, Action<Command> commandCustomizer = null)
public CommandResult RunComponentResolutionTest(string componentPath, TestApp hostApp, string hostFxrFolder, Action<Command> commandCustomizer = null, [CallerMemberName] string caller = "")
{
string[] args =
{
Expand All @@ -65,16 +66,16 @@ public CommandResult RunComponentResolutionTest(string componentPath, TestApp ho
.MultilevelLookup(false);
commandCustomizer?.Invoke(command);

return command.Execute()
return command.Execute(caller)
.StdErrAfter("corehost_resolve_component_dependencies = {");
}

public CommandResult RunComponentResolutionMultiThreadedTest(TestApp componentOne, TestApp componentTwo)
public CommandResult RunComponentResolutionMultiThreadedTest(TestApp componentOne, TestApp componentTwo, [CallerMemberName] string caller = "")
{
return RunComponentResolutionMultiThreadedTest(componentOne.AppDll, componentTwo.AppDll, FrameworkReferenceApp, DotNetWithNetCoreApp.GreatestVersionHostFxrPath);
return RunComponentResolutionMultiThreadedTest(componentOne.AppDll, componentTwo.AppDll, FrameworkReferenceApp, DotNetWithNetCoreApp.GreatestVersionHostFxrPath, caller);
}

public CommandResult RunComponentResolutionMultiThreadedTest(string componentOnePath, string componentTwoPath, TestApp hostApp, string hostFxrFolder)
public CommandResult RunComponentResolutionMultiThreadedTest(string componentOnePath, string componentTwoPath, TestApp hostApp, string hostFxrFolder, [CallerMemberName] string caller = "")
{
string[] args =
{
Expand All @@ -89,7 +90,7 @@ public CommandResult RunComponentResolutionMultiThreadedTest(string componentOne
return Command.Create(NativeHostPath, args)
.EnableTracingAndCaptureOutputs()
.MultilevelLookup(false)
.Execute();
.Execute(caller);
}

protected override void Dispose(bool disposing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public void DepsJsonWithUtf8Bom()
{
// Test that .deps.json files with UTF8 BOM are parsed correctly
TestApp app = sharedState.FrameworkReferenceApp;

// Create a copy of the existing deps.json with UTF8 BOM
string depsJsonWithBom = Path.Combine(Path.GetDirectoryName(sharedState.DepsJsonPath),
string depsJsonWithBom = Path.Combine(Path.GetDirectoryName(sharedState.DepsJsonPath),
Path.GetFileNameWithoutExtension(sharedState.DepsJsonPath) + "_bom.deps.json");

try
{
// Read the original deps.json content and write with UTF8 BOM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.IO;
using System.Runtime.CompilerServices;
using Xunit;

namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution
Expand Down Expand Up @@ -59,7 +60,7 @@ public void AppWithSameAssemblyAsFramework(string testAssemblyName, string appAs
RunTest(testAssemblyName, appAsmVersion, appFileVersion, appWins);
}

protected abstract void RunTest(string testAssemblyName, string appAsmVersion, string appFileVersion, bool appWins);
protected abstract void RunTest(string testAssemblyName, string appAsmVersion, string appFileVersion, bool appWins, [CallerMemberName] string caller = "");

public class SharedTestState : ComponentSharedTestStateBase
{
Expand Down Expand Up @@ -99,7 +100,7 @@ public AppPerAssemblyVersionResolution(SharedTestState sharedState)
{
}

protected override void RunTest(string testAssemblyName, string appAsmVersion, string appFileVersion, bool appWins)
protected override void RunTest(string testAssemblyName, string appAsmVersion, string appFileVersion, bool appWins, [CallerMemberName] string caller = "")
{
var app = SharedState.CreateTestFrameworkReferenceApp(b => b
.WithPackage(TestVersionsPackage, "1.0.0", lib => lib
Expand All @@ -112,7 +113,7 @@ protected override void RunTest(string testAssemblyName, string appAsmVersion, s

SharedState.DotNetWithNetCoreApp.Exec(app.AppDll)
.EnableTracingAndCaptureOutputs()
.Execute()
.Execute(caller)
.Should().Pass()
.And.HaveResolvedAssembly(expectedTestAssemblyPath)
.And.HaveUsedFrameworkProbe(SharedState.DotNetWithNetCoreApp.GreatestVersionSharedFxPath, level: 1);
Expand All @@ -128,7 +129,7 @@ public AdditionalDepsPerAssemblyVersionResolution(SharedTestState sharedState)
{
}

protected override void RunTest(string testAssemblyName, string appAsmVersion, string appFileVersion, bool appWins)
protected override void RunTest(string testAssemblyName, string appAsmVersion, string appFileVersion, bool appWins, [CallerMemberName] string caller = "")
{
using (TestApp additionalDependency = TestApp.CreateEmpty("additionalDeps"))
{
Expand All @@ -151,7 +152,7 @@ protected override void RunTest(string testAssemblyName, string appAsmVersion, s
: Path.Combine(SharedState.DotNetWithNetCoreApp.GreatestVersionSharedFxPath, $"{testAssemblyName}.dll");
SharedState.DotNetWithNetCoreApp.Exec(Constants.AdditionalDeps.CommandLineArgument, additionalDependency.DepsJson, app.AppDll)
.EnableTracingAndCaptureOutputs()
.Execute()
.Execute(caller)
.Should().Pass()
.And.HaveUsedAdditionalDeps(additionalDependency.DepsJson)
.And.HaveResolvedAssembly(expectedTestAssemblyPath)
Expand All @@ -169,7 +170,7 @@ public ComponentPerAssemblyVersionResolution(SharedTestState sharedState)
{
}

protected override void RunTest(string testAssemblyName, string appAsmVersion, string appFileVersion, bool appWins)
protected override void RunTest(string testAssemblyName, string appAsmVersion, string appFileVersion, bool appWins, [CallerMemberName] string caller = "")
{
var component = SharedState.CreateComponentWithNoDependencies(b => b
.WithPackage(TestVersionsPackage, "1.0.0", lib => lib
Expand All @@ -180,7 +181,7 @@ protected override void RunTest(string testAssemblyName, string appAsmVersion, s
// For component dependency resolution, frameworks are not considered, so the assembly from the component always wins
string expectedTestAssemblyPath = Path.Combine(component.Location, testAssemblyName + ".dll");

SharedState.RunComponentResolutionTest(component)
SharedState.RunComponentResolutionTest(component, caller: caller)
.Should().Pass()
.And.HaveSuccessfullyResolvedComponentDependencies()
.And.HaveResolvedComponentDependencyAssembly($"{component.AppDll};{expectedTestAssemblyPath}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.IO;
using System.Runtime.CompilerServices;
using Xunit;

namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution
Expand Down Expand Up @@ -75,7 +76,7 @@ public void AppWithExactlySameAssemblyAsFrameworkWithRollForward(string framewor
TestAssemblyWithBothVersions, "2.1.1.1", "3.2.2.2", Constants.MicrosoftNETCoreApp);
}

protected abstract void RunTest(Action<RuntimeConfig> runtimeConfigCustomizer, string testAssemblyName, string appAsmVersion, string appFileVersion, string frameWorkWins);
protected abstract void RunTest(Action<RuntimeConfig> runtimeConfigCustomizer, string testAssemblyName, string appAsmVersion, string appFileVersion, string frameWorkWins, [CallerMemberName] string caller = "");

public class SharedTestState : ComponentSharedTestStateBase
{
Expand Down Expand Up @@ -135,7 +136,7 @@ public AppPerAssemblyVersionResolutionMultipleFrameworks(SharedTestState sharedS
{
}

protected override void RunTest(Action<RuntimeConfig> runtimeConfigCustomizer, string testAssemblyName, string appAsmVersion, string appFileVersion, string frameworkWins)
protected override void RunTest(Action<RuntimeConfig> runtimeConfigCustomizer, string testAssemblyName, string appAsmVersion, string appFileVersion, string frameworkWins, [CallerMemberName] string caller = "")
{
var app = SharedState.CreateTestFrameworkReferenceApp(b => b
.WithPackage(TestVersionsPackage, "1.0.0", lib => lib
Expand All @@ -159,7 +160,7 @@ protected override void RunTest(Action<RuntimeConfig> runtimeConfigCustomizer, s

SharedState.DotNetWithNetCoreApp.Exec(app.AppDll)
.EnableTracingAndCaptureOutputs()
.Execute()
.Execute(caller)
.Should().Pass()
.And.HaveResolvedAssembly(expectedTestAssemblyPath)
.And.HaveUsedFrameworkProbe(SharedState.HighWarePath, level: 1)
Expand All @@ -176,7 +177,7 @@ public ComponentPerAssemblyVersionResolutionMultipleFrameworks(SharedTestState s
{
}

protected override void RunTest(Action<RuntimeConfig> runtimeConfigCustomizer, string testAssemblyName, string appAsmVersion, string appFileVersion, string frameworkWins)
protected override void RunTest(Action<RuntimeConfig> runtimeConfigCustomizer, string testAssemblyName, string appAsmVersion, string appFileVersion, string frameworkWins, [CallerMemberName] string caller = "")
{
var component = SharedState.CreateComponentWithNoDependencies(b => b
.WithPackage(TestVersionsPackage, "1.0.0", lib => lib
Expand All @@ -193,7 +194,7 @@ protected override void RunTest(Action<RuntimeConfig> runtimeConfigCustomizer, s
// For component dependency resolution, frameworks are not considered, so the assembly from the component always wins
string expectedTestAssemblyPath = Path.Combine(component.Location, testAssemblyName + ".dll");

SharedState.RunComponentResolutionTest(component)
SharedState.RunComponentResolutionTest(component, caller: caller)
.Should().Pass()
.And.HaveSuccessfullyResolvedComponentDependencies()
.And.HaveResolvedComponentDependencyAssembly($"{component.AppDll};{expectedTestAssemblyPath}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using Microsoft.DotNet.Cli.Build;
using Microsoft.Extensions.DependencyModel;
using Xunit;
Expand Down Expand Up @@ -69,7 +70,8 @@ protected abstract void RunTest(
Action<NetCoreAppBuilder.RuntimeLibraryBuilder> assetsCustomizer,
TestSetup setup,
ResolvedPaths expected,
Action<NetCoreAppBuilder> appCustomizer = null);
Action<NetCoreAppBuilder> appCustomizer = null,
[CallerMemberName] string caller = "");

protected TestApp UpdateAppConfigForTest(TestApp app, TestSetup setup, bool copyOnUpdate)
{
Expand Down Expand Up @@ -649,7 +651,8 @@ protected override void RunTest(
Action<NetCoreAppBuilder.RuntimeLibraryBuilder> assetsCustomizer,
TestSetup setup,
ResolvedPaths expected,
Action<NetCoreAppBuilder> appCustomizer)
Action<NetCoreAppBuilder> appCustomizer,
[CallerMemberName] string caller = "")
{
using (TestApp app = NetCoreAppBuilder.PortableForNETCoreApp(SharedState.FrameworkReferenceApp)
.WithProject(p => { p.WithAssemblyGroup(null, g => g.WithMainAssembly()); assetsCustomizer?.Invoke(p); })
Expand All @@ -672,7 +675,7 @@ protected override void RunTest(
var result = dotnet.Exec(app.AppDll)
.EnableTracingAndCaptureOutputs()
.RuntimeId(setup.Rid)
.Execute();
.Execute(caller);
result.Should().Pass()
.And.HaveResolvedAssembly(expected.IncludedAssemblyPaths, app)
.And.NotHaveResolvedAssembly(expected.ExcludedAssemblyPaths, app)
Expand Down Expand Up @@ -703,7 +706,8 @@ protected override void RunTest(
Action<NetCoreAppBuilder.RuntimeLibraryBuilder> assetsCustomizer,
TestSetup setup,
ResolvedPaths expected,
Action<NetCoreAppBuilder> appCustomizer)
Action<NetCoreAppBuilder> appCustomizer,
[CallerMemberName] string caller = "")
{
var component = SharedState.CreateComponentWithNoDependencies(b => b
.WithPackage("NativeDependency", "1.0.0", p => assetsCustomizer?.Invoke(p))
Expand All @@ -722,8 +726,12 @@ protected override void RunTest(

TestApp app = UpdateAppConfigForTest(SharedState.FrameworkReferenceApp, setup, copyOnUpdate: true);

var result = SharedState.RunComponentResolutionTest(component.AppDll, app, dotnet.GreatestVersionHostFxrPath, command => command
.RuntimeId(setup.Rid));
var result = SharedState.RunComponentResolutionTest(
component.AppDll,
app,
dotnet.GreatestVersionHostFxrPath,
command => command.RuntimeId(setup.Rid),
caller: caller);
result.Should().Pass()
.And.HaveSuccessfullyResolvedComponentDependencies()
.And.HaveResolvedComponentDependencyAssembly(expected.IncludedAssemblyPaths, component)
Expand Down Expand Up @@ -754,7 +762,8 @@ protected override void RunTest(
Action<NetCoreAppBuilder.RuntimeLibraryBuilder> assetsCustomizer,
TestSetup setup,
ResolvedPaths expected,
Action<NetCoreAppBuilder> appCustomizer)
Action<NetCoreAppBuilder> appCustomizer,
[CallerMemberName] string caller = "")
{
var component = SharedState.CreateComponentWithNoDependencies(b => b
.WithPackage("NativeDependency", "1.0.0", p => assetsCustomizer?.Invoke(p))
Expand All @@ -773,8 +782,12 @@ protected override void RunTest(

app = UpdateAppConfigForTest(app, setup, copyOnUpdate: true);

var result = SharedState.RunComponentResolutionTest(component.AppDll, app, app.Location, command => command
.RuntimeId(setup.Rid));
var result = SharedState.RunComponentResolutionTest(
component.AppDll,
app,
app.Location,
command => command.RuntimeId(setup.Rid),
caller: caller);
result.Should().Pass()
.And.HaveSuccessfullyResolvedComponentDependencies()
.And.HaveResolvedComponentDependencyAssembly(expected.IncludedAssemblyPaths, component)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void Muxer_NonAssemblyWithExeExtension()
TestContext.BuiltDotNet.Exec(appExe)
.CaptureStdOut()
.CaptureStdErr()
.Execute()
.Execute(expectedToFail: true)
.Should().Fail()
.And.HaveStdErrContaining("BadImageFormatException");
}
Expand Down Expand Up @@ -439,7 +439,7 @@ public void AppHost_GUI_MissingRuntimeFramework_ErrorReportedInDialog()
command.Process.Kill();

string expectedMissingFramework = $"'{Constants.MicrosoftNETCoreApp}', version '{TestContext.MicrosoftNETCoreAppVersion}' ({TestContext.BuildArchitecture})";
var result = command.WaitForExit(true)
var result = command.WaitForExit()
.Should().Fail()
.And.HaveStdErrContaining($"Showing error dialog for application: '{Path.GetFileName(appExe)}' - error code: 0x{expectedErrorCode}")
.And.HaveStdErrContaining($"url: 'https://aka.ms/dotnet-core-applaunch?{expectedUrlQuery}")
Expand Down Expand Up @@ -469,7 +469,7 @@ public void AppHost_GUI_MissingRuntime_ErrorReportedInDialog()
command.Process.Kill();

var expectedErrorCode = Constants.ErrorCode.CoreHostLibMissingFailure.ToString("x");
var result = command.WaitForExit(true)
var result = command.WaitForExit()
.Should().Fail()
.And.HaveStdErrContaining($"Showing error dialog for application: '{Path.GetFileName(appExe)}' - error code: 0x{expectedErrorCode}")
.And.HaveStdErrContaining($"url: 'https://aka.ms/dotnet-core-applaunch?missing_runtime=true")
Expand Down Expand Up @@ -504,7 +504,7 @@ public void AppHost_GUI_NoCustomErrorWriter_FrameworkMissing_ErrorReportedInDial
command.Process.Kill();

string expectedErrorCode = Constants.ErrorCode.FrameworkMissingFailure.ToString("x");
command.WaitForExit(true)
command.WaitForExit()
.Should().Fail()
.And.HaveStdErrContaining($"Showing error dialog for application: '{Path.GetFileName(appExe)}' - error code: 0x{expectedErrorCode}")
.And.HaveStdErrContaining("You must install or update .NET to run this application.")
Expand Down
Loading
Loading