Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventuallyWithT does not always copy the last errors #1437

Closed
cszczepaniak opened this issue Jul 30, 2023 · 2 comments
Closed

EventuallyWithT does not always copy the last errors #1437

cszczepaniak opened this issue Jul 30, 2023 · 2 comments
Labels
bug concurrency pkg-assert Change related to package testify/assert

Comments

@cszczepaniak
Copy link

The documentation for EventuallyWithT states:

// If the condition is not met before waitFor, the collected errors of
// the last tick are copied to t.

However, it is possible to show that this is not the case with the following test:

func TestEventuallyWithTFalse(t *testing.T) {
	mockT := new(CollectT)

	var calledOnce bool
	condition := func(collect *CollectT) {
		if calledOnce {
			time.Sleep(time.Second)
		}
		True(collect, false)
		calledOnce = true
	}

	False(t, EventuallyWithT(mockT, condition, 100*time.Millisecond, 20*time.Millisecond))
	Len(t, mockT.errors, 2)
}

This test fails because the errors do not get copied; there is a race condition condition between the condition-checking goroutine and the assertion's goroutine.

@cszczepaniak
Copy link
Author

This is potentially a duplicate of #1395; this issue reports the symptom of what #1395 reports.

@cszczepaniak
Copy link
Author

Closing this because there are plenty of similar issues already.

@cszczepaniak cszczepaniak reopened this Jul 30, 2023
@cszczepaniak cszczepaniak closed this as not planned Won't fix, can't repro, duplicate, stale Jul 30, 2023
@dolmen dolmen added bug pkg-assert Change related to package testify/assert concurrency labels Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug concurrency pkg-assert Change related to package testify/assert
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants