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

@@ -21,6 +21,7 @@ import (
"os"
"regexp"
"runtime"
"sync/atomic"
"time"
"github.com/gohugoio/hugo/common/terminal"
@@ -31,7 +32,7 @@ import (
var (
// Counts ERROR logs to the global jww logger.
GlobalErrorCounter *jww.Counter
PanicOnWarning bool
PanicOnWarning atomic.Bool
)
func init() {
@@ -136,14 +137,14 @@ const panicOnWarningMessage = "Warning trapped. Remove the --panicOnWarning flag
func (l *logger) Warnf(format string, v ...any) {
l.WARN.Printf(format, v...)
if PanicOnWarning {
if PanicOnWarning.Load() {
panic(panicOnWarningMessage)
}
}
func (l *logger) Warnln(v ...any) {
l.WARN.Println(v...)
if PanicOnWarning {
if PanicOnWarning.Load() {
panic(panicOnWarningMessage)
}
}