(t *testing.T)
| 118 | } |
| 119 | |
| 120 | func TestServerInterrupt(t *testing.T) { |
| 121 | if runtime.GOOS == "windows" { |
| 122 | t.Skip("requires POSIX signals") |
| 123 | } |
| 124 | requireExec(t) |
| 125 | |
| 126 | t.Log("Starting server command") |
| 127 | cmd := createServerCommand(t, "default") |
| 128 | |
| 129 | client := mcp.NewClient(testImpl, nil) |
| 130 | t.Log("Connecting to server") |
| 131 | |
| 132 | ctx := context.Background() |
| 133 | session, err := client.Connect(ctx, &mcp.CommandTransport{Command: cmd}, nil) |
| 134 | if err != nil { |
| 135 | t.Fatal(err) |
| 136 | } |
| 137 | |
| 138 | t.Log("Send a signal to the server process to terminate it") |
| 139 | if err := cmd.Process.Signal(os.Interrupt); err != nil { |
| 140 | t.Fatal(err) |
| 141 | } |
| 142 | |
| 143 | t.Log("Closing client session so server can exit immediately") |
| 144 | session.Close() |
| 145 | |
| 146 | t.Log("Wait for process to terminate after interrupt signal") |
| 147 | _, err = cmd.Process.Wait() |
| 148 | if err == nil { |
| 149 | t.Errorf("unexpected error: %v", err) |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | func TestStdioContextCancellation(t *testing.T) { |
| 154 | if runtime.GOOS == "windows" { |
nothing calls this directly
no test coverage detected
searching dependent graphs…