Name the step's deadline, not a bound never set, when an unbounded command is cut (issue 1497)
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user