sdk: also print test agent logs in verbose mode (#8616)

This commit is contained in:
R.B. Boyer 2020-09-04 11:24:11 -05:00 committed by GitHub
parent b57a5b4911
commit a14a31ccf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -25,8 +25,8 @@ func LoggerWithOutput(t testing.TB, output io.Writer) hclog.InterceptLogger {
var sendTestLogsToStdout = os.Getenv("NOLOGBUFFER") == "1" var sendTestLogsToStdout = os.Getenv("NOLOGBUFFER") == "1"
// NewLogBuffer returns an io.Writer which buffers all writes. When the test // NewLogBuffer returns an io.Writer which buffers all writes. When the test
// ends, t.Failed is checked. If the test has failed all log output is printed // ends, t.Failed is checked. If the test has failed or has been run in verbose
// to stdout. // mode all log output is printed to stdout.
// //
// Set the env var NOLOGBUFFER=1 to disable buffering, resulting in all log // Set the env var NOLOGBUFFER=1 to disable buffering, resulting in all log
// output being written immediately to stdout. // output being written immediately to stdout.
@ -36,7 +36,7 @@ func NewLogBuffer(t CleanupT) io.Writer {
} }
buf := &logBuffer{buf: new(bytes.Buffer)} buf := &logBuffer{buf: new(bytes.Buffer)}
t.Cleanup(func() { t.Cleanup(func() {
if t.Failed() { if t.Failed() || testing.Verbose() {
buf.Lock() buf.Lock()
defer buf.Unlock() defer buf.Unlock()
buf.buf.WriteTo(os.Stdout) buf.buf.WriteTo(os.Stdout)