elvish/pkg/eval/builtin_fn_time_unix_test.go
Qi Xiao 0adf0ec147 Use the unix build tag.
The unix build tag is supported by Go 1.19.
2023-03-03 00:01:26 +00:00

28 lines
450 B
Go

//go:build unix
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"),
)
}