Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor --arch switch for arm64 on Windows and Mac #3100

Merged
merged 44 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3ebcdaa
add first version of muxer finder
MarcoRossignoli Oct 11, 2021
792b981
add X64 force scenarios
MarcoRossignoli Oct 11, 2021
e3047e2
refactor DotnetHostHelper
MarcoRossignoli Oct 12, 2021
fb54a0e
add validation matrix
MarcoRossignoli Oct 13, 2021
735569b
move internal helper to internal visibility
MarcoRossignoli Oct 13, 2021
fa12d56
force to x64 only if user doesn't specify nothing, refactor arch/fx m…
MarcoRossignoli Oct 13, 2021
e4e9958
make RunsettingsHelper testable
MarcoRossignoli Oct 13, 2021
47da915
temporary fix issue with ARM64 metadata detection, add architecture i…
MarcoRossignoli Oct 13, 2021
6c09164
address PR feedback
MarcoRossignoli Oct 13, 2021
eebc3c1
fix architecture infer for asm, add Mac-O reader, update dotnet host …
MarcoRossignoli Oct 14, 2021
5cd221b
keep back compat in assembly metadata provider
MarcoRossignoli Oct 14, 2021
9fabfee
refactor dotnet host helper, improve error notification
MarcoRossignoli Oct 14, 2021
3da05df
use invariant culture api
MarcoRossignoli Oct 14, 2021
9090dcf
first part of update for win arm, run always with dotnet muxer and av…
MarcoRossignoli Oct 15, 2021
2dcbd9f
remove testhost.dll override from package for x64, refactor searching…
MarcoRossignoli Oct 18, 2021
df68b83
skip apphost host on arm/win, flow new sdk VSTEST_WINAPPHOST_ to app …
MarcoRossignoli Oct 19, 2021
16f3457
add VSTEST_TMP_SWITCH_DOTNETROOTS_ENVVARS env var for manual testability
MarcoRossignoli Oct 20, 2021
412d0b3
fix PlatformArgumentProcessorTests UTs
MarcoRossignoli Oct 20, 2021
b7275e1
fix unix build
MarcoRossignoli Oct 20, 2021
459f93b
use AnyCPU version of testhost.dll in case of x64
MarcoRossignoli Oct 21, 2021
b3fc02c
remove arch/framework check and let test fail
MarcoRossignoli Oct 21, 2021
0001463
move acceptance RunMultipleTestAssembliesInParallel to win only
MarcoRossignoli Oct 21, 2021
73dc606
fix comment typo
MarcoRossignoli Oct 21, 2021
056e239
Update message for muxer not found
MarcoRossignoli Oct 22, 2021
097198e
Improve error message in case of x64 forcing.
MarcoRossignoli Oct 24, 2021
e13896f
address Vitek feedback, refactor host manager
MarcoRossignoli Oct 25, 2021
704266e
nit cleanup
MarcoRossignoli Oct 25, 2021
0e007d0
address PR feedback
MarcoRossignoli Oct 25, 2021
0ec501e
return current running muxer if SDK and target architecture are the same
MarcoRossignoli Oct 25, 2021
52e120e
Improve logging
MarcoRossignoli Oct 25, 2021
47e268a
add UTs DotnetHostHelper env vars
MarcoRossignoli Oct 25, 2021
9d7976a
Add UTs for windows global registraton
MarcoRossignoli Oct 25, 2021
9d363b8
complete DotnetHostHelper UTs
MarcoRossignoli Oct 26, 2021
72a178a
Improve DotnetHostHelper UTs
MarcoRossignoli Oct 26, 2021
35dbef9
Run GetDotnetPathByArchitecture_DefaultInstallation_Win only on win d…
MarcoRossignoli Oct 26, 2021
8e048e8
Add UTs for apphost DOTNET_ROOTS forwarding
MarcoRossignoli Oct 26, 2021
a48edc2
Cleanup
MarcoRossignoli Oct 26, 2021
cbc247d
Apply suggestions from code review
MarcoRossignoli Oct 27, 2021
73b2a23
address Jakub feedback
MarcoRossignoli Oct 27, 2021
bcf4bbf
fix UTs
MarcoRossignoli Oct 27, 2021
37bfa5e
revert platform BC
MarcoRossignoli Oct 27, 2021
041b1f2
revert public api BC
MarcoRossignoli Oct 27, 2021
4d1c3e0
restore InitializeShouldNotConsiderCaseSensitivityOfTheArgumentPassed UT
MarcoRossignoli Oct 27, 2021
dea3414
fix documentation
MarcoRossignoli Oct 27, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ internal class DotnetHostHelper : IDotnetHostHelper
private readonly IEnvironment environment;
private readonly IWindowsRegistryHelper windowsRegistryHelper;
private readonly IEnvironmentVariableHelper environmentVariableHelper;
private readonly IProcessHelper processHelper;
private readonly string muxerName;

/// <summary>
/// Initializes a new instance of the <see cref="DotnetHostHelper"/> class.
/// </summary>
public DotnetHostHelper() : this(new FileHelper(), new PlatformEnvironment(), new WindowsRegistryHelper(), new EnvironmentVariableHelper())
public DotnetHostHelper() : this(new FileHelper(), new PlatformEnvironment(), new WindowsRegistryHelper(), new EnvironmentVariableHelper(), new ProcessHelper())
{
}

Expand All @@ -43,12 +44,14 @@ public DotnetHostHelper(
IFileHelper fileHelper,
IEnvironment environment,
IWindowsRegistryHelper windowsRegistryHelper,
IEnvironmentVariableHelper environmentVariableHelper)
IEnvironmentVariableHelper environmentVariableHelper,
IProcessHelper processHelper)
{
this.fileHelper = fileHelper;
this.environment = environment;
this.windowsRegistryHelper = windowsRegistryHelper;
this.environmentVariableHelper = environmentVariableHelper;
this.processHelper = processHelper;
this.muxerName = $"dotnet{(environment.OperatingSystem == PlatformOperatingSystem.Windows ? ".exe" : "")}";
}

Expand Down Expand Up @@ -103,6 +106,21 @@ private bool TryGetExecutablePath(string executableBaseName, out string executab

public bool TryGetDotnetPathByArchitecture(PlatformArchitecture targetArchitecture, out string muxerPath)
{
if (this.environment.Architecture == targetArchitecture)
{
string currentProcessFileName = this.processHelper.GetCurrentProcessFileName();
if (Path.GetFileName(currentProcessFileName) != this.muxerName)
{
EqtTrace.Verbose($"DotnetHostHelper: Target architecture same as current process architecture but muxer is not a valid one, '{currentProcessFileName}'");
}
else
{
muxerPath = currentProcessFileName;
EqtTrace.Verbose($"DotnetHostHelper: Target architecture same as current process architecture, muxer resolved using current process path '{muxerPath}'");
return true;
}
}

// We used similar approach as the runtime resolver.
// https://github.com/dotnet/runtime/blob/main/src/native/corehost/fxr_resolver.cpp#L55

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ public void GetDotnetPathByArchitecture_EnvVars(PlatformArchitecture targetArchi
{
string expectedMuxerLocation = platformSystem == PlatformOperatingSystem.OSX ? "/tmp/dotnet" : @"c:\dotnet.exe";
Mock<IFileHelper> fileHelper = new Mock<IFileHelper>();
Mock<IProcessHelper> processHelper = new Mock<IProcessHelper>();
Mock<IEnvironment> environmentHelper = new Mock<IEnvironment>();
environmentHelper.SetupGet(x => x.Architecture).Returns(platformArchitecture);
environmentHelper.SetupGet(x => x.OperatingSystem).Returns(platformSystem);
Mock<IWindowsRegistryHelper> windowsRegistrytHelper = new Mock<IWindowsRegistryHelper>();
Mock<IEnvironmentVariableHelper> environmentVariableHelper = new Mock<IEnvironmentVariableHelper>();
environmentVariableHelper.Setup(x => x.GetEnvironmentVariable(envVar)).Returns(expectedMuxerLocation);

var dotnetHostHelper = new DotnetHostHelper(fileHelper.Object, environmentHelper.Object, windowsRegistrytHelper.Object, environmentVariableHelper.Object);
var dotnetHostHelper = new DotnetHostHelper(fileHelper.Object, environmentHelper.Object, windowsRegistrytHelper.Object, environmentVariableHelper.Object, processHelper.Object);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace TestPlatform.CrossPlatEngine.UnitTests.Client
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources;
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers;
Expand All @@ -24,12 +23,10 @@ namespace TestPlatform.CrossPlatEngine.UnitTests.Client
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host;
using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Moq;
using Constants = Microsoft.VisualStudio.TestPlatform.CoreUtilities.Constants;

[TestClass]
public class ProxyOperationManagerTests : ProxyBaseManagerTests
Expand Down Expand Up @@ -546,7 +543,7 @@ public TestableDotnetTestHostManager(
IEnvironmentVariableHelper environmentVariableHelper) : base(
processHelper,
fileHelper,
new DotnetHostHelper(fileHelper, environment, new WindowsRegistryHelper(), new EnvironmentVariableHelper()),
new DotnetHostHelper(fileHelper, environment, windowsRegistryHelper, environmentVariableHelper, processHelper),
environment,
runsettingHelper,
windowsRegistryHelper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace TestPlatform.TestHostProvider.UnitTests.Hosting
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -88,7 +87,7 @@ public DotnetTestHostManagerTests()
this.dotnetHostManager = new TestableDotnetTestHostManager(
this.mockProcessHelper.Object,
this.mockFileHelper.Object,
new DotnetHostHelper(this.mockFileHelper.Object, this.mockEnvironment.Object, this.mockWindowsRegistry.Object, this.mockEnvironmentVariable.Object),
new DotnetHostHelper(this.mockFileHelper.Object, this.mockEnvironment.Object, this.mockWindowsRegistry.Object, this.mockEnvironmentVariable.Object, this.mockProcessHelper.Object),
this.mockEnvironment.Object,
this.mockRunsettingHelper.Object,
this.mockWindowsRegistry.Object,
Expand Down