From 25b17db6c159abc112e89ca1e4dce622be1f147b Mon Sep 17 00:00:00 2001 From: ulfjack Date: Mon, 10 Apr 2017 08:23:18 +0000 Subject: Fix the SpawnInputExpander to compute the manifest path correctly PiperOrigin-RevId: 152663008 --- .../build/lib/exec/SpawnInputExpander.java | 3 ++- .../build/lib/exec/SpawnInputExpanderTest.java | 26 +++++++++++----------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java b/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java index 351f8c7e10..ef538a0c2d 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java @@ -113,7 +113,8 @@ public class SpawnInputExpander { Map inputMappings, Artifact manifest, String workspaceName) throws IOException { Path file = manifest.getRoot().getPath().getRelative( - AnalysisUtils.getManifestPathFromFilesetPath(manifest.getExecPath()).getPathString()); + AnalysisUtils.getManifestPathFromFilesetPath( + manifest.getRootRelativePath()).getPathString()); FileSystemUtils.asByteSource(file).asCharSource(UTF_8) .readLines(new ManifestLineProcessor(inputMappings, workspaceName, manifest.getExecPath())); } diff --git a/src/test/java/com/google/devtools/build/lib/exec/SpawnInputExpanderTest.java b/src/test/java/com/google/devtools/build/lib/exec/SpawnInputExpanderTest.java index 5b6db72c27..355e914bcc 100644 --- a/src/test/java/com/google/devtools/build/lib/exec/SpawnInputExpanderTest.java +++ b/src/test/java/com/google/devtools/build/lib/exec/SpawnInputExpanderTest.java @@ -191,52 +191,52 @@ public class SpawnInputExpanderTest { public void testManifestWithSingleFile() throws Exception { // See AnalysisUtils for the mapping from "foo" to "_foo/MANIFEST". scratchFile( - "/root/_foo/MANIFEST", + "/root/out/_foo/MANIFEST", "workspace/bar /dir/file", ""); - Artifact artifact = - new Artifact(fs.getPath("/root/foo"), Root.asSourceRoot(fs.getPath("/root"))); + Root outputRoot = Root.asDerivedRoot(fs.getPath("/root"), fs.getPath("/root/out"), true); + Artifact artifact = new Artifact(fs.getPath("/root/out/foo"), outputRoot); expander.parseFilesetManifest(inputMappings, artifact, "workspace"); assertThat(inputMappings).hasSize(1); assertThat(inputMappings) - .containsEntry(PathFragment.create("foo/bar"), ActionInputHelper.fromPath("/dir/file")); + .containsEntry(PathFragment.create("out/foo/bar"), ActionInputHelper.fromPath("/dir/file")); } @Test public void testManifestWithTwoFiles() throws Exception { // See AnalysisUtils for the mapping from "foo" to "_foo/MANIFEST". scratchFile( - "/root/_foo/MANIFEST", + "/root/out/_foo/MANIFEST", "workspace/bar /dir/file", "", "workspace/baz /dir/file", ""); - Artifact artifact = - new Artifact(fs.getPath("/root/foo"), Root.asSourceRoot(fs.getPath("/root"))); + Root outputRoot = Root.asDerivedRoot(fs.getPath("/root"), fs.getPath("/root/out"), true); + Artifact artifact = new Artifact(fs.getPath("/root/out/foo"), outputRoot); expander.parseFilesetManifest(inputMappings, artifact, "workspace"); assertThat(inputMappings).hasSize(2); assertThat(inputMappings) - .containsEntry(PathFragment.create("foo/bar"), ActionInputHelper.fromPath("/dir/file")); + .containsEntry(PathFragment.create("out/foo/bar"), ActionInputHelper.fromPath("/dir/file")); assertThat(inputMappings) - .containsEntry(PathFragment.create("foo/baz"), ActionInputHelper.fromPath("/dir/file")); + .containsEntry(PathFragment.create("out/foo/baz"), ActionInputHelper.fromPath("/dir/file")); } @Test public void testManifestWithDirectory() throws Exception { // See AnalysisUtils for the mapping from "foo" to "_foo/MANIFEST". scratchFile( - "/root/_foo/MANIFEST", + "/root/out/_foo/MANIFEST", "workspace/bar /some", ""); - Artifact artifact = - new Artifact(fs.getPath("/root/foo"), Root.asSourceRoot(fs.getPath("/root"))); + Root outputRoot = Root.asDerivedRoot(fs.getPath("/root"), fs.getPath("/root/out"), true); + Artifact artifact = new Artifact(fs.getPath("/root/out/foo"), outputRoot); expander.parseFilesetManifest(inputMappings, artifact, "workspace"); assertThat(inputMappings).hasSize(1); assertThat(inputMappings) .containsEntry( - PathFragment.create("foo/bar"), ActionInputHelper.fromPath("/some")); + PathFragment.create("out/foo/bar"), ActionInputHelper.fromPath("/some")); } } -- cgit v1.2.3