commands: Fix data race in test

Note that this is a test fix only.
This commit is contained in:
Bjørn Erik Pedersen
2023-03-14 12:18:42 +01:00
parent f5eddf89bf
commit 0fbab7cbc5
6 changed files with 15 additions and 11 deletions

View File

@@ -415,7 +415,7 @@ func Deprecated(item, alternative string, err bool) {
DistinctErrorLog.Errorf("%s is deprecated and will be removed in Hugo %s. %s", item, hugo.CurrentVersion.Next().ReleaseVersion(), alternative)
} else {
var warnPanicMessage string
if !loggers.PanicOnWarning {
if !loggers.PanicOnWarning.Load() {
warnPanicMessage = "\n\nRe-run Hugo with the flag --panicOnWarning to get a better error message."
}
DistinctWarnLog.Warnf("%s is deprecated and will be removed in a future release. %s%s", item, alternative, warnPanicMessage)

View File

@@ -65,10 +65,10 @@ func TestDistinctLoggerDoesNotLockOnWarningPanic(t *testing.T) {
// Set PanicOnWarning to true to reproduce issue 9380
// Ensure global variable loggers.PanicOnWarning is reset to old value after test
if loggers.PanicOnWarning == false {
loggers.PanicOnWarning = true
if !loggers.PanicOnWarning.Load() {
loggers.PanicOnWarning.Store(true)
defer func() {
loggers.PanicOnWarning = false
loggers.PanicOnWarning.Store(false)
}()
}