Skip to content

Commit 1f1ca2f

Browse files
committed
terminal: move signal shutdown test to a unix only file
1 parent fe7b583 commit 1f1ca2f

2 files changed

Lines changed: 29 additions & 17 deletions

File tree

shutdown_test.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package terminal
22

33
import (
4-
"syscall"
54
"testing"
65
"time"
76

@@ -66,19 +65,3 @@ func TestShutdownSourceChannelStable(t *testing.T) {
6665

6766
require.Equal(t, first, s.ShutdownChannel())
6867
}
69-
70-
// TestShutdownSourceSignal checks that an OS termination signal closes the
71-
// shutdown channel. The signal is captured by signal.Notify, so it does not
72-
// terminate the test process.
73-
func TestShutdownSourceSignal(t *testing.T) {
74-
// Not parallel: this sends a process-wide signal, which every
75-
// registered shutdownSource would observe.
76-
s := newShutdownSource()
77-
defer s.Stop()
78-
79-
requireOpen(t, s.ShutdownChannel())
80-
81-
require.NoError(t, syscall.Kill(syscall.Getpid(), syscall.SIGTERM))
82-
83-
waitClosed(t, s.ShutdownChannel())
84-
}

shutdown_unix_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//go:build !windows
2+
3+
package terminal
4+
5+
import (
6+
"syscall"
7+
"testing"
8+
9+
"github.com/stretchr/testify/require"
10+
)
11+
12+
// TestShutdownSourceSignal checks that an OS termination signal closes the
13+
// shutdown channel. The signal is captured by signal.Notify, so it does not
14+
// terminate the test process.
15+
//
16+
// This lives in a Unix-only file because syscall.Kill is not available on
17+
// Windows.
18+
func TestShutdownSourceSignal(t *testing.T) {
19+
// Not parallel: this sends a process-wide signal, which every registered
20+
// shutdownSource would observe.
21+
s := newShutdownSource()
22+
defer s.Stop()
23+
24+
requireOpen(t, s.ShutdownChannel())
25+
26+
require.NoError(t, syscall.Kill(syscall.Getpid(), syscall.SIGTERM))
27+
28+
waitClosed(t, s.ShutdownChannel())
29+
}

0 commit comments

Comments
 (0)