diff options
author | zeripath <art27@cantab.net> | 2019-04-11 12:49:49 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2019-04-11 19:49:49 +0800 |
commit | c02c6a144fb26c44f4c7cfe9331daa6218a51cc8 (patch) | |
tree | 011298f8ee4809a6a8318409d7a349596424a90c /integrations/testlogger.go | |
parent | 346036d47ff8c8f64e9843eac4e02c87a14e94a6 (diff) | |
download | gitea-c02c6a144fb26c44f4c7cfe9331daa6218a51cc8.tar.gz gitea-c02c6a144fb26c44f4c7cfe9331daa6218a51cc8.zip |
Fix race in integration testlogger (#6556)
* Fix race in logger
* At testing end drop the reference to the last test.
Diffstat (limited to 'integrations/testlogger.go')
-rw-r--r-- | integrations/testlogger.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/integrations/testlogger.go b/integrations/testlogger.go index 9ee28d2ead..c50daead9b 100644 --- a/integrations/testlogger.go +++ b/integrations/testlogger.go @@ -33,6 +33,27 @@ func (w *testLoggerWriterCloser) Write(p []byte) (int, error) { if len(p) > 0 && p[len(p)-1] == '\n' { p = p[:len(p)-1] } + + defer func() { + err := recover() + if err == nil { + return + } + var errString string + errErr, ok := err.(error) + if ok { + errString = errErr.Error() + } else { + errString, ok = err.(string) + } + if !ok { + panic(err) + } + if !strings.HasPrefix(errString, "Log in goroutine after ") { + panic(err) + } + }() + w.t.Log(string(p)) return len(p), nil } |