Add workspace name to runfiles cache invalidation criteria This is needed to regenerate the runfiles under the right directory when the workspace name changes. -- MOS_MIGRATED_REVID=120918511
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java b/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java index 73e8c40..36f3b50 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java
@@ -193,6 +193,7 @@ Fingerprint f = new Fingerprint(); f.addString(GUID); f.addBoolean(runfiles.getLegacyExternalRunfiles()); + f.addPath(runfiles.getSuffix()); Map<PathFragment, Artifact> symlinks = runfiles.getSymlinksAsMap(null); f.addInt(symlinks.size()); for (Map.Entry<PathFragment, Artifact> symlink : symlinks.entrySet()) {
diff --git a/src/test/shell/bazel/runfiles_test.sh b/src/test/shell/bazel/runfiles_test.sh index 33205b8..ded1184 100755 --- a/src/test/shell/bazel/runfiles_test.sh +++ b/src/test/shell/bazel/runfiles_test.sh
@@ -53,4 +53,43 @@ [[ -x bazel-bin/foo/foo.runfiles/$name/foo/foo ]] || fail "No foo executable under $name" } +function test_legacy_runfiles_change() { + cat > WORKSPACE <<EOF +workspace(name = "foo") + +new_local_repository( + name = "bar", + path = ".", + build_file = "BUILD", +) +EOF + + cat > BUILD <<EOF +exports_files(glob(["*"])) + +cc_binary( + name = "thing", + srcs = ["thing.cc"], + data = ["@bar//:thing.cc"], +) +EOF + cat > thing.cc <<EOF +int main() { return 0; } +EOF + bazel build --legacy_external_runfiles //:thing &> $TEST_log \ + || fail "Build failed" + [[ -d bazel-bin/thing.runfiles/foo/external/bar ]] \ + || fail "bar not found" + + bazel build --nolegacy_external_runfiles //:thing &> $TEST_log \ + || fail "Build failed" + [[ ! -d bazel-bin/thing.runfiles/foo/external/bar ]] \ + || fail "Old bar still found" + + bazel build --legacy_external_runfiles //:thing &> $TEST_log \ + || fail "Build failed" + [[ -d bazel-bin/thing.runfiles/foo/external/bar ]] \ + || fail "bar not recreated" +} + run_suite "runfiles tests"
diff --git a/src/test/shell/integration/runfiles_test.sh b/src/test/shell/integration/runfiles_test.sh index 6821b30..8cd6ff5 100755 --- a/src/test/shell/integration/runfiles_test.sh +++ b/src/test/shell/integration/runfiles_test.sh
@@ -148,5 +148,32 @@ diff -u <(sort MANIFEST) <(sort MANIFEST2) } -run_suite "runfiles" +function test_workspace_name_change() { + cat > WORKSPACE <<EOF +workspace(name = "foo") +EOF + cat > BUILD <<EOF +cc_binary( + name = "thing", + srcs = ["thing.cc"], + data = ["BUILD"], +) +EOF + cat > thing.cc <<EOF +int main() { return 0; } +EOF + bazel build //:thing &> $TEST_log || fail "Build failed" + [[ -d ${PRODUCT_NAME}-bin/thing.runfiles/foo ]] || fail "foo not found" + + cat > WORKSPACE <<EOF +workspace(name = "bar") +EOF + bazel build //:thing &> $TEST_log || fail "Build failed" + [[ -d ${PRODUCT_NAME}-bin/thing.runfiles/bar ]] || fail "bar not found" + [[ ! -d ${PRODUCT_NAME}-bin/thing.runfiles/foo ]] \ + || fail "Old foo still found" +} + + +run_suite "runfiles"