Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.0.1] Force output checking for incremental run commands without the bytes. #20881

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,15 @@ private ModifiedFileSet startBuildAndDetermineModifiedOutputFiles(
startLocalOutputBuild();
}
}
if (!request.getPackageOptions().checkOutputFiles
// Do not skip invalidation in case the output tree is empty -- this can happen
// after it's cleaned or corrupted.
&& !modifiedOutputFiles.treatEverythingAsDeleted()) {
modifiedOutputFiles = ModifiedFileSet.NOTHING_MODIFIED;
if (!request.getPackageOptions().checkOutputFiles) {
// Do not skip output invalidation in the following cases:
// 1. If the output tree is empty: this can happen after it's cleaned or corrupted.
// 2. For a run command: so that outputs are downloaded even if they were previously built
// with --remote_download_minimal. See https://github.com/bazelbuild/bazel/issues/20843.
if (!modifiedOutputFiles.treatEverythingAsDeleted()
&& !request.getCommandName().equals("run")) {
return ModifiedFileSet.NOTHING_MODIFIED;
}
}
return modifiedOutputFiles;
}
Expand Down
38 changes: 38 additions & 0 deletions src/test/shell/bazel/remote/build_without_the_bytes_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2210,4 +2210,42 @@ EOF
//:foo >& $TEST_log || fail "Failed to build //:foo"
}

function test_incremental_run_command_with_no_check_output_files() {
# Regression test for https://github.com/bazelbuild/bazel/issues/20843.
cat > BUILD <<'EOF'
genrule(
name = "gen",
outs = ["out.txt"],
cmd = "touch $@",
)
sh_binary(
name = "foo",
srcs = ["foo.sh"],
data = ["out.txt"],
)
EOF
cat > foo.sh <<'EOF'
#!/bin/bash
if ! [[ -f "$0.runfiles/_main/out.txt" ]]; then
echo "runfile $0.runfiles/_main/out.txt not found" 1>&2
exit 1
fi
EOF
chmod +x foo.sh

CACHEDIR=$(mktemp -d)
FLAGS=(--disk_cache="$CACHEDIR" --remote_download_minimal --noexperimental_check_output_files)

# Populate the disk cache.
bazel build "${FLAGS[@]}" //:foo >& $TEST_log || fail "Failed to build //:foo"

# Clean build. No outputs are considered top-level, so nothing is downloaded.
bazel clean "${FLAGS[@]}"
bazel build "${FLAGS[@]}" //:foo >& $TEST_log || fail "Failed to build //:foo"

# Incremental run. Even though output checking is disabled, invalidation must
# must still occur to force them to be downloaded.
bazel run "${FLAGS[@]}" //:foo >& $TEST_log || fail "Failed to run //:foo"
}

run_suite "Build without the Bytes tests"
Loading