elvish/pkg/eval/builtin_fn_misc_unix_test.go
Qi Xiao 6723b9a226 Use consistent pattern for mutating variables in tests.
- Use testutil.Set.

- Only export such variables to tests.
2022-06-19 23:56:18 +01:00

28 lines
471 B
Go

//go:build !windows && !plan9 && !js
package eval_test
import (
"os"
"testing"
"time"
"golang.org/x/sys/unix"
. "src.elv.sh/pkg/eval"
"src.elv.sh/pkg/testutil"
. "src.elv.sh/pkg/eval/evaltest"
)
func TestSleep_Interrupt(t *testing.T) {
testutil.Set(t, TimeAfter,
func(fm *Frame, d time.Duration) <-chan time.Time {
go unix.Kill(os.Getpid(), unix.SIGINT)
return time.After(d)
})
Test(t,
That(`sleep 1s`).Throws(ErrInterrupted, "sleep 1s"),
)
}