From 831af6016180f470898de51415c12628fc4aa0a2 Mon Sep 17 00:00:00 2001 From: Fred Date: Thu, 29 Feb 2024 13:18:29 +0100 Subject: [PATCH 1/3] write wrapper for Log and Logf functions --- suite/suite.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/suite/suite.go b/suite/suite.go index 18443a91c..177d19040 100644 --- a/suite/suite.go +++ b/suite/suite.go @@ -77,6 +77,23 @@ func (suite *Suite) Assert() *assert.Assertions { return suite.Assertions } +// Logf wraps call to testing.T Logf function. This is erquivalent to calling +// s.T().Logf(format, args). +func (suite *Suite) Logf(format string, args ...interface{}) { + suite.mu.RLock() + defer suite.mu.RUnlock() + suite.T().Logf(format, args...) +} + +// Log wraps call to testing.T Log function. This is erquivalent to calling +// s.T().Log(message). +func (suite *Suite) Log(args ...interface{}) { + suite.mu.RLock() + defer suite.mu.RUnlock() + suite.T().Log(args...) +} + + func recoverAndFailOnPanic(t *testing.T) { t.Helper() r := recover() From 246f7a38294bd749838d7f701efb86410dfd3f63 Mon Sep 17 00:00:00 2001 From: Fred Date: Sat, 2 Mar 2024 20:17:28 +0100 Subject: [PATCH 2/3] fix style --- suite/suite.go | 1 - 1 file changed, 1 deletion(-) diff --git a/suite/suite.go b/suite/suite.go index 177d19040..3c6d67591 100644 --- a/suite/suite.go +++ b/suite/suite.go @@ -93,7 +93,6 @@ func (suite *Suite) Log(args ...interface{}) { suite.T().Log(args...) } - func recoverAndFailOnPanic(t *testing.T) { t.Helper() r := recover() From af827760577a807de25e44dde9642d3db06952b0 Mon Sep 17 00:00:00 2001 From: Fred Date: Wed, 6 Mar 2024 09:15:53 +0100 Subject: [PATCH 3/3] review comment --- suite/suite.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/suite/suite.go b/suite/suite.go index 3c6d67591..b6c157485 100644 --- a/suite/suite.go +++ b/suite/suite.go @@ -82,7 +82,7 @@ func (suite *Suite) Assert() *assert.Assertions { func (suite *Suite) Logf(format string, args ...interface{}) { suite.mu.RLock() defer suite.mu.RUnlock() - suite.T().Logf(format, args...) + suite.t.Logf(format, args...) } // Log wraps call to testing.T Log function. This is erquivalent to calling @@ -90,7 +90,7 @@ func (suite *Suite) Logf(format string, args ...interface{}) { func (suite *Suite) Log(args ...interface{}) { suite.mu.RLock() defer suite.mu.RUnlock() - suite.T().Log(args...) + suite.t.Log(args...) } func recoverAndFailOnPanic(t *testing.T) {