exec: increase default wait delay
Should avoid killing Nix command whenever possible.
This commit is contained in:
parent
4787f51d84
commit
e448541464
2
exec.go
2
exec.go
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
defaultWaitDelay = 15 * time.Second
|
||||
defaultWaitDelay = 30 * time.Second
|
||||
)
|
||||
|
||||
// Nix is the name of the nix program.
|
||||
|
@ -107,7 +107,7 @@ func TestNixStub(t *testing.T) {
|
||||
Flag(&flagExtraExperimentalFeatures, trimFlagName(nix.ExtraExperimentalFeatures), command.StringFlag(""),
|
||||
fmt.Sprintf("expects exactly %q", nix.ExperimentalFeaturesFlakes))
|
||||
|
||||
c.Command("true", command.UsageInternal, func([]string) error { return nil })
|
||||
c.Command(nix.ValueTrue, command.UsageInternal, func([]string) error { return nil })
|
||||
|
||||
for _, f := range stubCommandInit {
|
||||
f(c)
|
20
exec_test.go
20
exec_test.go
@ -1,6 +1,7 @@
|
||||
package nix_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
@ -33,4 +34,23 @@ func TestNixWriteStdin(t *testing.T) {
|
||||
t.Fatalf("WriteStdinCommand: error = %v, want %v", err, syscall.ENOSYS)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("exit before cancel", func(t *testing.T) {
|
||||
stubNixCommand(t)
|
||||
ctx := newStubContext(t.Context(), nil, os.Stdout, os.Stderr)
|
||||
c, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
cmd := ctx.Nix(c, "true")
|
||||
if err := cmd.Start(); err != nil {
|
||||
t.Fatalf("Start: error = %v", err)
|
||||
}
|
||||
// Cancel is skipped after exec.Cmd.Wait completes
|
||||
if _, err := cmd.Process.Wait(); err != nil {
|
||||
t.Fatalf("Wait: error = %v", err)
|
||||
}
|
||||
cancel()
|
||||
if cmd.Err != nil {
|
||||
t.Fatalf("Err = %v", cmd.Err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user