diff options
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java | 24 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java | 7 |
2 files changed, 20 insertions, 11 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java index 78cb3c08ec..7319653078 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java @@ -38,7 +38,6 @@ import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter; import com.google.devtools.build.lib.skylarkinterface.SkylarkValue; -import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import java.io.BufferedReader; import java.io.IOException; @@ -423,11 +422,20 @@ public final class Runfiles { continue outer; } PathFragment suffix = source.subFragment(n - j, n); - Path viaAncestor = ancestor.getPath().getRelative(suffix); - Path expected = symlink.getPath(); + PathFragment viaAncestor = ancestor.getExecPath().getRelative(suffix); + PathFragment expected = symlink.getExecPath(); if (!viaAncestor.equals(expected)) { - eventHandler.handle(Event.warn(location, "runfiles symlink " + source + " -> " - + expected + " obscured by " + prefix + " -> " + ancestor.getPath())); + eventHandler.handle( + Event.warn( + location, + "runfiles symlink " + + source + + " -> " + + expected + + " obscured by " + + prefix + + " -> " + + ancestor.getExecPath())); } continue outer; } @@ -731,8 +739,10 @@ public final class Runfiles { // Previous and new entry might have value of null Artifact previous = map.get(path); if (!Objects.equals(previous, artifact)) { - String previousStr = (previous == null) ? "empty file" : previous.getPath().toString(); - String artifactStr = (artifact == null) ? "empty file" : artifact.getPath().toString(); + String previousStr = + (previous == null) ? "empty file" : previous.getExecPath().toString(); + String artifactStr = + (artifact == null) ? "empty file" : artifact.getExecPath().toString(); String message = String.format( "overwrote runfile %s, was symlink to %s, now symlink to %s", diff --git a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java index e31d516f2d..6e2e3a1850 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java @@ -41,7 +41,7 @@ import org.junit.runners.JUnit4; public class RunfilesTest extends FoundationTestCase { private void checkWarning() { - assertContainsEvent("obscured by a -> /workspace/a"); + assertContainsEvent("obscured by a -> x"); assertWithMessage("Runfiles.filterListForObscuringSymlinks should have warned once") .that(eventCollector.count()) .isEqualTo(1); @@ -53,7 +53,7 @@ public class RunfilesTest extends FoundationTestCase { Map<PathFragment, Artifact> obscuringMap = new HashMap<>(); PathFragment pathA = PathFragment.create("a"); ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); - Artifact artifactA = new Artifact(PathFragment.create("a"), root); + Artifact artifactA = new Artifact(PathFragment.create("x"), root); obscuringMap.put(pathA, artifactA); obscuringMap.put(PathFragment.create("a/b"), new Artifact(PathFragment.create("c/b"), root)); @@ -67,8 +67,7 @@ public class RunfilesTest extends FoundationTestCase { Map<PathFragment, Artifact> obscuringMap = new HashMap<>(); PathFragment pathA = PathFragment.create("a"); ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); - Artifact artifactA = new Artifact(PathFragment.create("a"), - root); + Artifact artifactA = new Artifact(PathFragment.create("x"), root); obscuringMap.put(pathA, artifactA); obscuringMap.put(PathFragment.create("a/b/c"), new Artifact(PathFragment.create("b/c"), root)); |