Skip to content

Commit c901827

Browse files
lberkicoeuvre
authored andcommitted
Make the Merkle tree computation work in the wake of bazelbuild@7149f57 .
Fixes a bunch of downstream breakages: bazelbuild/continuous-integration#1093 bazelbuild/continuous-integration#1094 bazel-contrib/rules_nodejs#2464 bazelbuild/rules_python#419 Turns out, the assertion that "Merkle tree computation uses `ActionInput.getExecPath()`" was only mostly correct: there was a place where the key of the input map was used instead. I'm somewhat surprised that this did not show up in our test battery, although, admittedly, "unsound directory as an input file in an external repository" doesn't sound like the most common use case. RELNOTES: None. PiperOrigin-RevId: 358366246
1 parent 1f3f9f4 commit c901827

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/main/java/com/google/devtools/build/lib/remote/merkletree/DirectoryTreeBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private static int buildFromActionInputs(
146146

147147
case DIRECTORY:
148148
SortedMap<PathFragment, ActionInput> directoryInputs =
149-
explodeDirectory(path, execRoot);
149+
explodeDirectory(input.getExecPath(), execRoot);
150150
return buildFromActionInputs(
151151
directoryInputs, metadataProvider, execRoot, digestUtil, tree);
152152

src/test/shell/bazel/disk_cache_test.sh

+25
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,29 @@ EOF
6666
assert_equals "0" $(cat "${execution_file}")
6767
}
6868

69+
function test_input_directories_in_external_repo_with_sibling_repository_layout() {
70+
create_new_workspace
71+
l=$TEST_TMPDIR/l
72+
mkdir -p "$l/dir"
73+
touch "$l/WORKSPACE"
74+
touch "$l/dir/f"
75+
cat > "$l/BUILD" <<'EOF'
76+
exports_files(["dir"])
77+
EOF
78+
79+
cat >> WORKSPACE <<EOF
80+
local_repository(name="l", path="$l")
81+
EOF
82+
83+
cat > BUILD <<'EOF'
84+
genrule(name="g", srcs=["@l//:dir"], outs=["go"], cmd="find $< > $@")
85+
EOF
86+
87+
bazel build \
88+
--experimental_sibling_repository_layout \
89+
--disk_cache="$TEST_TMPDIR/cache" \
90+
//:g || fail "build failed"
91+
92+
}
93+
6994
run_suite "local action cache test"

0 commit comments

Comments
 (0)