Skip to content

Commit b8d84c8

Browse files
author
Uwe Jugel
committed
regenerate code
1 parent c8e9baa commit b8d84c8

5 files changed

Lines changed: 116 additions & 0 deletions

File tree

assert/assertion_format.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface
168168
// Eventuallyf asserts that given condition will be met in waitFor time,
169169
// periodically checking target function each tick.
170170
//
171+
// If the condition does not return normally, but instead calls [runtime.Goexit],
172+
// the assertion fails immediately. This usually means that the condition called
173+
// t.FailNow() on the outer 't'.
174+
//
171175
// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
172176
func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
173177
if h, ok := t.(tHelper); ok {
@@ -185,6 +189,12 @@ func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick
185189
// If the condition is not met before waitFor, the collected errors of
186190
// the last tick are copied to t.
187191
//
192+
// If the condition does not return normally, but instead calls [runtime.Goexit],
193+
// and the exit was not via 'collect.FailNow()', the assertion fails immediately.
194+
// This usually means that the condition called t.FailNow() on the outer 't'.
195+
// Use [CollectT.FailNow] or 'require' functions on the provided 'collect' to
196+
// only fail the current tick.
197+
//
188198
// externalValue := false
189199
// go func() {
190200
// time.Sleep(8*time.Second)
@@ -525,6 +535,10 @@ func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) bool
525535
// Neverf asserts that the given condition doesn't satisfy in waitFor time,
526536
// periodically checking the target function each tick.
527537
//
538+
// If the condition does not return normally, but instead calls [runtime.Goexit],
539+
// the assertion fails immediately. This usually means that the condition called
540+
// t.FailNow() on the outer 't'.
541+
//
528542
// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
529543
func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
530544
if h, ok := t.(tHelper); ok {

assert/assertion_forward.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool {
325325
// Eventually asserts that given condition will be met in waitFor time,
326326
// periodically checking target function each tick.
327327
//
328+
// If the condition does not return normally, but instead calls [runtime.Goexit],
329+
// the assertion fails immediately. This usually means that the condition called
330+
// t.FailNow() on the outer 't'.
331+
//
328332
// a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond)
329333
func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
330334
if h, ok := a.t.(tHelper); ok {
@@ -342,6 +346,12 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti
342346
// If the condition is not met before waitFor, the collected errors of
343347
// the last tick are copied to t.
344348
//
349+
// If the condition does not return normally, but instead calls [runtime.Goexit],
350+
// and the exit was not via 'collect.FailNow()', the assertion fails immediately.
351+
// This usually means that the condition called t.FailNow() on the outer 't'.
352+
// Use [CollectT.FailNow] or 'require' functions on the provided 'collect' to
353+
// only fail the current tick.
354+
//
345355
// externalValue := false
346356
// go func() {
347357
// time.Sleep(8*time.Second)
@@ -367,6 +377,12 @@ func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor
367377
// If the condition is not met before waitFor, the collected errors of
368378
// the last tick are copied to t.
369379
//
380+
// If the condition does not return normally, but instead calls [runtime.Goexit],
381+
// and the exit was not via 'collect.FailNow()', the assertion fails immediately.
382+
// This usually means that the condition called t.FailNow() on the outer 't'.
383+
// Use [CollectT.FailNow] or 'require' functions on the provided 'collect' to
384+
// only fail the current tick.
385+
//
370386
// externalValue := false
371387
// go func() {
372388
// time.Sleep(8*time.Second)
@@ -386,6 +402,10 @@ func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT), waitFor
386402
// Eventuallyf asserts that given condition will be met in waitFor time,
387403
// periodically checking target function each tick.
388404
//
405+
// If the condition does not return normally, but instead calls [runtime.Goexit],
406+
// the assertion fails immediately. This usually means that the condition called
407+
// t.FailNow() on the outer 't'.
408+
//
389409
// a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
390410
func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
391411
if h, ok := a.t.(tHelper); ok {
@@ -1039,6 +1059,10 @@ func (a *Assertions) Negativef(e interface{}, msg string, args ...interface{}) b
10391059
// Never asserts that the given condition doesn't satisfy in waitFor time,
10401060
// periodically checking the target function each tick.
10411061
//
1062+
// If the condition does not return normally, but instead calls [runtime.Goexit],
1063+
// the assertion fails immediately. This usually means that the condition called
1064+
// t.FailNow() on the outer 't'.
1065+
//
10421066
// a.Never(func() bool { return false; }, time.Second, 10*time.Millisecond)
10431067
func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
10441068
if h, ok := a.t.(tHelper); ok {
@@ -1050,6 +1074,10 @@ func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick ti
10501074
// Neverf asserts that the given condition doesn't satisfy in waitFor time,
10511075
// periodically checking the target function each tick.
10521076
//
1077+
// If the condition does not return normally, but instead calls [runtime.Goexit],
1078+
// the assertion fails immediately. This usually means that the condition called
1079+
// t.FailNow() on the outer 't'.
1080+
//
10531081
// a.Neverf(func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
10541082
func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
10551083
if h, ok := a.t.(tHelper); ok {

require/require.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@ func Errorf(t TestingT, err error, msg string, args ...interface{}) {
404404
// Eventually asserts that given condition will be met in waitFor time,
405405
// periodically checking target function each tick.
406406
//
407+
// If the condition does not return normally, but instead calls [runtime.Goexit],
408+
// the assertion fails immediately. This usually means that the condition called
409+
// t.FailNow() on the outer 't'.
410+
//
407411
// require.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond)
408412
func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
409413
if h, ok := t.(tHelper); ok {
@@ -424,6 +428,12 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t
424428
// If the condition is not met before waitFor, the collected errors of
425429
// the last tick are copied to t.
426430
//
431+
// If the condition does not return normally, but instead calls [runtime.Goexit],
432+
// and the exit was not via 'collect.FailNow()', the assertion fails immediately.
433+
// This usually means that the condition called t.FailNow() on the outer 't'.
434+
// Use [CollectT.FailNow] or 'require' functions on the provided 'collect' to
435+
// only fail the current tick.
436+
//
427437
// externalValue := false
428438
// go func() {
429439
// time.Sleep(8*time.Second)
@@ -452,6 +462,12 @@ func EventuallyWithT(t TestingT, condition func(collect *assert.CollectT), waitF
452462
// If the condition is not met before waitFor, the collected errors of
453463
// the last tick are copied to t.
454464
//
465+
// If the condition does not return normally, but instead calls [runtime.Goexit],
466+
// and the exit was not via 'collect.FailNow()', the assertion fails immediately.
467+
// This usually means that the condition called t.FailNow() on the outer 't'.
468+
// Use [CollectT.FailNow] or 'require' functions on the provided 'collect' to
469+
// only fail the current tick.
470+
//
455471
// externalValue := false
456472
// go func() {
457473
// time.Sleep(8*time.Second)
@@ -474,6 +490,10 @@ func EventuallyWithTf(t TestingT, condition func(collect *assert.CollectT), wait
474490
// Eventuallyf asserts that given condition will be met in waitFor time,
475491
// periodically checking target function each tick.
476492
//
493+
// If the condition does not return normally, but instead calls [runtime.Goexit],
494+
// the assertion fails immediately. This usually means that the condition called
495+
// t.FailNow() on the outer 't'.
496+
//
477497
// require.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
478498
func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
479499
if h, ok := t.(tHelper); ok {
@@ -1310,6 +1330,10 @@ func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) {
13101330
// Never asserts that the given condition doesn't satisfy in waitFor time,
13111331
// periodically checking the target function each tick.
13121332
//
1333+
// If the condition does not return normally, but instead calls [runtime.Goexit],
1334+
// the assertion fails immediately. This usually means that the condition called
1335+
// t.FailNow() on the outer 't'.
1336+
//
13131337
// require.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond)
13141338
func Never(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
13151339
if h, ok := t.(tHelper); ok {
@@ -1324,6 +1348,10 @@ func Never(t TestingT, condition func() bool, waitFor time.Duration, tick time.D
13241348
// Neverf asserts that the given condition doesn't satisfy in waitFor time,
13251349
// periodically checking the target function each tick.
13261350
//
1351+
// If the condition does not return normally, but instead calls [runtime.Goexit],
1352+
// the assertion fails immediately. This usually means that the condition called
1353+
// t.FailNow() on the outer 't'.
1354+
//
13271355
// require.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
13281356
func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
13291357
if h, ok := t.(tHelper); ok {

require/require_forward.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,10 @@ func (a *Assertions) Errorf(err error, msg string, args ...interface{}) {
326326
// Eventually asserts that given condition will be met in waitFor time,
327327
// periodically checking target function each tick.
328328
//
329+
// If the condition does not return normally, but instead calls [runtime.Goexit],
330+
// the assertion fails immediately. This usually means that the condition called
331+
// t.FailNow() on the outer 't'.
332+
//
329333
// a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond)
330334
func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
331335
if h, ok := a.t.(tHelper); ok {
@@ -343,6 +347,12 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti
343347
// If the condition is not met before waitFor, the collected errors of
344348
// the last tick are copied to t.
345349
//
350+
// If the condition does not return normally, but instead calls [runtime.Goexit],
351+
// and the exit was not via 'collect.FailNow()', the assertion fails immediately.
352+
// This usually means that the condition called t.FailNow() on the outer 't'.
353+
// Use [CollectT.FailNow] or 'require' functions on the provided 'collect' to
354+
// only fail the current tick.
355+
//
346356
// externalValue := false
347357
// go func() {
348358
// time.Sleep(8*time.Second)
@@ -368,6 +378,12 @@ func (a *Assertions) EventuallyWithT(condition func(collect *assert.CollectT), w
368378
// If the condition is not met before waitFor, the collected errors of
369379
// the last tick are copied to t.
370380
//
381+
// If the condition does not return normally, but instead calls [runtime.Goexit],
382+
// and the exit was not via 'collect.FailNow()', the assertion fails immediately.
383+
// This usually means that the condition called t.FailNow() on the outer 't'.
384+
// Use [CollectT.FailNow] or 'require' functions on the provided 'collect' to
385+
// only fail the current tick.
386+
//
371387
// externalValue := false
372388
// go func() {
373389
// time.Sleep(8*time.Second)
@@ -387,6 +403,10 @@ func (a *Assertions) EventuallyWithTf(condition func(collect *assert.CollectT),
387403
// Eventuallyf asserts that given condition will be met in waitFor time,
388404
// periodically checking target function each tick.
389405
//
406+
// If the condition does not return normally, but instead calls [runtime.Goexit],
407+
// the assertion fails immediately. This usually means that the condition called
408+
// t.FailNow() on the outer 't'.
409+
//
390410
// a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
391411
func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
392412
if h, ok := a.t.(tHelper); ok {
@@ -1040,6 +1060,10 @@ func (a *Assertions) Negativef(e interface{}, msg string, args ...interface{}) {
10401060
// Never asserts that the given condition doesn't satisfy in waitFor time,
10411061
// periodically checking the target function each tick.
10421062
//
1063+
// If the condition does not return normally, but instead calls [runtime.Goexit],
1064+
// the assertion fails immediately. This usually means that the condition called
1065+
// t.FailNow() on the outer 't'.
1066+
//
10431067
// a.Never(func() bool { return false; }, time.Second, 10*time.Millisecond)
10441068
func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
10451069
if h, ok := a.t.(tHelper); ok {
@@ -1051,6 +1075,10 @@ func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick ti
10511075
// Neverf asserts that the given condition doesn't satisfy in waitFor time,
10521076
// periodically checking the target function each tick.
10531077
//
1078+
// If the condition does not return normally, but instead calls [runtime.Goexit],
1079+
// the assertion fails immediately. This usually means that the condition called
1080+
// t.FailNow() on the outer 't'.
1081+
//
10541082
// a.Neverf(func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
10551083
func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
10561084
if h, ok := a.t.(tHelper); ok {

require/requirements_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package require
33
import (
44
"encoding/json"
55
"errors"
6+
"runtime"
67
"testing"
78
"time"
89

@@ -788,3 +789,20 @@ func TestEventuallyWithTTrue(t *testing.T) {
788789
False(t, mockT.Failed, "Check should pass")
789790
Equal(t, 2, counter, "Condition is expected to be called 2 times")
790791
}
792+
793+
func TestEventuallyWithTOuterFailNow(t *testing.T) {
794+
t.Parallel()
795+
796+
mockT := new(MockT)
797+
798+
counter := 0
799+
condition := func(collect *assert.CollectT) {
800+
// Simulate a FailNow on the outer 't'.
801+
counter += 1
802+
runtime.Goexit()
803+
}
804+
805+
EventuallyWithT(mockT, condition, 100*time.Millisecond, 20*time.Millisecond)
806+
True(t, mockT.Failed, "Check should pass")
807+
Equal(t, 1, counter, "Condition is expected to be called 1 times")
808+
}

0 commit comments

Comments
 (0)