Skip to content

Commit 4f13866

Browse files
madelinekalilgopherbot
authored andcommitted
gopls/internal/cmd: disable mcp tests when fsnotify not supported
These tests require fsnotify, which is not supported on certain os, so we should disable them. Fixes golang/go#74580 Change-Id: I73010366e672218b7247146b88077ebee96ff1c1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/688155 Reviewed-by: Hongxiang Jiang <[email protected]> Auto-Submit: Hongxiang Jiang <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 8d1f71a commit 4f13866

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

gopls/internal/cmd/mcp_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"os"
1313
"os/exec"
1414
"path/filepath"
15+
"runtime"
1516
"strconv"
1617
"strings"
1718
"testing"
@@ -23,6 +24,10 @@ import (
2324

2425
func TestMCPCommandStdio(t *testing.T) {
2526
// Test that the headless MCP subcommand works, and recognizes file changes.
27+
if !(supportsFsnotify(runtime.GOOS)) {
28+
// See golang/go#74580
29+
t.Skipf(`skipping on %s; fsnotify is not supported`, runtime.GOOS)
30+
}
2631
testenv.NeedsExec(t) // stdio transport uses execve(2)
2732
tree := writeTree(t, `
2833
-- go.mod --
@@ -95,6 +100,10 @@ const B = 2
95100

96101
func TestMCPCommandLogging(t *testing.T) {
97102
// Test that logging flags for headless MCP subcommand work as intended.
103+
if !(supportsFsnotify(runtime.GOOS)) {
104+
// See golang/go#74580
105+
t.Skipf(`skipping on %s; fsnotify is not supported`, runtime.GOOS)
106+
}
98107
testenv.NeedsExec(t) // stdio transport uses execve(2)
99108

100109
tests := []struct {
@@ -155,6 +164,10 @@ package p
155164
}
156165

157166
func TestMCPCommandHTTP(t *testing.T) {
167+
if !(supportsFsnotify(runtime.GOOS)) {
168+
// See golang/go#74580
169+
t.Skipf(`skipping on %s; fsnotify is not supported`, runtime.GOOS)
170+
}
158171
testenv.NeedsExec(t)
159172
tree := writeTree(t, `
160173
-- go.mod --
@@ -271,3 +284,8 @@ func getRandomPort() int {
271284
defer listener.Close()
272285
return listener.Addr().(*net.TCPAddr).Port
273286
}
287+
288+
// supportsFsnotify returns true if fsnotify supports the os.
289+
func supportsFsnotify(os string) bool {
290+
return os == "darwin" || os == "linux" || os == "windows"
291+
}

0 commit comments

Comments
 (0)