Skip to content

Commit

Permalink
[7.4.0] Ensure parent directories of action outputs are made writable…
Browse files Browse the repository at this point in the history
… when building without the bytes. (bazelbuild#23577)

Fixes bazelbuild#23462.

Closes bazelbuild#23555.

PiperOrigin-RevId: 672863567
Change-Id: I50af46f2ae637fb478e81ae31bd16ac4e306fe40

Commit
bazelbuild@885a6ba

Co-authored-by: Tiago Quelhas <[email protected]>
  • Loading branch information
bazel-io and tjgq authored Sep 12, 2024
1 parent 076214d commit 54e572b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public void createActionFsOutputDirectories(
if (done.add(outputDir)) {
try {
outputDir.createDirectoryAndParents();
outputDir.setWritable(true);
continue;
} catch (IOException e) {
/* Fall through to plan B. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1176,21 +1176,43 @@ public void multiplePackagePaths_buildsSuccessfully() throws Exception {
}

@Test
public void incrementalBuild_deleteOutputsInUnwritableParentDirectory() throws Exception {
public void incrementalBuild_unwritableParentDirectory_outputExists() throws Exception {
write(
"BUILD",
"genrule(",
" name = 'unwritable',",
" srcs = ['file.in'],",
" outs = ['unwritable/somefile.out'],",
" cmd = 'cat $(SRCS) > $@; chmod a-w $$(dirname $@)',",
" cmd = 'cat $(SRCS) > $@',",
" local = True,",
")");
write("file.in", "content");
buildTarget("//:unwritable");

getOutputPath("unwritable").setWritable(false);

write("file.in", "updated content");
buildTarget("//:unwritable");
}

@Test
public void incrementalBuild_unwritableParentDirectory_outputDoesNotExist() throws Exception {
write(
"BUILD",
"genrule(",
" name = 'unwritable',",
" srcs = ['file.in'],",
" outs = ['unwritable/somefile.out'],",
" cmd = 'cat $(SRCS) > $@',",
" local = True,",
")");
write("file.in", "content");
buildTarget("//:unwritable");

getOutputPath("unwritable/somefile.out").delete();
getOutputPath("unwritable").setWritable(false);

write("file.in", "updated content");
buildTarget("//:unwritable");
}

Expand Down

0 comments on commit 54e572b

Please sign in to comment.