Refactor (Simple)SpawnResult to reduce invalid representations This moves status-related helper method implementations from the concrete implementation to default methods on the interface, making their semantics clearer, and encouraging other implementations of the interface to behave the same. This also strengthens status/exitCode assertions in SpawnResult.Builder's build method. This makes misuse less likely. RELNOTES: None. PiperOrigin-RevId: 296071684
diff --git a/src/test/java/com/google/devtools/build/lib/actions/SpawnResultTest.java b/src/test/java/com/google/devtools/build/lib/actions/SpawnResultTest.java index 59de66f..2e9b0ff 100644 --- a/src/test/java/com/google/devtools/build/lib/actions/SpawnResultTest.java +++ b/src/test/java/com/google/devtools/build/lib/actions/SpawnResultTest.java
@@ -38,7 +38,7 @@ new SpawnResult.Builder() .setStatus(SpawnResult.Status.TIMEOUT) .setWallTime(Duration.ofSeconds(5)) - .setExitCode(1) + .setExitCode(SpawnResult.POSIX_TIMEOUT_EXIT_CODE) .setRunnerName("test") .build(); assertThat(r.getDetailMessage("", "", false, false, false)) @@ -50,7 +50,7 @@ SpawnResult r = new SpawnResult.Builder() .setStatus(SpawnResult.Status.TIMEOUT) - .setExitCode(1) + .setExitCode(SpawnResult.POSIX_TIMEOUT_EXIT_CODE) .setRunnerName("test") .build(); assertThat(r.getDetailMessage("", "", false, false, false))