Skip to content

Commit 9cb3942

Browse files
committed
✨ [pkg/test] Add error messages.
Now, whenever a stage fails or the test context expires, a t.Errorf() call is made. Signed-off-by: Steffen Rattay <steffen@perun.network>
1 parent bfcdcaf commit 9cb3942

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/test/concurrent.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ func (t *ConcurrentT) Wait(names ...string) {
190190
stage := t.getStage(name)
191191
select {
192192
case <-t.ctx.Done():
193+
t.failNowMutex.Lock()
194+
t.t.Errorf("Wait for stage %s: %v", name, t.ctx.Err())
195+
t.failNowMutex.Unlock()
193196
t.FailNow()
194197
case <-stage.wg.WaitCh():
195198
if stage.failed.IsSet() {
@@ -245,12 +248,17 @@ func (t *ConcurrentT) StageN(name string, goroutines int, fn func(ConcT)) {
245248

246249
// If it did not terminate, just abort the test.
247250
if !ok {
251+
t.failNowMutex.Lock()
252+
t.t.Errorf("Stage %s: %v", name, t.ctx.Err())
253+
t.failNowMutex.Unlock()
248254
t.FailNow()
249255
}
250256

251257
// If it is a panic or Goexit from certain contexts, print stack trace.
252258
if _, ok := abort.(*Panic); ok || shouldPrintStack(abort.Stack()) {
253-
print("\n", abort.String())
259+
t.failNowMutex.Lock()
260+
t.t.Errorf("Stage %s: %s", name, abort.String())
261+
t.failNowMutex.Unlock()
254262
}
255263
t.FailNow()
256264
}

0 commit comments

Comments
 (0)