Add a mechanism to pass extra flags to the process-wrapper.
This adds a new --process_wrapper_extra_flags repeated flag that takes
extra flags to pass to the proces-wrapper. These flags are appended to
the invocation built by Blaze, so we can use this to override builtin
computed values.
We'll use this to controlledly roll out the changes from https://github.com/bazelbuild/bazel/commit/7828118ea8f4150aa1eae4ab3133935ffe221eb5
(and, later, https://github.com/bazelbuild/bazel/commit/9c1853aa2fe49cf80dd467bb4020eb0822d53881), both of which required a Bazel release rollback
due to unforeseen problems.
Part of https://github.com/bazelbuild/bazel/issues/10245.
RELNOTES: None.
PiperOrigin-RevId: 311162177
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperTest.java b/src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperTest.java
index 06de77c..b509cbb 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperTest.java
@@ -23,7 +23,6 @@
import java.io.IOException;
import java.time.Duration;
import java.util.List;
-import javax.annotation.Nullable;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,12 +39,11 @@
testFS = new InMemoryFileSystem();
}
- private ProcessWrapper getProcessWrapper(String path, @Nullable Duration killDelay)
- throws IOException {
+ private Path makeProcessWrapperBin(String path) throws IOException {
Path processWrapperPath = testFS.getPath(path);
processWrapperPath.getParentDirectory().createDirectoryAndParents();
processWrapperPath.getOutputStream().close();
- return new ProcessWrapper(processWrapperPath, killDelay);
+ return processWrapperPath;
}
@Test
@@ -54,9 +52,11 @@
ImmutableList<String> commandArguments = ImmutableList.of("echo", "hello, world");
ImmutableList<String> expectedCommandLine =
- ImmutableList.<String>builder().add("/some/bin/path").addAll(commandArguments).build();
+ ImmutableList.<String>builder().add("/some/path").addAll(commandArguments).build();
- ProcessWrapper processWrapper = getProcessWrapper("/some/bin/path", /*killDelay=*/ null);
+ ImmutableList<String> extraFlags = ImmutableList.of();
+ ProcessWrapper processWrapper =
+ new ProcessWrapper(makeProcessWrapperBin("/some/path"), /*killDelay=*/ null, extraFlags);
List<String> commandLine = processWrapper.commandLineBuilder(commandArguments).build();
assertThat(commandLine).containsExactlyElementsIn(expectedCommandLine).inOrder();
@@ -65,6 +65,7 @@
@Test
public void testProcessWrapperCommandLineBuilder_BuildsWithOptionalArguments()
throws IOException {
+ ImmutableList<String> extraFlags = ImmutableList.of("--debug");
ImmutableList<String> commandArguments = ImmutableList.of("echo", "hello, world");
Duration timeout = Duration.ofSeconds(10);
@@ -75,16 +76,19 @@
ImmutableList<String> expectedCommandLine =
ImmutableList.<String>builder()
- .add("/path/to/process-wrapper")
+ .add("/path/process-wrapper")
.add("--timeout=" + timeout.getSeconds())
.add("--kill_delay=" + killDelay.getSeconds())
.add("--stdout=" + stdoutPath)
.add("--stderr=" + stderrPath)
.add("--stats=" + statisticsPath)
+ .addAll(extraFlags)
.addAll(commandArguments)
.build();
- ProcessWrapper processWrapper = getProcessWrapper("/path/to/process-wrapper", killDelay);
+ ProcessWrapper processWrapper =
+ new ProcessWrapper(makeProcessWrapperBin("/path/process-wrapper"), killDelay, extraFlags);
+
List<String> commandLine =
processWrapper
.commandLineBuilder(commandArguments)