The testing package silently drops t.Log messages that are made by a goroutine after the test has completed. For example, the following test passes and logs nothing.
This should be fixed by extending the code added in 1.12 that panics if a goroutine logs after a test has completed to not silently discard the log message. The silent discarding is occurring in the current code because every test runs in a parent context, and the output accumulated by the parent context is discarded.
package main
import (
"testing"
"time"
)
func TestLateLog(t *testing.T) {
c := make(chan bool)
go func() {
<-c
time.Sleep(time.Millisecond)
t.Log("log after test")
}()
close(c)
}
The testing package silently drops
t.Logmessages that are made by a goroutine after the test has completed. For example, the following test passes and logs nothing.This should be fixed by extending the code added in 1.12 that panics if a goroutine logs after a test has completed to not silently discard the log message. The silent discarding is occurring in the current code because every test runs in a parent context, and the output accumulated by the parent context is discarded.