diff options
author | 2017-07-19 13:21:07 +0200 | |
---|---|---|
committer | 2017-07-19 16:48:42 +0200 | |
commit | 10cc2e3e891ff643bb547e478f5b7e60a20ff658 (patch) | |
tree | 13d3911222b7ab046a46619c9c8fb6cbaee64b22 /src/test/java/com/google/devtools | |
parent | 891f540a1bc6977f25e77a29f24cdcf939fb2e2e (diff) |
Fix sandboxing when spawn outputs differ from action outputs.
TestRunner actions are special because their action outputs are
different from their spawn outputs. If there's a spawn output that's
not an action output, SymlinkExecroot can't rely on the parent
directories for that output existing in the real execroot. Thus,
copyOutputs() must ensure the real execroot has the relevant ancestral
directories before copying the output over.
Change-Id: I84fd69cd51628c51de9c8993b6a4407bbff038a0
PiperOrigin-RevId: 162470058
Diffstat (limited to 'src/test/java/com/google/devtools')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawnTest.java | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawnTest.java b/src/test/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawnTest.java index 9d186c0a61..6f797afbd4 100644 --- a/src/test/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawnTest.java +++ b/src/test/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawnTest.java @@ -107,19 +107,22 @@ public class SymlinkedSandboxedSpawnTest extends SandboxTestCase { Path outputLink = execRoot.getRelative("very/output.link"); Path outputDangling = execRoot.getRelative("very/output.dangling"); Path outputDir = execRoot.getRelative("very/output.dir"); + Path outputInUncreatedTargetDir = execRoot.getRelative("uncreated/output.txt"); - SymlinkedSandboxedSpawn symlinkedExecRoot = new SymlinkedSandboxedSpawn( - sandboxDir, - execRoot, - ImmutableList.of("/bin/true"), - ImmutableMap.<String, String>of(), - ImmutableMap.<PathFragment, Path>of(), - ImmutableSet.of( - outputFile.relativeTo(execRoot), - outputLink.relativeTo(execRoot), - outputDangling.relativeTo(execRoot), - outputDir.relativeTo(execRoot)), - ImmutableSet.<Path>of()); + SymlinkedSandboxedSpawn symlinkedExecRoot = + new SymlinkedSandboxedSpawn( + sandboxDir, + execRoot, + ImmutableList.of("/bin/true"), + ImmutableMap.<String, String>of(), + ImmutableMap.<PathFragment, Path>of(), + ImmutableSet.of( + outputFile.relativeTo(execRoot), + outputLink.relativeTo(execRoot), + outputDangling.relativeTo(execRoot), + outputDir.relativeTo(execRoot), + outputInUncreatedTargetDir.relativeTo(execRoot)), + ImmutableSet.<Path>of()); symlinkedExecRoot.createFileSystem(); FileSystemUtils.createEmptyFile(outputFile); @@ -127,6 +130,7 @@ public class SymlinkedSandboxedSpawnTest extends SandboxTestCase { outputDangling.createSymbolicLink(PathFragment.create("doesnotexist")); outputDir.createDirectory(); FileSystemUtils.createEmptyFile(outputDir.getRelative("test.txt")); + FileSystemUtils.createEmptyFile(outputInUncreatedTargetDir); outputsDir.getRelative("very").createDirectory(); symlinkedExecRoot.copyOutputs(outputsDir); @@ -145,5 +149,6 @@ public class SymlinkedSandboxedSpawnTest extends SandboxTestCase { assertThat(outputsDir.getRelative("very/output.dir").isDirectory(Symlinks.NOFOLLOW)).isTrue(); assertThat(outputsDir.getRelative("very/output.dir/test.txt").isFile(Symlinks.NOFOLLOW)) .isTrue(); + assertThat(outputsDir.getRelative("uncreated/output.txt").isFile(Symlinks.NOFOLLOW)).isTrue(); } } |