Add helper method for debug of Bazel run by JUnit black box tests
Closes
@@ -51,6 +51,7 @@ public final class BuilderRunner {
private int errorCode = 0;
private List<String> flags;
private boolean shouldFail;
+ private boolean enableDebug;
/**
* Creates the BuilderRunner
@@ -131,6 +132,17 @@ public final class BuilderRunner {
return this;
}
+ /**
+ * 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 @@ public final class BuilderRunner {
list.add(bazelRc.toAbsolutePath().toString());
}
}
+ if (enableDebug) {
+ list.add("--host_jvm_debug");
+ }
list.add(command);
list.addAll(this.flags);
Collections.addAll(list, args);
