mirror of https://github.com/golang/go.git
cmd/vet: reenable cgo test
The reason the 386 trybot was happy but 'GOARCH=386 go test cmd/vet' was not is that CgoEnabled defaults to false in a cross build; I have no idea why. Now we ask the go command for the effective value so that the test works in both cases. Also, remove stale comment. Fixes #28829 Change-Id: I1210af34da6986f47924059de5c1f08b2824ace9 Reviewed-on: https://go-review.googlesource.com/c/149958 Run-TryBot: Alan Donovan <adonovan@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
b7ba523355
commit
55e1fc930b
|
|
@ -70,11 +70,6 @@ func vetCmd(t *testing.T, args ...string) *exec.Cmd {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestVet is equivalent to running this:
|
|
||||||
// go build -o ./testvet
|
|
||||||
// errorCheck the output of ./testvet -printfuncs='Warn:1,Warnf:1' testdata/*.go testdata/*.s
|
|
||||||
// rm ./testvet
|
|
||||||
//
|
|
||||||
func TestVet(t *testing.T) {
|
func TestVet(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
Build(t)
|
Build(t)
|
||||||
|
|
@ -106,9 +101,8 @@ func TestVet(t *testing.T) {
|
||||||
t.Run(pkg, func(t *testing.T) {
|
t.Run(pkg, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
// Skip for now, pending investigation.
|
// Skip cgo test on platforms without cgo.
|
||||||
if pkg == "cgo" {
|
if pkg == "cgo" && !cgoEnabled(t) {
|
||||||
t.Skip("cgo test disabled -- github.com/golang/go/issues/28829")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,6 +131,17 @@ func TestVet(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cgoEnabled(t *testing.T) bool {
|
||||||
|
// Don't trust build.Default.CgoEnabled as it is false for
|
||||||
|
// cross-builds unless CGO_ENABLED is explicitly specified.
|
||||||
|
// That's fine for the builders, but causes commands like
|
||||||
|
// 'GOARCH=386 go test .' to fail.
|
||||||
|
// Instead, we ask the go command.
|
||||||
|
cmd := exec.Command(testenv.GoToolPath(t), "list", "-f", "{{context.CgoEnabled}}")
|
||||||
|
out, _ := cmd.CombinedOutput()
|
||||||
|
return string(out) == "true\n"
|
||||||
|
}
|
||||||
|
|
||||||
func errchk(c *exec.Cmd, files []string, t *testing.T) {
|
func errchk(c *exec.Cmd, files []string, t *testing.T) {
|
||||||
output, err := c.CombinedOutput()
|
output, err := c.CombinedOutput()
|
||||||
if _, ok := err.(*exec.ExitError); !ok {
|
if _, ok := err.(*exec.ExitError); !ok {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue