mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
cmd/vet: use length of output from errchk to check PASS/FAIL
errchk is itself a FAIL: it doesn't exit non-zero on error! R=golang-dev, iant CC=golang-dev https://golang.org/cl/9842044
This commit is contained in:
parent
c7f7fa1381
commit
2b48cfca08
@ -51,14 +51,17 @@ func TestVet(t *testing.T) {
|
|||||||
"-printfuncs=Warn:1,Warnf:1",
|
"-printfuncs=Warn:1,Warnf:1",
|
||||||
}
|
}
|
||||||
cmd = exec.Command(errchk, append(flags, files...)...)
|
cmd = exec.Command(errchk, append(flags, files...)...)
|
||||||
run(cmd, t)
|
if !run(cmd, t) {
|
||||||
|
t.Fatal("vet command failed")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func run(c *exec.Cmd, t *testing.T) {
|
func run(c *exec.Cmd, t *testing.T) bool {
|
||||||
c.Stdout = os.Stdout
|
output, err := c.CombinedOutput()
|
||||||
c.Stderr = os.Stderr
|
os.Stderr.Write(output)
|
||||||
err := c.Run()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
// Errchk delights by not returning non-zero status if it finds errors, so we look at the output.
|
||||||
|
return c.ProcessState.Success() && len(output) == 0
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user