main: rework the way the mock logger is passed
Pass the mock logger directly to `run()` instead of mocking `logrus.New`. Doing the later leads to a data race when multiple parallel tests modify the (global) `var logrusNew logrus.New`. Thanks to Tomas Hozza for reporting.
This commit is contained in:
parent
95b4a9e250
commit
8ebefbdbc9
3 changed files with 7 additions and 24 deletions
|
|
@ -4,9 +4,6 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
logrusTest "github.com/sirupsen/logrus/hooks/test"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -15,19 +12,6 @@ var (
|
|||
HandleIncludedSources = handleIncludedSources
|
||||
)
|
||||
|
||||
func MockLogger() (hook *logrusTest.Hook, restore func()) {
|
||||
saved := logrusNew
|
||||
logger, hook := logrusTest.NewNullLogger()
|
||||
logrusNew = func() *logrus.Logger {
|
||||
return logger
|
||||
}
|
||||
logger.SetLevel(logrus.DebugLevel)
|
||||
|
||||
return hook, func() {
|
||||
logrusNew = saved
|
||||
}
|
||||
}
|
||||
|
||||
func MockOsbuildBinary(t *testing.T, new string) (restore func()) {
|
||||
t.Helper()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue