Skip to content

Commit

Permalink
Make the Merkle tree computation work in the wake of 7149f57 .
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lberki authored and copybara-github committed Feb 19, 2021
1 parent eeb1576 commit 4efeac9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private static int buildFromActionInputs(

case DIRECTORY:
SortedMap<PathFragment, ActionInput> directoryInputs =
explodeDirectory(path, execRoot);
explodeDirectory(input.getExecPath(), execRoot);
return buildFromActionInputs(
directoryInputs, metadataProvider, execRoot, digestUtil, tree);

Expand Down
25 changes: 25 additions & 0 deletions src/test/shell/bazel/disk_cache_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,29 @@ EOF
assert_equals "0" $(cat "${execution_file}")
}

function test_input_directories_in_external_repo_with_sibling_repository_layout() {
create_new_workspace
l=$TEST_TMPDIR/l
mkdir -p "$l/dir"
touch "$l/WORKSPACE"
touch "$l/dir/f"
cat > "$l/BUILD" <<'EOF'
exports_files(["dir"])
EOF

cat >> WORKSPACE <<EOF
local_repository(name="l", path="$l")
EOF

cat > BUILD <<'EOF'
genrule(name="g", srcs=["@l//:dir"], outs=["go"], cmd="find $< > $@")
EOF

bazel build \
--experimental_sibling_repository_layout \
--disk_cache="$TEST_TMPDIR/cache" \
//:g || fail "build failed"

}

run_suite "local action cache test"

0 comments on commit 4efeac9

Please sign in to comment.