Combine stdout and stderr in all_test.go

GTest sends its output to stdout, not stderr. Merge them in the runner
(though eventually we'll teach the bots to run the GTest targets
directly) so we don't lose it.

BUG=129

Change-Id: I7c499cd9572f46f97bd4b7f6c6c9beca057625f2
Reviewed-on: https://boringssl-review.googlesource.com/13624
Reviewed-by: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
David Benjamin 2017-02-04 11:14:57 -05:00 committed by CQ bot account: commit-bot@chromium.org
parent 8df6766d01
commit 634b0e3c73

View File

@ -186,10 +186,9 @@ func runTestOnce(test test, mallocNumToFail int64) (passed bool, err error) {
} else {
cmd = exec.Command(prog, args...)
}
var stdoutBuf bytes.Buffer
var stderrBuf bytes.Buffer
cmd.Stdout = &stdoutBuf
cmd.Stderr = &stderrBuf
var outBuf bytes.Buffer
cmd.Stdout = &outBuf
cmd.Stderr = &outBuf
if mallocNumToFail >= 0 {
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, "MALLOC_NUMBER_TO_FAIL="+strconv.FormatInt(mallocNumToFail, 10))
@ -208,13 +207,12 @@ func runTestOnce(test test, mallocNumToFail int64) (passed bool, err error) {
return false, errMoreMallocs
}
}
fmt.Print(string(stderrBuf.Bytes()))
fmt.Print(string(outBuf.Bytes()))
return false, err
}
fmt.Print(string(stderrBuf.Bytes()))
// Account for Windows line-endings.
stdout := bytes.Replace(stdoutBuf.Bytes(), []byte("\r\n"), []byte("\n"), -1)
stdout := bytes.Replace(outBuf.Bytes(), []byte("\r\n"), []byte("\n"), -1)
if bytes.HasSuffix(stdout, []byte("PASS\n")) &&
(len(stdout) == 5 || stdout[len(stdout)-6] == '\n') {
@ -228,6 +226,7 @@ func runTestOnce(test test, mallocNumToFail int64) (passed bool, err error) {
return true, nil
}
fmt.Print(string(outBuf.Bytes()))
return false, nil
}