Skip to content

Commit c9ef5b8

Browse files
committed
mcp: fix more flaky tests
1 parent c2458f9 commit c9ef5b8

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

mcp/cmd_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ func TestServerRunContextCancel(t *testing.T) {
122122
}
123123

124124
func TestServerInterrupt(t *testing.T) {
125-
t.Skip()
126125
if runtime.GOOS == "windows" {
127126
t.Skip("requires POSIX signals")
128127
}
@@ -134,10 +133,11 @@ func TestServerInterrupt(t *testing.T) {
134133
cmd := createServerCommand(t, "default")
135134

136135
client := mcp.NewClient(testImpl, nil)
137-
_, err := client.Connect(ctx, &mcp.CommandTransport{Command: cmd}, nil)
136+
session, err := client.Connect(ctx, &mcp.CommandTransport{Command: cmd}, nil)
138137
if err != nil {
139138
t.Fatal(err)
140139
}
140+
t.Cleanup(func() { session.Close() })
141141

142142
// get a signal when the server process exits
143143
onExit := make(chan struct{})
@@ -208,7 +208,6 @@ func TestStdioContextCancellation(t *testing.T) {
208208
}
209209

210210
func TestCmdTransport(t *testing.T) {
211-
t.Skip()
212211
requireExec(t)
213212

214213
ctx, cancel := context.WithCancel(context.Background())

mcp/mcp_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,6 @@ func TestEndToEnd(t *testing.T) {
464464
})
465465

466466
t.Run("resource_subscriptions", func(t *testing.T) {
467-
t.Skip("TODO")
468467
err := cs.Subscribe(ctx, &SubscribeParams{
469468
URI: "test",
470469
})

mcp/streamable_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
)
3535

3636
func TestStreamableTransports(t *testing.T) {
37-
t.Skip()
3837
// This test checks that the streamable server and client transports can
3938
// communicate.
4039

@@ -271,7 +270,6 @@ func TestStreamableServerShutdown(t *testing.T) {
271270
// uses a proxy that is killed and restarted to simulate a recoverable network
272271
// outage.
273272
func TestClientReplay(t *testing.T) {
274-
t.Skip()
275273
for _, test := range []clientReplayTest{
276274
{"default", 0, true},
277275
{"no retries", -1, false},
@@ -344,7 +342,7 @@ func testClientReplay(t *testing.T, test clientReplayTest) {
344342
if err != nil {
345343
t.Fatalf("client.Connect() failed: %v", err)
346344
}
347-
defer clientSession.Close()
345+
t.Cleanup(func() { clientSession.Close() })
348346

349347
var (
350348
wg sync.WaitGroup
@@ -386,7 +384,7 @@ func testClientReplay(t *testing.T, test clientReplayTest) {
386384

387385
restartedProxy := &http.Server{Handler: proxyHandler}
388386
go restartedProxy.Serve(listener)
389-
defer restartedProxy.Close()
387+
t.Cleanup(func() { restartedProxy.Close() })
390388

391389
wg.Wait()
392390

0 commit comments

Comments
 (0)