elvish/pkg/daemon/server_unix_test.go
Qi Xiao 8e117a2875 Merge pkg/daemon/client into pkg/daemon.
Also merge and rename files to make the client/server separation clearer.
2021-09-30 23:37:36 +01:00

31 lines
649 B
Go

//go:build !windows && !plan9 && !js
// +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)
startServerSigCh(t, nil)
p, err := os.FindProcess(os.Getpid())
if err != nil {
t.Fatalf("FindProcess: %v", err)
}
p.Signal(sig)
// startServerSigCh will wait for server to terminate at cleanup
}