Skip to content

Commit

Permalink
Add an option to TraversalRequest to skip emitting infinite symlink…
Browse files Browse the repository at this point in the history
… expansion errors.

PiperOrigin-RevId: 512159809
Change-Id: I14ba63fe0384648cc0fbbfe90c578dca1c0d9c77
  • Loading branch information
justinhorvitz authored and copybara-github committed Feb 24, 2023
1 parent 06b756a commit 532a52e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,21 +381,27 @@ private static FileInfo lookUpFileInfo(
if (env.valuesMissing()) {
return null;
}
return toFileInfo(fileValue, env, traversal.root().asPath(), syscallCache);
return toFileInfo(fileValue, env, traversal.root().asPath(), traversal, syscallCache);
}
}

@Nullable
private static FileInfo toFileInfo(
FileValue fileValue, Environment env, Path path, SyscallCache syscallCache)
FileValue fileValue,
Environment env,
Path path,
TraversalRequest traversal,
SyscallCache syscallCache)
throws IOException, InterruptedException {
if (fileValue.unboundedAncestorSymlinkExpansionChain() != null) {
SkyKey uniquenessKey =
FileSymlinkInfiniteExpansionUniquenessFunction.key(
fileValue.unboundedAncestorSymlinkExpansionChain());
env.getValue(uniquenessKey);
if (env.valuesMissing()) {
return null;
if (traversal.reportInfiniteSymlinkExpansionErrors()) {
SkyKey uniquenessKey =
FileSymlinkInfiniteExpansionUniquenessFunction.key(
fileValue.unboundedAncestorSymlinkExpansionChain());
env.getValue(uniquenessKey);
if (env.valuesMissing()) {
return null;
}
}

throw new FileSymlinkInfiniteExpansionException(
Expand Down Expand Up @@ -717,7 +723,8 @@ private ImmutableList<RecursiveFilesystemTraversalValue> traverseSourceChildren(
if (key instanceof FileValue.Key) {
FileValue.Key fileKey = (FileValue.Key) key;
FileInfo fileInfo =
toFileInfo((FileValue) value, env, fileKey.argument().asPath(), syscallCache);
toFileInfo(
(FileValue) value, env, fileKey.argument().asPath(), traversal, syscallCache);
if (fileInfo != null) {
childValues.add(resultForFileRoot(fileKey.argument(), fileInfo));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ public abstract class TraversalRequest implements SkyKey {
*/
protected abstract String errorInfo();

/**
* Determines whether events for {@linkplain
* com.google.devtools.build.lib.io.FileSymlinkInfiniteExpansionException infinite symlink
* expansion errors} encountered during the traversal should be emitted.
*/
protected boolean reportInfiniteSymlinkExpansionErrors() {
return true;
}

/**
* Creates a new traversal request identical to this one except with the given new values for
* {@link #root} and {@link #skipTestingForSubpackage}.
Expand Down Expand Up @@ -109,6 +118,7 @@ public final String toString() {
.add("strictOutputFiles", strictOutputFiles())
.add("skipTestingForSubpackage", skipTestingForSubpackage())
.add("errorInfo", errorInfo())
.add("reportInfiniteSymlinkExpansionErrors", reportInfiniteSymlinkExpansionErrors())
.toString();
}
}

0 comments on commit 532a52e

Please sign in to comment.