Name the step's deadline, not a bound never set, when an unbounded command is cut (issue 1497)

This commit is contained in:
2026-10-20 20:09:32 +00:00
parent 9e296295c0
commit 0b990a9c31
2 changed files with 7 additions and 1 deletions
+4 -1
View File
@@ -56,7 +56,10 @@ func execRun(ctx context.Context, bound time.Duration, env []string, name string
var exitErr *exec.ExitError
switch {
case errors.Is(ctx.Err(), context.DeadlineExceeded):
r.Status, r.Err = 124, fmt.Sprintf("no answer within %d s", int(bound/time.Second))
r.Status, r.Err = 124, "ended by its step's deadline"
if bound > 0 {
r.Err = fmt.Sprintf("no answer within %d s", int(bound/time.Second))
}
case errors.Is(err, exec.ErrNotFound):
r.Status, r.Err = 127, "ENOENT"
case errors.As(err, &exitErr):
+3
View File
@@ -36,6 +36,9 @@ func TestExecRunnerForZeroIsCutByItsContext(t *testing.T) {
defer cancel()
began := time.Now()
r := ExecRunnerFor(0)(ctx, nil, "sleep", "2")
if r.Err != "ended by its step's deadline" {
t.Errorf("Err = %q, want the step's deadline named, not a bound that was never set", r.Err)
}
if r.Status == 0 || time.Since(began) > time.Second {
t.Errorf("ran = %+v after %v, want it cut", r, time.Since(began))
}