Skip to content

Commit

Permalink
Give helpful information if the user encounters action conflicts from…
Browse files Browse the repository at this point in the history
… a single target.

PiperOrigin-RevId: 421073213
  • Loading branch information
Googler authored and Copybara-Service committed Jan 11, 2022
1 parent d98dcf1 commit 10fb5ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,10 @@ private static ConfiguredTargetValue createConfiguredTarget(
} catch (MissingDepException e) {
Preconditions.checkState(env.valuesMissing(), e.getMessage());
return null;
} catch (ActionConflictException | InvalidExecGroupException e) {
} catch (ActionConflictException e) {
e.reportTo(env.getListener());
throw new ConfiguredValueCreationException(ctgValue, e.getMessage());
} catch (InvalidExecGroupException e) {
throw new ConfiguredValueCreationException(ctgValue, e.getMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,23 @@ public void aliasConflict() throws Exception {
() -> update("//conflict:conflict1", "//conflict:aliased"));
}

@Test
public void actionConflictFromSameTarget() throws Exception {
scratch.file(
"conflict/conflict.bzl",
"def _conflict(ctx):",
" file = ctx.actions.declare_file('single_file')",
" ctx.actions.write(output = file, content = 'a')",
" ctx.actions.write(output = file, content = 'b')",
" return [DefaultInfo(files = depset([file]))]",
"my_rule = rule(implementation = _conflict)");
scratch.file(
"conflict/BUILD", "load(':conflict.bzl', 'my_rule')", "my_rule(name = 'conflict')");
reporter.removeHandler(failFastHandler);
assertThrows(ViewCreationFailedException.class, () -> update("//conflict"));
assertContainsEvent("file 'conflict/single_file' is generated by these conflicting actions:");
}

@Test
public void actionConflictWithDependentRule() throws IOException {
scratch.file(
Expand Down

0 comments on commit 10fb5ee

Please sign in to comment.