-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
CoroutinesTimeout for JUnit5 #2402
Conversation
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.
Skimmed through KDoc and public API, will get back to the engine impl later.
Could you please rebase this branch on the recent develop
?
kotlinx-coroutines-debug/src/junit/junit5/CoroutinesTimeoutExtension.kt
Outdated
Show resolved
Hide resolved
kotlinx-coroutines-debug/test/junit5/CoroutinesTimeoutSimpleTest.kt
Outdated
Show resolved
Hide resolved
fbefe36
to
54da484
Compare
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.
Let's address one final question and ship it 🚀
@@ -38,6 +41,12 @@ if (rootProject.ext.jvm_ir_enabled) { | |||
} | |||
} | |||
|
|||
java { |
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.
Doesn't seem to be necessary for the latest develop
where we have 1.8 target
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.
I attempted to remove this block, but then the build was failing. I managed to fix the build of this subproject by adding
tasks.withType(JavaCompile) {
targetCompatibility = JavaVersion.VERSION_1_8
}
However, then kotlinx-coroutines-test also required targetCompatibility
set. At that point, I stopped. Do you think this should be pursued further?
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.
I think that's enough, thanks for checking it
|
||
private fun tryPassDebugProbesOwnership() = debugProbesOwnershipPassed.compareAndSet(false, true) | ||
|
||
private val isDebugProbesOwnershipPassed |
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.
unused val
kotlinx-coroutines-debug/src/junit/junit5/CoroutinesTimeoutExtension.kt
Outdated
Show resolved
Hide resolved
As implemented, now DebugProbes will be installed before the first constructor of a test class that uses CoroutinesTimeout is invoked, and uninstalled during the cleanup of the extension.
Instead, another interface is implemented that resembles the one provided for JUnit4 and does allow such configuration.
1. A case where extension instances run concurrently and use the same extension context or where an extension instance is run on several methods concurrently is handled, even though it's unclear whether such things could happen. 2. Using CoroutinesTimeout via annotation no longer needs write access to the resource lock, meaning that tests annotated with it don't have to run sequentially. 3. Better documentation for the now-complex logic.
54da484
to
bb5216c
Compare
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.
Great!
@@ -38,6 +41,12 @@ if (rootProject.ext.jvm_ir_enabled) { | |||
} | |||
} | |||
|
|||
java { |
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.
I think that's enough, thanks for checking it
Fixes #2197.