From 92ec681769c2078190627c164de06776d6b9dad1 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Wed, 25 Oct 2023 16:29:04 +0200 Subject: [PATCH] Enable `--incompatible_sandbox_hermetic_tmp` by default Fixes #3236 Fixes #19915 --- .../google/devtools/build/lib/sandbox/SandboxOptions.java | 2 +- .../devtools/build/lib/buildtool/EditDuringBuildTest.java | 5 ++--- src/test/shell/integration/sandboxing_test.sh | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxOptions.java b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxOptions.java index 768c07511fd795..c3809b85da0ead 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxOptions.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxOptions.java @@ -350,7 +350,7 @@ public ImmutableSet getInaccessiblePaths(FileSystem fs) { @Option( name = "incompatible_sandbox_hermetic_tmp", - defaultValue = "false", + defaultValue = "true", documentationCategory = OptionDocumentationCategory.EXECUTION_STRATEGY, effectTags = {OptionEffectTag.EXECUTION}, help = diff --git a/src/test/java/com/google/devtools/build/lib/buildtool/EditDuringBuildTest.java b/src/test/java/com/google/devtools/build/lib/buildtool/EditDuringBuildTest.java index e7b1dc8a677bbc..b5d194d86c2db4 100644 --- a/src/test/java/com/google/devtools/build/lib/buildtool/EditDuringBuildTest.java +++ b/src/test/java/com/google/devtools/build/lib/buildtool/EditDuringBuildTest.java @@ -44,9 +44,8 @@ public void testEditDuringBuild() throws Exception { Path in = write("edit/in", "line1"); in.setLastModifiedTime(123456789); - // Make in writable from sandbox (in case sandbox strategy is used). - String absoluteInPath = in.getPathString(); - addOptions("--sandbox_writable_path=" + absoluteInPath); + // Modify the actual source file, not a sandboxed copy. + addOptions("--spawn_strategy=local"); // The "echo" effects editing of the source file during the build: write("edit/BUILD", diff --git a/src/test/shell/integration/sandboxing_test.sh b/src/test/shell/integration/sandboxing_test.sh index 7825fa80b96d61..6cd814d45fec87 100755 --- a/src/test/shell/integration/sandboxing_test.sh +++ b/src/test/shell/integration/sandboxing_test.sh @@ -735,6 +735,7 @@ EOF touch "${temp_dir}/file" bazel test //pkg:tmp_test \ + --sandbox_add_mount_pair=/tmp \ --test_output=errors &>$TEST_log || fail "Expected test to pass" } @@ -812,6 +813,7 @@ EOF chmod +x pkg/tmp_test.sh bazel test //pkg:tmp_test \ + --sandbox_add_mount_pair=/tmp \ --test_output=errors &>$TEST_log || fail "Expected test to pass" [[ -f "${temp_dir}/file" ]] || fail "Expected ${temp_dir}/file to exist" }