Add helper method for debug of Bazel run by JUnit black box tests
Closes #7735.
PiperOrigin-RevId: 238626987
diff --git a/src/test/java/com/google/devtools/build/lib/blackbox/framework/BuilderRunner.java b/src/test/java/com/google/devtools/build/lib/blackbox/framework/BuilderRunner.java
index 1d69d92..5e3b005 100644
--- a/src/test/java/com/google/devtools/build/lib/blackbox/framework/BuilderRunner.java
+++ b/src/test/java/com/google/devtools/build/lib/blackbox/framework/BuilderRunner.java
@@ -51,6 +51,7 @@
private int errorCode = 0;
private List<String> flags;
private boolean shouldFail;
+ private boolean enableDebug;
/**
* Creates the BuilderRunner
@@ -132,6 +133,17 @@
}
/**
+ * Should be used ONLY FOR TESTS DEBUG. Adds "--host_jvm_debug" to the Bazel startup options, so
+ * that the JVM waits for the debugger process to connect before executing any code.
+ *
+ * @return this BuilderRunner instance
+ */
+ public BuilderRunner enableDebug() {
+ this.enableDebug = true;
+ return this;
+ }
+
+ /**
* Specifies that Bazel should not pass the default .bazelrc (in the test working directory) as
* parameter
*
@@ -267,6 +279,9 @@
list.add(bazelRc.toAbsolutePath().toString());
}
}
+ if (enableDebug) {
+ list.add("--host_jvm_debug");
+ }
list.add(command);
list.addAll(this.flags);
Collections.addAll(list, args);