diff options
author | Bjørn Erik Pedersen <[email protected]> | 2023-03-14 12:18:42 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-03-14 12:18:42 +0100 |
commit | 0fbab7cbc5a0b57ec875858111b178160d18acb5 (patch) | |
tree | ac718d00f98bf7df0cef4d82d3e8db527f85560d /helpers | |
parent | f5eddf89bf6c8ea9571c16f301f6b449259e6187 (diff) | |
download | hugo-0fbab7cbc5a0b57ec875858111b178160d18acb5.tar.gz hugo-0fbab7cbc5a0b57ec875858111b178160d18acb5.zip |
commands: Fix data race in test
Note that this is a test fix only.
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/general.go | 2 | ||||
-rw-r--r-- | helpers/general_test.go | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/helpers/general.go b/helpers/general.go index c8a676829..920376227 100644 --- a/helpers/general.go +++ b/helpers/general.go @@ -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) diff --git a/helpers/general_test.go b/helpers/general_test.go index 95d9c5461..b2ee03f15 100644 --- a/helpers/general_test.go +++ b/helpers/general_test.go @@ -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) }() } |