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

[6.2.0]Skip empty directories instead of throwing in prefetcher. #17718

Merged
merged 1 commit into from
Mar 10, 2023
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 @@ -197,10 +197,16 @@ protected ListenableFuture<Void> prefetchFiles(
Map<SpecialArtifact, List<TreeFileArtifact>> trees = new HashMap<>();
List<ActionInput> files = new ArrayList<>();
for (ActionInput input : inputs) {
// Source artifacts don't need to be fetched.
if (input instanceof Artifact && ((Artifact) input).isSourceArtifact()) {
continue;
}

// Skip empty tree artifacts (non-empty tree artifacts should have already been expanded).
if (input.isDirectory()) {
continue;
}

if (input instanceof TreeFileArtifact) {
TreeFileArtifact treeFile = (TreeFileArtifact) input;
SpecialArtifact treeArtifact = treeFile.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,58 @@ public void treeOutputsFromLocalFileSystem_works() throws Exception {
assertValidOutputFile("out/foobar.txt", "file-1\nbar\n");
}

@Test
public void emptyTreeConsumedByLocalAction() throws Exception {
// Disable remote execution so that the empty tree artifact is prefetched.
addOptions("--modify_execution_info=Genrule=+no-remote-exec");
setDownloadToplevel();
writeOutputDirRule();
write(
"BUILD",
"load(':output_dir.bzl', 'output_dir')",
"output_dir(",
" name = 'foo',",
" manifest = ':manifest',",
")",
"genrule(",
" name = 'foobar',",
" srcs = [':foo'],",
" outs = ['foobar.txt'],",
" cmd = 'touch $@',",
")");
write("manifest"); // no files

buildTarget("//:foobar");
waitDownloads();
}

@Test
public void multiplePackagePaths_buildsSuccessfully() throws Exception {
write(
"../a/src/BUILD",
"genrule(",
" name = 'foo',",
" srcs = [],",
" outs = ['out/foo.txt'],",
" cmd = 'echo foo > $@',",
")");
write(
"BUILD",
"genrule(",
" name = 'foobar',",
" srcs = ['//src:foo'],",
" outs = ['out/foobar.txt'],",
" cmd = 'cat $(location //src:foo) > $@ && echo bar >> $@',",
")");
addOptions("--package_path=%workspace%:%workspace%/../a");
setDownloadToplevel();

buildTarget("//:foobar");
waitDownloads();

assertValidOutputFile("out/foobar.txt", "foo\nbar\n");
}

@Test
public void incrementalBuild_deleteOutputsInUnwritableParentDirectory() throws Exception {
write(
Expand Down