mirror of
https://github.com/BepInEx/dotnet-runtime.git
synced 2026-11-24 18:28:38 -10:00
Explicitly set DOTNET_MULTILEVEL_LOOKUP in tests (dotnet/core-setup#7541)
Commit migrated from https://github.com/dotnet/core-setup/commit/9b9814cc595dce09a126186d5926b1b19e8a09f3
This commit is contained in:
1 parent
9aebd3763a
commit
f63be0d091
11 files changed
+73
-95
No files matched your search
@@ -36,6 +36,18 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
|
||||
.CaptureStdErr();
|
||||
}
|
||||
|
||||
public static Command DotNetRoot(this Command command, string dotNetRoot)
|
||||
{
|
||||
return command
|
||||
.EnvironmentVariable("DOTNET_ROOT", dotNetRoot)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", dotNetRoot);
|
||||
}
|
||||
|
||||
public static Command MultilevelLookup(this Command command, bool enable)
|
||||
{
|
||||
return command.EnvironmentVariable(Constants.MultilevelLookup.EnvironmentVariable, enable ? "1" : "0");
|
||||
}
|
||||
|
||||
public static Command RuntimeId(this Command command, string rid)
|
||||
{
|
||||
return command.EnvironmentVariable(Constants.RuntimeId.EnvironmentVariable, rid);
|
||||
|
||||
+3
-1
@@ -60,7 +60,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution
|
||||
};
|
||||
|
||||
Command command = Command.Create(NativeHostPath, args)
|
||||
.EnableTracingAndCaptureOutputs();
|
||||
.EnableTracingAndCaptureOutputs()
|
||||
.MultilevelLookup(false);
|
||||
commandCustomizer?.Invoke(command);
|
||||
|
||||
return command.Execute()
|
||||
@@ -86,6 +87,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution
|
||||
|
||||
return Command.Create(NativeHostPath, args)
|
||||
.EnableTracingAndCaptureOutputs()
|
||||
.MultilevelLookup(false)
|
||||
.Execute();
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -46,11 +46,9 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution
|
||||
}
|
||||
|
||||
CommandResult result = command
|
||||
.EnvironmentVariable("COREHOST_TRACE", "1")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", multiLevelLookup ? "1" : "0")
|
||||
.EnableTracingAndCaptureOutputs()
|
||||
.MultilevelLookup(multiLevelLookup)
|
||||
.Environment(settings.Environment)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute();
|
||||
|
||||
resultAction?.Invoke(result);
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
|
||||
DotNet.Exec("--roll-forward-on-no-candidate-fx", "2", appDll, "argumentOne", "arg2")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.MultilevelLookup(false)
|
||||
.Execute()
|
||||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("mock coreclr_initialize() called")
|
||||
|
||||
@@ -31,12 +31,14 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
return;
|
||||
}
|
||||
|
||||
string scenario = synchronous ? "synchronous" : "concurrent";
|
||||
string args = $"comhost {scenario} {count} {sharedState.ComHostPath} {sharedState.ClsidString}";
|
||||
CommandResult result = Command.Create(sharedState.NativeHostPath, args)
|
||||
.EnableTracingAndCaptureOutputs()
|
||||
.EnvironmentVariable("DOTNET_ROOT", sharedState.ComLibraryFixture.BuiltDotnet.BinPath)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.ComLibraryFixture.BuiltDotnet.BinPath)
|
||||
string [] args = {
|
||||
"comhost",
|
||||
synchronous ? "synchronous" : "concurrent",
|
||||
$"{count}",
|
||||
sharedState.ComHostPath,
|
||||
sharedState.ClsidString
|
||||
};
|
||||
CommandResult result = sharedState.CreateNativeHostCommand(args, sharedState.ComLibraryFixture.BuiltDotnet.BinPath)
|
||||
.Execute();
|
||||
|
||||
result.Should().Pass()
|
||||
@@ -64,11 +66,14 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
fixture.TestProject.BuiltApp.Location,
|
||||
$"{ fixture.TestProject.AssemblyName }.comhost.dll");
|
||||
|
||||
string args = $"comhost synchronous 1 {comHostWithAppLocalFxr} {sharedState.ClsidString}";
|
||||
CommandResult result = Command.Create(sharedState.NativeHostPath, args)
|
||||
.EnableTracingAndCaptureOutputs()
|
||||
.EnvironmentVariable("DOTNET_ROOT", fixture.BuiltDotnet.BinPath)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", fixture.BuiltDotnet.BinPath)
|
||||
string[] args = {
|
||||
"comhost",
|
||||
"synchronous",
|
||||
"1",
|
||||
comHostWithAppLocalFxr,
|
||||
sharedState.ClsidString
|
||||
};
|
||||
CommandResult result = sharedState.CreateNativeHostCommand(args, fixture.BuiltDotnet.BinPath)
|
||||
.Execute();
|
||||
|
||||
result.Should().Pass()
|
||||
@@ -98,11 +103,14 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
fixture.TestProject.BuiltApp.Location,
|
||||
$"{ fixture.TestProject.AssemblyName }.comhost.dll");
|
||||
|
||||
string args = $"comhost errorinfo 1 {comHost} {sharedState.ClsidString}";
|
||||
CommandResult result = Command.Create(sharedState.NativeHostPath, args)
|
||||
.EnableTracingAndCaptureOutputs()
|
||||
.EnvironmentVariable("DOTNET_ROOT", fixture.BuiltDotnet.BinPath)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", fixture.BuiltDotnet.BinPath)
|
||||
string[] args = {
|
||||
"comhost",
|
||||
"errorinfo",
|
||||
"1",
|
||||
comHost,
|
||||
sharedState.ClsidString
|
||||
};
|
||||
CommandResult result = sharedState.CreateNativeHostCommand(args, fixture.BuiltDotnet.BinPath)
|
||||
.Execute();
|
||||
|
||||
result.Should().Pass()
|
||||
|
||||
@@ -38,12 +38,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
validType ? sharedState.ComponentTypeName : $"Component.BadType, {componentProject.AssemblyName}",
|
||||
validMethod ? sharedState.ComponentEntryPoint1 : "BadMethod",
|
||||
};
|
||||
CommandResult result = Command.Create(sharedState.NativeHostPath, args)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.EnvironmentVariable("COREHOST_TRACE", "1")
|
||||
.EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
|
||||
CommandResult result = sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
|
||||
.Execute();
|
||||
|
||||
result.Should()
|
||||
@@ -90,12 +85,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
args = args.Concat(componentInfo);
|
||||
}
|
||||
|
||||
CommandResult result = Command.Create(sharedState.NativeHostPath, args)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.EnvironmentVariable("COREHOST_TRACE", "1")
|
||||
.EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
|
||||
CommandResult result = sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
|
||||
.Execute();
|
||||
|
||||
result.Should().Pass()
|
||||
@@ -139,12 +129,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
args = args.Concat(componentInfo);
|
||||
}
|
||||
|
||||
CommandResult result = Command.Create(sharedState.NativeHostPath, args)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.EnvironmentVariable("COREHOST_TRACE", "1")
|
||||
.EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
|
||||
CommandResult result = sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
|
||||
.Execute();
|
||||
|
||||
result.Should().Pass()
|
||||
|
||||
@@ -138,12 +138,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
SharedTestState.AppPropertyName,
|
||||
newPropertyName
|
||||
};
|
||||
CommandResult result = Command.Create(sharedState.NativeHostPath, args.Concat(commandArgs).Concat(appArgs))
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.EnvironmentVariable("COREHOST_TRACE", "1")
|
||||
.EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
|
||||
CommandResult result = sharedState.CreateNativeHostCommand(args.Concat(commandArgs).Concat(appArgs), sharedState.DotNetRoot)
|
||||
.Execute();
|
||||
|
||||
result.Should().Pass()
|
||||
@@ -176,12 +171,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
SharedTestState.ConfigPropertyName,
|
||||
newPropertyName
|
||||
};
|
||||
CommandResult result = Command.Create(sharedState.NativeHostPath, args)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.EnvironmentVariable("COREHOST_TRACE", "1")
|
||||
.EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
|
||||
CommandResult result = sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
|
||||
.Execute();
|
||||
|
||||
result.Should().Pass()
|
||||
@@ -203,12 +193,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
sharedState.SelfContainedHostFxrPath,
|
||||
sharedState.SelfContainedConfigPath
|
||||
};
|
||||
CommandResult result = Command.Create(sharedState.NativeHostPath, args)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.EnvironmentVariable("COREHOST_TRACE", "1")
|
||||
.EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
|
||||
CommandResult result = sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
|
||||
.Execute();
|
||||
|
||||
result.Should().Fail()
|
||||
@@ -236,12 +221,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
SharedTestState.ConfigPropertyName,
|
||||
SharedTestState.SecondaryConfigPropertyName
|
||||
};
|
||||
CommandResult result = Command.Create(sharedState.NativeHostPath, args)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.EnvironmentVariable("COREHOST_TRACE", "1")
|
||||
.EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
|
||||
CommandResult result = sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
|
||||
.Execute();
|
||||
|
||||
result.Should().Pass()
|
||||
@@ -289,13 +269,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
SharedTestState.AppPropertyName,
|
||||
SharedTestState.ConfigPropertyName
|
||||
};
|
||||
CommandResult result = Command.Create(sharedState.NativeHostPath, args.Concat(appArgs))
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.EnvironmentVariable("COREHOST_TRACE", "1")
|
||||
CommandResult result = sharedState.CreateNativeHostCommand(args.Concat(appArgs), sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("COREHOST_TRACE_VERBOSITY", "3")
|
||||
.EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("TEST_BLOCK_MOCK_EXECUTE_ASSEMBLY", $"{sharedState.AppPath}.block")
|
||||
.EnvironmentVariable("TEST_SIGNAL_MOCK_EXECUTE_ASSEMBLY", $"{sharedState.AppPath}.signal")
|
||||
.Execute();
|
||||
@@ -380,13 +355,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
CommandResult result;
|
||||
try
|
||||
{
|
||||
result = Command.Create(sharedState.NativeHostPath, args)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.EnvironmentVariable("COREHOST_TRACE", "1")
|
||||
result = sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("COREHOST_TRACE_VERBOSITY", "3")
|
||||
.EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("TEST_BLOCK_MOCK_EXECUTE_ASSEMBLY", $"{sharedState.AppPath}.block")
|
||||
.EnvironmentVariable("TEST_SIGNAL_MOCK_EXECUTE_ASSEMBLY", $"{sharedState.AppPath}.signal")
|
||||
.Execute();
|
||||
@@ -476,13 +446,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
CommandResult result;
|
||||
try
|
||||
{
|
||||
result = Command.Create(sharedState.NativeHostPath, args)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.EnvironmentVariable("COREHOST_TRACE", "1")
|
||||
result = sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("COREHOST_TRACE_VERBOSITY", "3")
|
||||
.EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
|
||||
.EnvironmentVariable("TEST_BLOCK_MOCK_EXECUTE_ASSEMBLY", $"{sharedState.AppPath}.block")
|
||||
.EnvironmentVariable("TEST_SIGNAL_MOCK_EXECUTE_ASSEMBLY", $"{sharedState.AppPath}.signal")
|
||||
.Execute();
|
||||
|
||||
@@ -35,8 +35,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
string dotNetRoot = isValid ? Path.Combine(sharedState.ValidInstallRoot, "dotnet") : sharedState.InvalidInstallRoot;
|
||||
CommandResult result = Command.Create(sharedState.NativeHostPath, $"{GetHostFxrPath} {explicitLoad} {(useAssemblyPath ? sharedState.TestAssemblyPath : string.Empty)}")
|
||||
.EnableTracingAndCaptureOutputs()
|
||||
.EnvironmentVariable("DOTNET_ROOT", dotNetRoot)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", dotNetRoot)
|
||||
.DotNetRoot(dotNetRoot)
|
||||
.Execute();
|
||||
|
||||
result.Should().HaveStdErrContaining("Using environment variable");
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
@@ -37,6 +39,14 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
|
||||
NethostPath);
|
||||
}
|
||||
|
||||
public Command CreateNativeHostCommand(IEnumerable<string> args, string dotNetRoot)
|
||||
{
|
||||
return Command.Create(NativeHostPath, args)
|
||||
.EnableTracingAndCaptureOutputs()
|
||||
.DotNetRoot(dotNetRoot)
|
||||
.MultilevelLookup(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
||||
@@ -150,10 +150,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
|
||||
"exec",
|
||||
"--additionalprobingpath", additionalProbingPath,
|
||||
appDll)
|
||||
.EnvironmentVariable("COREHOST_TRACE", "1")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.EnableTracingAndCaptureOutputs()
|
||||
.Execute()
|
||||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("Hello World")
|
||||
@@ -279,8 +276,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
|
||||
Command.Create(appExe)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.EnvironmentVariable("DOTNET_ROOT", builtDotnet)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", builtDotnet)
|
||||
.DotNetRoot(builtDotnet)
|
||||
.MultilevelLookup(false)
|
||||
.Execute()
|
||||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("Hello World")
|
||||
@@ -290,8 +287,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
|
||||
// Verify running from within the working directory
|
||||
Command.Create(appExe)
|
||||
.WorkingDirectory(fixture.TestProject.OutputDirectory)
|
||||
.EnvironmentVariable("DOTNET_ROOT", builtDotnet)
|
||||
.EnvironmentVariable("DOTNET_ROOT(x86)", builtDotnet)
|
||||
.DotNetRoot(builtDotnet)
|
||||
.MultilevelLookup(false)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.Execute()
|
||||
@@ -347,6 +344,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
|
||||
Command.Create(appExe)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.MultilevelLookup(false)
|
||||
.ApplyRegisteredInstallLocationOverride(registeredInstallLocationOverride)
|
||||
.EnvironmentVariable(Constants.TestOnlyEnvironmentVariables.DefaultInstallPath, useRegisteredLocation ? null : builtDotnet)
|
||||
.Execute()
|
||||
@@ -358,6 +356,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
|
||||
Command.Create(appExe)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.MultilevelLookup(false)
|
||||
.WorkingDirectory(fixture.TestProject.OutputDirectory)
|
||||
.ApplyRegisteredInstallLocationOverride(registeredInstallLocationOverride)
|
||||
.EnvironmentVariable(Constants.TestOnlyEnvironmentVariables.DefaultInstallPath, useRegisteredLocation ? null : builtDotnet)
|
||||
@@ -378,9 +377,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
|
||||
var appDll = fixture.TestProject.AppDll;
|
||||
|
||||
dotnet.Exec(appDll)
|
||||
.EnvironmentVariable("COREHOST_TRACE", "1")
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.EnableTracingAndCaptureOutputs()
|
||||
.Execute()
|
||||
.Should().Pass()
|
||||
.And.HaveStdErrMatching($"Property TRUSTED_PLATFORM_ASSEMBLIES = .*[^{Path.PathSeparator}]$", System.Text.RegularExpressions.RegexOptions.Multiline);
|
||||
|
||||
@@ -67,7 +67,8 @@ namespace Microsoft.DotNet.Cli.Build
|
||||
}
|
||||
|
||||
return Command.Create(DotnetExecutablePath, newArgs)
|
||||
.EnvironmentVariable("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", "1");
|
||||
.EnvironmentVariable("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", "1")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0"); // Avoid looking at machine state by default
|
||||
}
|
||||
|
||||
public Command Restore(params string[] args) => Exec("restore", args);
|
||||
|
||||
Reference in new issue
Block a user