From ef70c3bf50dbd0cc7c8171186794d41c7cd5b146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sun, 2 Jan 2022 20:29:34 +0100 Subject: [PATCH] Race --- hugolib/integrationtest_builder.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/hugolib/integrationtest_builder.go b/hugolib/integrationtest_builder.go index 315ee86ab66..b64f895eb7f 100644 --- a/hugolib/integrationtest_builder.go +++ b/hugolib/integrationtest_builder.go @@ -69,11 +69,23 @@ type IntegrationTestBuilder struct { buildCount int counters *testCounters - logBuff bytes.Buffer + logBuff lockingBuffer builderInit sync.Once } +type lockingBuffer struct { + sync.Mutex + bytes.Buffer +} + +func (b *lockingBuffer) Write(p []byte) (n int, err error) { + b.Lock() + n, err = b.Buffer.Write(p) + b.Unlock() + return +} + func (s *IntegrationTestBuilder) AssertLogContains(text string) { s.Helper() s.Assert(s.logBuff.String(), qt.Contains, text)