diff options
author | 2015-09-08 08:35:16 +0000 | |
---|---|---|
committer | 2015-09-08 09:09:02 +0000 | |
commit | 95ef61d06401800bdcee2d9d2240f6bf7d553f28 (patch) | |
tree | be3d802aabec58e7995cb4818486425b40179ff3 /src/main/java/com/google/devtools/build | |
parent | 34bfb8c9a06cacfcbb4f009765645978a514bb91 (diff) |
Display TIMEOUT for test that times out
Previously the timing out information wasn't propagated to the
user, leading to a wrong FAILED message whereas the test was
timing out.
--
MOS_MIGRATED_REVID=102535481
Diffstat (limited to 'src/main/java/com/google/devtools/build')
5 files changed, 49 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ExecException.java b/src/main/java/com/google/devtools/build/lib/actions/ExecException.java index a2edc84291..efcb55f982 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ExecException.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ExecException.java @@ -43,10 +43,12 @@ package com.google.devtools.build.lib.actions; public abstract class ExecException extends Exception { private final boolean catastrophe; + private final boolean timedOut; public ExecException(String message, boolean catastrophe) { super(message); this.catastrophe = catastrophe; + this.timedOut = false; } public ExecException(String message) { @@ -56,12 +58,25 @@ public abstract class ExecException extends Exception { public ExecException(String message, Throwable cause, boolean catastrophe) { super(message + ": " + cause.getMessage(), cause); this.catastrophe = catastrophe; + this.timedOut = false; } public ExecException(String message, Throwable cause) { this(message, cause, false); } + public ExecException(String message, boolean catastrophe, boolean timedOut) { + super(message); + this.catastrophe = catastrophe; + this.timedOut = timedOut; + } + + public ExecException(String message, Throwable cause, boolean catastrophe, boolean timedOut) { + super(message, cause); + this.catastrophe = catastrophe; + this.timedOut = timedOut; + } + /** * Catastrophic exceptions should stop the build, even if --keep_going. */ @@ -93,4 +108,12 @@ public abstract class ExecException extends Exception { */ public abstract ActionExecutionException toActionExecutionException(String messagePrefix, boolean verboseFailures, Action action); + + + /** + * Tells if the execution exception was thrown because of the execution timing out. + */ + public boolean hasTimedOut() { + return timedOut; + } } diff --git a/src/main/java/com/google/devtools/build/lib/actions/UserExecException.java b/src/main/java/com/google/devtools/build/lib/actions/UserExecException.java index 86a6eb008c..15cdb887ce 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/UserExecException.java +++ b/src/main/java/com/google/devtools/build/lib/actions/UserExecException.java @@ -24,10 +24,18 @@ public class UserExecException extends ExecException { super(message); } + public UserExecException(String message, boolean timedOut) { + super(message, false, timedOut); + } + public UserExecException(String message, Throwable cause) { super(message, cause); } + public UserExecException(String message, Throwable cause, boolean timedOut) { + super(message, cause, false, timedOut); + } + @Override public ActionExecutionException toActionExecutionException(String messagePrefix, boolean verboseFailures, Action action) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java b/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java index 2e29789360..ea19b5bf99 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java @@ -190,8 +190,9 @@ public class StandaloneTestStrategy extends TestStrategy { // TODO(bazel-team): set cachable==true for relevant statuses (failure, but not for // timeout, etc.) - builder.setTestPassed(false) - .setStatus(BlazeTestStatus.FAILED); + builder + .setTestPassed(false) + .setStatus(e.hasTimedOut() ? BlazeTestStatus.TIMEOUT : BlazeTestStatus.FAILED); } finally { if (streamed != null) { streamed.close(); diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java index 1ee75f4eff..d1a1783e60 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java @@ -38,7 +38,9 @@ import com.google.devtools.build.lib.events.EventHandler; import com.google.devtools.build.lib.rules.cpp.CppCompileAction; import com.google.devtools.build.lib.rules.test.TestRunnerAction; import com.google.devtools.build.lib.runtime.BlazeRuntime; +import com.google.devtools.build.lib.shell.AbnormalTerminationException; import com.google.devtools.build.lib.shell.CommandException; +import com.google.devtools.build.lib.shell.TerminationStatus; import com.google.devtools.build.lib.standalone.StandaloneSpawnStrategy; import com.google.devtools.build.lib.syntax.Label; import com.google.devtools.build.lib.unix.FilesystemUtils; @@ -195,10 +197,11 @@ public class LinuxSandboxedStrategy implements SpawnActionContext { } }); } + } catch (AbnormalTerminationException e) { + TerminationStatus status = e.getResult().getTerminationStatus(); + boolean timedOut = !status.exited() && (status.getTerminatingSignal() == 14 /* SIGALRM */); + throw new UserExecException("Error during execution of spawn", e, timedOut); } catch (CommandException e) { - EventHandler handler = actionExecutionContext.getExecutor().getEventHandler(); - handler.handle( - Event.error("Sandboxed execution failed: " + spawn.getOwner().getLabel() + ".")); throw new UserExecException("Error during execution of spawn", e); } catch (IOException e) { EventHandler handler = actionExecutionContext.getExecutor().getEventHandler(); diff --git a/src/main/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategy.java b/src/main/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategy.java index cdd2d70583..ed034d5e49 100644 --- a/src/main/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategy.java @@ -20,8 +20,10 @@ import com.google.devtools.build.lib.actions.Executor; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.SpawnActionContext; import com.google.devtools.build.lib.actions.UserExecException; +import com.google.devtools.build.lib.shell.AbnormalTerminationException; import com.google.devtools.build.lib.shell.Command; import com.google.devtools.build.lib.shell.CommandException; +import com.google.devtools.build.lib.shell.TerminationStatus; import com.google.devtools.build.lib.syntax.Label; import com.google.devtools.build.lib.util.CommandFailureUtils; import com.google.devtools.build.lib.util.OS; @@ -103,6 +105,13 @@ public class StandaloneSpawnStrategy implements SpawnActionContext { outErr.getOutputStream(), outErr.getErrorStream(), /*killSubprocessOnInterrupt*/ true); + } catch (AbnormalTerminationException e) { + TerminationStatus status = e.getResult().getTerminationStatus(); + boolean timedOut = !status.exited() && (status.getTerminatingSignal() == 14 /* SIGALRM */); + String message = + CommandFailureUtils.describeCommandFailure( + verboseFailures, spawn.getArguments(), spawn.getEnvironment(), cwd); + throw new UserExecException(String.format("%s: %s", message, e), timedOut); } catch (CommandException e) { String message = CommandFailureUtils.describeCommandFailure( verboseFailures, spawn.getArguments(), spawn.getEnvironment(), cwd); |