diff --git a/helper/bwrap_test.go b/helper/bwrap_test.go index be0a465..a7804e3 100644 --- a/helper/bwrap_test.go +++ b/helper/bwrap_test.go @@ -113,7 +113,7 @@ func TestBwrap(t *testing.T) { nil, sc, nil, ) - }, "exec") + }) }) } diff --git a/helper/cmd.go b/helper/cmd.go index 4fe978a..bfdd348 100644 --- a/helper/cmd.go +++ b/helper/cmd.go @@ -62,7 +62,7 @@ func (h *helperCmd) Start() error { // Check for doubled Start calls before we defer failure cleanup. If the prior // call to Start succeeded, we don't want to spuriously close its pipes. if h.Cmd != nil && h.Cmd.Process != nil { - return errors.New("exec: already started") + return errors.New("helper: already started") } h.Env = slices.Grow(h.Env, 2) diff --git a/helper/cmd_test.go b/helper/cmd_test.go index 9c64098..a761d82 100644 --- a/helper/cmd_test.go +++ b/helper/cmd_test.go @@ -34,6 +34,6 @@ func TestCmd(t *testing.T) { return helper.NewDirect(ctx, os.Args[0], argsWt, stat, argF, func(cmd *exec.Cmd) { setOutput(&cmd.Stdout, &cmd.Stderr) }, nil) - }, "exec") + }) }) } diff --git a/helper/helper_test.go b/helper/helper_test.go index 27c3171..ced3bb8 100644 --- a/helper/helper_test.go +++ b/helper/helper_test.go @@ -48,10 +48,11 @@ func argFChecked(argsFd, statFd int) (args []string) { } // this function tests an implementation of the helper.Helper interface -func testHelper(t *testing.T, - createHelper func(ctx context.Context, setOutput func(stdoutP, stderrP *io.Writer), stat bool) helper.Helper, - prefix string, -) { +func testHelper(t *testing.T, createHelper func(ctx context.Context, setOutput func(stdoutP, stderrP *io.Writer), stat bool) helper.Helper) { + oldWaitDelay := helper.WaitDelay + helper.WaitDelay = 16 * time.Second + t.Cleanup(func() { helper.WaitDelay = oldWaitDelay }) + t.Run("start helper with status channel and wait", func(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) stdout, stderr := new(strings.Builder), new(strings.Builder) @@ -77,7 +78,7 @@ func testHelper(t *testing.T, cancel() t.Run("start already started helper", func(t *testing.T) { - wantErr := prefix + ": already started" + wantErr := "helper: already started" if err := h.Start(); err != nil && err.Error() != wantErr { t.Errorf("Start: error = %v, wantErr %v", err, wantErr)