Skip to content

Commit

Permalink
Also inject a failure for createWritableDirectory when testing that A…
Browse files Browse the repository at this point in the history
…ctionOutputDirectoryHelper propagates exceptions.

Failure to do causes a flaky test failure when simulating an IOException while the `knownDirectories` cache is disabled. The reason is that `ActionOutputDirectoryHelper#forceCreateDirectoryAndParents` calls either `createDirectory` or `createWritableDirectory`, depending on whether the parent directory is in the cache or not. However, "disabling" the cache sets its size to zero, which doesn't prevent insertion; rather, it causes inserted entries to be almost immediately deleted by a background thread. Thus, if only one of `createDirectory` and `createWritableDirectory` throws, the test outcome depends on how fast the background thread runs.

(We could make the zero-sized cache an actual no-op, but it's unlikely that anyone would want to set it to zero outside of test code, so it's not worth the trouble.)

Fixes #21471.

PiperOrigin-RevId: 615513608
Change-Id: Id2247596c6af0e5d5142072de8309227a1d1cbd1
  • Loading branch information
tjgq authored and copybara-github committed Mar 13, 2024
1 parent 6d98251 commit f924338
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ public boolean createDirectory(PathFragment path) throws IOException {
return super.createDirectory(path);
}

@Override
public boolean createWritableDirectory(PathFragment path) throws IOException {
if (path.equals(failingPath)) {
throw injectedException;
}
return super.createWritableDirectory(path);
}

@Override
public void createDirectoryAndParents(PathFragment path) throws IOException {
if (path.equals(failingPath)) {
Expand Down

0 comments on commit f924338

Please sign in to comment.