elvish/pkg/daemon/server_unix_test.go
Qi Xiao f7cb556d9b Require Go 1.18.
- Run "go fix" to remove legacy build tags

- Use staticcheck@master until it has a release that supports Go 1.18

- Turn off autocrlf for Windows tasks
2022-03-20 15:28:23 +00:00

30 lines
656 B
Go

//go:build !windows && !plan9 && !js
package daemon
import (
"os"
"syscall"
"testing"
)
func TestProgram_QuitsOnSystemSignal_SIGINT(t *testing.T) {
testProgram_QuitsOnSystemSignal(t, syscall.SIGINT)
}
func TestProgram_QuitsOnSystemSignal_SIGTERM(t *testing.T) {
testProgram_QuitsOnSystemSignal(t, syscall.SIGTERM)
}
func testProgram_QuitsOnSystemSignal(t *testing.T, sig os.Signal) {
t.Helper()
setup(t)
startServerOpts(t, cli("sock", "db"), ServeOpts{Signals: nil})
p, err := os.FindProcess(os.Getpid())
if err != nil {
t.Fatalf("FindProcess: %v", err)
}
p.Signal(sig)
// startServerOpts will wait for server to terminate at cleanup
}