Skip to content

Commit 142b776

Browse files
committed
go/packages: fix TestCgoOption to work on Windows
The cgoLookupHost function isn't defined on Windows in the net package in the standard library, but the addrinfoErrno type is (and is also defined on Unix). Look for that instead. Fixes golang/go#35839 Change-Id: I5a3b18d51209549002add1397b8f46de9ef2ee5a Reviewed-on: https://go-review.googlesource.com/c/tools/+/212478 Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent c734170 commit 142b776

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

go/packages/stdlib_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ func TestCgoOption(t *testing.T) {
9696
// The test also loads the actual file to verify that the
9797
// object is indeed defined at that location.
9898
for _, test := range []struct {
99-
pkg, name, genericFile string
99+
pkg, declKeyword, name, genericFile string
100100
}{
101-
{"net", "cgoLookupHost", "cgo_stub.go"},
102-
{"os/user", "current", "lookup_stubs.go"},
101+
{"net", "type", "addrinfoErrno", "cgo_stub.go"},
102+
{"os/user", "func", "current", "lookup_stubs.go"},
103103
} {
104104
cfg := &packages.Config{Mode: packages.LoadSyntax}
105105
pkgs, err := packages.Load(cfg, test.pkg)
@@ -134,7 +134,7 @@ func TestCgoOption(t *testing.T) {
134134
}
135135
line := string(bytes.Split(b, []byte("\n"))[posn.Line-1])
136136
// Don't assume posn.Column is accurate.
137-
if !strings.Contains(line, "func "+test.name) {
137+
if !strings.Contains(line, test.declKeyword+" "+test.name) {
138138
t.Errorf("%s: %s not declared here (looking at %q)", posn, obj, line)
139139
}
140140
}

0 commit comments

Comments
 (0)