mcp: use synctest for timing-dependent tests (#756)

Converted timing-based tests to use Go 1.25's synctest for instant,
deterministic execution with simulated time.

Moved converted tests to *_go125_test.go files. Tests using real I/O
(exec.Command, httptest) remain timing-based as they require actual
system operations.

Fixes #680

---------

Co-authored-by: i586147 <lakshana.goswami@sap.com>
This commit is contained in:
original-owl 2026-02-10 15:10:11 +05:30 • committed by GitHub
commit 86f8415122
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -76,6 +76,7 @@ func runCancelContextServer() {
}
}
// TODO: remove this test when Go 1.24 support is dropped (use go1.25 synctest version).
func TestServerRunContextCancel(t *testing.T) {
server := mcp.NewServer(&mcp.Implementation{Name: "greeter", Version: "v0.0.1"}, nil)
mcp.AddTool(server, &mcp.Tool{Name: "greet", Description: "say hi"}, SayHi)
@ -107,7 +108,7 @@ func TestServerRunContextCancel(t *testing.T) {
cancel()
// wait for the server to exit
// TODO: use synctest when availble
// TODO: use synctest when available
select {
case <-time.After(5 * time.Second):
t.Fatal("server did not exit after context cancellation")