Commit e6b0793
committed
fix(Eventually): fixed go routine leak issues
Reference (original issue report): stretchr#1611
This fix involves a complete rewrite of assertions that run background
checks, with more idiomatic go routine codes and use of context.Context.
Affected assertions:
* Eventually
* Never
* EventuallyWithT
We no longer run go routines that are not waited for.
Timeouts and early exits are handled via context.Context.
CollecT.FailNow() now also cancels the context of the caller instead.
Significant changes:
* callers should not expect Eventually and others to
complete in the case of a blocking condition function.
In particular, the condition function should never wait for an event that is
triggered after Eventually. Complex or long-running condition function
may use t.Context() to exit early if the test is failed.
* callers may safely assume that only one go routine is executing the
condition function (no race on writes)
* test: asserted stretch/testify#480 is fixed
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>1 parent c217cc4 commit e6b0793
6 files changed
Lines changed: 759 additions & 290 deletions
File tree
- internal/assertions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
194 | 193 | | |
195 | 194 | | |
196 | 195 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | 196 | | |
216 | 197 | | |
217 | 198 | | |
| |||
0 commit comments