File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ //go:build !windows
2+
3+ package process
4+
5+ import (
6+ "os"
7+ "os/signal"
8+ "testing"
9+ "time"
10+
11+ "github.com/stretchr/testify/require"
12+ )
13+
14+ func TestSendInterrupt (t * testing.T ) {
15+ sigChan := make (chan os.Signal , 1 )
16+ signal .Notify (sigChan , os .Interrupt )
17+ defer signal .Stop (sigChan )
18+
19+ SendInterrupt ()
20+
21+ select {
22+ case sig := <- sigChan :
23+ require .Equal (t , os .Interrupt , sig )
24+ case <- time .After (2 * time .Second ):
25+ t .Fatal ("timeout waiting for interrupt signal" )
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ //go:build windows
2+
3+ package process
4+
5+ import "testing"
6+
7+ func TestSendInterrupt (t * testing.T ) {
8+ // On Windows CI (GitHub Actions), GenerateConsoleCtrlEvent may not work
9+ // as expected without a proper console attached.
10+ // This test verifies the function doesn't panic and the syscall loads correctly.
11+ defer func () {
12+ if r := recover (); r != nil {
13+ t .Fatalf ("SendInterrupt panicked: %v" , r )
14+ }
15+ }()
16+
17+ // Just verify it doesn't crash - the actual signal delivery
18+ // depends on console configuration which varies in CI
19+ SendInterrupt ()
20+ }
You can’t perform that action at this time.
0 commit comments