You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/08/09 06:31:44 UTC

[plc4x] 01/04: test(plc4go): fix race conditions in testutils

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit ef94bf5668193c4daf72d7ae5d783c7c0568541b
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue Aug 8 16:06:35 2023 +0200

    test(plc4go): fix race  conditions in testutils
---
 plc4go/spi/testutils/TestUtils.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/plc4go/spi/testutils/TestUtils.go b/plc4go/spi/testutils/TestUtils.go
index 564fed7655..57fdf32ab6 100644
--- a/plc4go/spi/testutils/TestUtils.go
+++ b/plc4go/spi/testutils/TestUtils.go
@@ -29,6 +29,7 @@ import (
 	"runtime/debug"
 	"strconv"
 	"strings"
+	"sync"
 	"testing"
 	"time"
 
@@ -225,11 +226,15 @@ func ProduceTestingLogger(t *testing.T) zerolog.Logger {
 	if highLogPrecision {
 		logger = logger.With().Timestamp().Logger()
 	}
-	zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
+	stackSetter.Do(func() {
+		zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
+	})
 	logger = logger.With().Stack().Logger()
 	return logger
 }
 
+var stackSetter sync.Once
+
 // EnrichOptionsWithOptionsForTesting appends options useful for testing to config.WithOption s
 func EnrichOptionsWithOptionsForTesting(t *testing.T, _options ...options.WithOption) []options.WithOption {
 	if extractedTraceWorkers, found := options.ExtractTracerWorkers(_options...); found {