From 8e3f96c9ce0bdb1561031bb145d614b0a2ae70f9 Mon Sep 17 00:00:00 2001 From: Brian Dong Date: Mon, 2 Dec 2024 14:21:41 -0700 Subject: [PATCH] Patch plugin to use local execution by default for test debugging --- base/src/com/google/idea/blaze/base/command/BlazeFlags.java | 3 +++ .../google/idea/blaze/java/run/BlazeJavaRunProfileState.java | 1 + .../idea/blaze/java/run/BlazeJavaRunProfileStateTest.java | 2 ++ 3 files changed, 6 insertions(+) diff --git a/base/src/com/google/idea/blaze/base/command/BlazeFlags.java b/base/src/com/google/idea/blaze/base/command/BlazeFlags.java index b45ef6a74b6..e92aaee3d85 100644 --- a/base/src/com/google/idea/blaze/base/command/BlazeFlags.java +++ b/base/src/com/google/idea/blaze/base/command/BlazeFlags.java @@ -39,6 +39,9 @@ public final class BlazeFlags { // It expands to: --test_arg=--wrapper_script_flag=--debug --test_output=streamed // --test_strategy=exclusive --test_timeout=9999 --nocache_test_results public static final String JAVA_TEST_DEBUG = "--java_debug"; + // Debugging tests should only run locally, so make sure no remote executor is defined + // while debugging tests + public static final String RUN_LOCALLY = "--remote_executor="; // Streams stdout/stderr output from each test in real-time. // Implies --test_strategy=exclusive and --test_sharding_strategy=disabled public static final String TEST_OUTPUT_STREAMED = "--test_output=streamed"; diff --git a/java/src/com/google/idea/blaze/java/run/BlazeJavaRunProfileState.java b/java/src/com/google/idea/blaze/java/run/BlazeJavaRunProfileState.java index 7ced8164183..2d471d03813 100644 --- a/java/src/com/google/idea/blaze/java/run/BlazeJavaRunProfileState.java +++ b/java/src/com/google/idea/blaze/java/run/BlazeJavaRunProfileState.java @@ -272,6 +272,7 @@ static BlazeCommand.Builder getBlazeCommandBuilder( command.addExeFlags(debugPortFlag(false, debugPort)); } else { command.addBlazeFlags(BlazeFlags.JAVA_TEST_DEBUG); + command.addBlazeFlags(BlazeFlags.RUN_LOCALLY); command.addBlazeFlags(debugPortFlag(true, debugPort)); } if (kotlinxCoroutinesJavaAgent != null) { diff --git a/java/tests/unittests/com/google/idea/blaze/java/run/BlazeJavaRunProfileStateTest.java b/java/tests/unittests/com/google/idea/blaze/java/run/BlazeJavaRunProfileStateTest.java index 2ff926dd5c9..38ad3b02fb0 100644 --- a/java/tests/unittests/com/google/idea/blaze/java/run/BlazeJavaRunProfileStateTest.java +++ b/java/tests/unittests/com/google/idea/blaze/java/run/BlazeJavaRunProfileStateTest.java @@ -233,6 +233,7 @@ public void debugFlagShouldBeIncludedForJavaTest() { "command", BlazeFlags.getToolTagFlag(), "--java_debug", + "--remote_executor=", "--test_arg=--wrapper_script_flag=--debug=127.0.0.1:5005", "--", "//label:rule")); @@ -260,6 +261,7 @@ public void debugFlagShouldBeIncludedForJavaTestSuite() { "test", BlazeFlags.getToolTagFlag(), "--java_debug", + "--remote_executor=", "--test_arg=--wrapper_script_flag=--debug=127.0.0.1:5005", "--", "//label:java_test_suite_rule"));