From 2b48cfca086d34fedf78aa73fbfff68817bc3256 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Tue, 28 May 2013 16:51:47 -0400 Subject: [PATCH] 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 --- cmd/vet/vet_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/vet/vet_test.go b/cmd/vet/vet_test.go index f9be1b3f1d..820e60c459 100644 --- a/cmd/vet/vet_test.go +++ b/cmd/vet/vet_test.go @@ -51,14 +51,17 @@ func TestVet(t *testing.T) { "-printfuncs=Warn:1,Warnf:1", } 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) { - c.Stdout = os.Stdout - c.Stderr = os.Stderr - err := c.Run() +func run(c *exec.Cmd, t *testing.T) bool { + output, err := c.CombinedOutput() + os.Stderr.Write(output) if err != nil { 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 }