Skip to content

Commit

Permalink
Fix message generation of ActionExecutionException"
Browse files Browse the repository at this point in the history
This fixes an issue introduced by commit
f95b80d, which resulted in certain
exception message being printed twice.
  • Loading branch information
fmeum committed Apr 27, 2023
1 parent cee1aa2 commit d17aa9e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 59 deletions.
3 changes: 2 additions & 1 deletion site/en/reference/test-encyclopedia.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ to run - for example, using a round-robin strategy. Not all test runners support
sharding. If a runner supports sharding, it must create or update the last
modified date of the file specified by
[`TEST_SHARD_STATUS_FILE`](#initial-conditions). Otherwise, Bazel assumes it
does not support sharding and will not launch additional runners.
does not support sharding and will not launch additional runners or report an
error (see [`--incompatible_check_sharding_support`]((/reference/command-line-reference#flag--incompatible_check_sharding_support)).

## Initial conditions {:#initial-conditions}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ActionExecutionException(
ActionAnalysisMetadata action,
boolean catastrophe,
DetailedExitCode detailedExitCode) {
super(combineMessages(message, cause), cause);
super(message, cause);
this.action = action;
this.catastrophe = catastrophe;
this.detailedExitCode = checkNotNull(detailedExitCode);
Expand Down Expand Up @@ -96,7 +96,7 @@ public ActionExecutionException(
NestedSet<Cause> rootCauses,
boolean catastrophe,
DetailedExitCode detailedExitCode) {
super(combineMessages(message, cause), cause);
super(message, cause);
this.action = action;
this.rootCauses = rootCauses;
this.catastrophe = catastrophe;
Expand Down Expand Up @@ -203,12 +203,4 @@ public DetailedExitCode getDetailedExitCode() {
public boolean showError() {
return getMessage() != null;
}

@Nullable
private static String combineMessages(String message, @Nullable Throwable cause) {
if (cause == null || cause.getMessage() == null) {
return message;
}
return message + ": " + cause.getMessage();
}
}

This file was deleted.

1 change: 0 additions & 1 deletion src/test/java/com/google/devtools/build/lib/actions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils",
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils:depsutils",
"//src/main/java/com/google/devtools/build/lib/util",
"//src/main/java/com/google/devtools/build/lib/util:detailed_exit_code",
"//src/main/java/com/google/devtools/build/lib/util:filetype",
"//src/main/java/com/google/devtools/build/lib/util:string",
"//src/main/java/com/google/devtools/build/lib/vfs",
Expand Down
6 changes: 4 additions & 2 deletions src/test/py/bazel/bazel_windows_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,15 +463,17 @@ def testTestShardStatusFile(self):
)
self.ScratchFile('foo.sh')

exit_code, stdout, stderr = self.RunBazel(['test', '//:foo_test'])
exit_code, stdout, stderr = self.RunBazel(
['test', '--incompatible_check_sharding_support', '//:foo_test'])
# Check for "tests failed" exit code
self.AssertExitCode(exit_code, 3, stderr, stdout)
self.assertIn("Sharding requested, but the test runner did not advertise "
"support for it by touching TEST_SHARD_STATUS_FILE.", stderr)

self.ScratchFile('foo.sh', ['touch "$TEST_SHARD_STATUS_FILE"'])

exit_code, stdout, stderr = self.RunBazel(['test', '//:foo_test'])
exit_code, stdout, stderr = self.RunBazel(
['test', '--incompatible_check_sharding_support', '//:foo_test'])
self.AssertExitCode(exit_code, 0, stderr, stdout)


Expand Down

0 comments on commit d17aa9e

Please sign in to comment.