2023-03-03 07:48:01 +08:00
|
|
|
//go:build unix
|
2020-08-18 13:40:30 +08:00
|
|
|
|
2020-09-03 13:48:39 +08:00
|
|
|
package eval_test
|
2020-08-18 13:40:30 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
"time"
|
2020-09-03 13:48:39 +08:00
|
|
|
|
2022-06-20 06:56:18 +08:00
|
|
|
"golang.org/x/sys/unix"
|
2021-01-27 09:28:38 +08:00
|
|
|
. "src.elv.sh/pkg/eval"
|
|
|
|
"src.elv.sh/pkg/testutil"
|
2020-09-03 13:48:39 +08:00
|
|
|
|
2021-01-27 09:28:38 +08:00
|
|
|
. "src.elv.sh/pkg/eval/evaltest"
|
2020-08-18 13:40:30 +08:00
|
|
|
)
|
|
|
|
|
2022-06-20 06:56:18 +08:00
|
|
|
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)
|
|
|
|
})
|
2020-08-18 13:40:30 +08:00
|
|
|
|
|
|
|
Test(t,
|
2021-01-02 09:45:55 +08:00
|
|
|
That(`sleep 1s`).Throws(ErrInterrupted, "sleep 1s"),
|
2020-08-18 13:40:30 +08:00
|
|
|
)
|
|
|
|
}
|