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

Debugging tests with a native debugger requires --InIsolation flag #10393

Closed
ocitrev opened this issue Oct 18, 2024 · 1 comment · Fixed by #10401
Closed

Debugging tests with a native debugger requires --InIsolation flag #10393

ocitrev opened this issue Oct 18, 2024 · 1 comment · Fixed by #10401

Comments

@ocitrev
Copy link
Contributor

ocitrev commented Oct 18, 2024

With environment variable VSTEST_HOST_NATIVE_DEBUG, we can use a native debugger to debug tests but it requires --InIsolation flag.
When using the argument --tests: to run a specific test, testhost.exe is spawned twice and we must attach twice to properly debug.

When the environment variable VSTEST_RUNNER_DEBUG is set, vstest.console only waits for a managed debugger.

I propose to add new environment variable VSTEST_RUNNER_NATIVE_DEBUG to enable native debugging of vstest.conssole.
This will enable native debugging of tests without the --InIsolation flag.

The proposed code changes

diff --git a/src/vstest.console/CommandLine/Executor.cs b/src/vstest.console/CommandLine/Executor.cs
index 951a4166..a153dd49 100644
--- a/src/vstest.console/CommandLine/Executor.cs
+++ b/src/vstest.console/CommandLine/Executor.cs
@@ -91,6 +91,7 @@ internal class Executor
     internal Executor(IOutput output, ITestPlatformEventSource testPlatformEventSource, IProcessHelper processHelper, IEnvironment environment)
     {
         DebuggerBreakpoint.AttachVisualStudioDebugger(WellKnownDebugEnvironmentVariables.VSTEST_RUNNER_DEBUG_ATTACHVS);
+        DebuggerBreakpoint.WaitForNativeDebugger(WellKnownDebugEnvironmentVariables.VSTEST_RUNNER_NATIVE_DEBUG);
         DebuggerBreakpoint.WaitForDebugger(WellKnownDebugEnvironmentVariables.VSTEST_RUNNER_DEBUG);
 
         Output = output;
diff --git a/src/Microsoft.TestPlatform.Execution.Shared/WellKnownDebugEnvironmentVariables.cs b/src/Microsoft.TestPlatform.Execution.Shared/WellKnownDebugEnvironmentVariables.cs
index 83402bce..61fe4fa0 100644
--- a/src/Microsoft.TestPlatform.Execution.Shared/WellKnownDebugEnvironmentVariables.cs
+++ b/src/Microsoft.TestPlatform.Execution.Shared/WellKnownDebugEnvironmentVariables.cs
@@ -13,4 +13,5 @@ internal static class WellKnownDebugEnvironmentVariables
     public const string VSTEST_HOST_DEBUG_ATTACHVS = nameof(VSTEST_HOST_DEBUG_ATTACHVS);
     public const string VSTEST_RUNNER_DEBUG_ATTACHVS = nameof(VSTEST_RUNNER_DEBUG_ATTACHVS);
     public const string VSTEST_HOST_NATIVE_DEBUG = nameof(VSTEST_HOST_NATIVE_DEBUG);
+    public const string VSTEST_RUNNER_NATIVE_DEBUG = nameof(VSTEST_RUNNER_NATIVE_DEBUG);
 }
@nohwnd
Copy link
Member

nohwnd commented Oct 21, 2024

Sure, please go ahead and make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants