diff --git a/main.go b/main.go index c6b2ad1b..b6b22e31 100644 --- a/main.go +++ b/main.go @@ -235,8 +235,9 @@ func Test(pkgName string, stdout, stderr io.Writer, options *compileopts.Options flags = append(flags, "-test.benchmem") } + buf := bytes.Buffer{} passed := false - err = buildAndRun(pkgName, config, os.Stdout, flags, nil, 0, func(cmd *exec.Cmd, result builder.BuildResult) error { + err = buildAndRun(pkgName, config, &buf, flags, nil, 0, func(cmd *exec.Cmd, result builder.BuildResult) error { if testCompileOnly || outpath != "" { // Write test binary to the specified file name. if outpath == "" { @@ -308,8 +309,12 @@ func Test(pkgName string, stdout, stderr io.Writer, options *compileopts.Options importPath := strings.TrimSuffix(result.ImportPath, ".test") passed = err == nil if passed { + if testVerbose { + buf.WriteTo(stdout) + } fmt.Fprintf(stdout, "ok \t%s\t%.3fs\n", importPath, duration.Seconds()) } else { + buf.WriteTo(stdout) fmt.Fprintf(stdout, "FAIL\t%s\t%.3fs\n", importPath, duration.Seconds()) } if _, ok := err.(*exec.ExitError); ok { @@ -1657,7 +1662,6 @@ func main() { wg.Wait() close(fail) if _, fail := <-fail; fail { - fmt.Println("FAIL") os.Exit(1) } case "monitor": diff --git a/src/testing/testing.go b/src/testing/testing.go index a458f267..c3d4b4ba 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -449,9 +449,7 @@ func (m *M) Run() (code int) { fmt.Println("FAIL") m.exitCode = 1 } else { - if flagVerbose { - fmt.Println("PASS") - } + fmt.Println("PASS") m.exitCode = 0 } return