-
Notifications
You must be signed in to change notification settings - Fork 680
Stabilize GlobalTimeoutTest and EngineTimeoutTest #4124
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
Conversation
4790583
to
fc80c8e
Compare
use locks to wait until tests have launched before running assertions
fc80c8e
to
507c042
Compare
* An active [Job] that will be completed when [engineFinished] is invoked. | ||
* @see waitForEngineFinished | ||
*/ | ||
private val engineFinishedJob = Job() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting solution, using a Job as a boolean-like state which one can wait for while suspending.
It took me some time to decipher, as I had to make sure that the Job
- does not perform actual work, and
- does not have children (in which case
complete()
would not makejoin()
return immediately).
Could you add some comment to that effect?
(The same could be achieved with a Mutex
(playground), but that would also require some comment explaining to its uncommon use. I have a similar thing called Gate
in this KotlinConf talk companion repo.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh yes, the mutex.withLock {}
is probably better. I'll update the code and with a comment.
Hmmm apparently
|
...ework-engine/src/commonMain/kotlin/io/kotest/engine/listener/CollectingTestEngineListener.kt
Outdated
Show resolved
Hide resolved
...ework-engine/src/commonMain/kotlin/io/kotest/engine/listener/CollectingTestEngineListener.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, given the new insights. I also wonder why the same listener would observe multiple engines. 🤔
Oh, I figured it out and forgot to update my message. The reason is one of the test re-uses a listener, which I think is reasonable. Lines 78 to 90 in e2ebd49
|
61d8d35
to
973e5b5
Compare
Thanks for clarifying! Helps to demystify what I suspected was one more piece of magic. Now I can relax again. :) |
Co-authored-by: OliverO2 <Oliver.O456i@gmail.com>
Co-authored-by: OliverO2 <Oliver.O456i@gmail.com>
973e5b5
to
b4e88a7
Compare
Wait until the engine has completed before asserting the results.
Part of #4113