Skip to content

Conversation

@twz123
Copy link

@twz123 twz123 commented Nov 19, 2025

Summary

Add CollectT.Halt() so fatal assertions invoked inside EventuallyWithT can stop the retry loop.

Changes

Add the new HaltT struct that acts as a CollectT wrapper. Whenever an error or failure is recorded, the wrapping HaltT will set CollectT's new halt flag, so that the EventuallyWithT loop can detect this and error out early.

Motivation

This allows for cleanly breaking out of the test loop before the timeout has elapsed, if necessary:

condition := func(c *CollectT) {
	require.True(c.Halt(), socketsOpen(), "socket must be open before proceeding")
	assert.True(c, eventuallyTrue(), "non-fatal checks still run until success/timeout")
}
assert.EventuallyWithT(t, condition, time.Second, 10*time.Millisecond)

Related issues

So fatal assertions invoked inside EventuallyWithT can stop the retry
loop.

Add the new HaltT struct that acts as a CollectT wrapper. Whenever an
error or failure is recorded, the wrapping HaltT will set CollectT's new
halt flag, so that the EventuallyWithT loop can detect this and error
out early.

This allows for cleanly breaking out of the test loop before the timeout
has elapsed, if necessary.

Signed-off-by: Tom Wieczorek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant