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

CoroutinesTimeout for JUnit5 #2402

Merged
merged 18 commits into from Apr 23, 2021
Merged

CoroutinesTimeout for JUnit5 #2402

merged 18 commits into from Apr 23, 2021

Conversation

dkhalanskyjb
Copy link
Collaborator

@dkhalanskyjb dkhalanskyjb commented Nov 20, 2020

Fixes #2197.

Copy link
Member

@qwwdfsad qwwdfsad left a 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?

@dkhalanskyjb dkhalanskyjb force-pushed the junit5-CoroutinesTimeout branch 2 times, most recently from fbefe36 to 54da484 Compare March 26, 2021 10:52
Copy link
Member

@qwwdfsad qwwdfsad left a 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 {
Copy link
Member

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

Copy link
Collaborator Author

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?

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused val

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.
Copy link
Member

@qwwdfsad qwwdfsad left a 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 {
Copy link
Member

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

@dkhalanskyjb dkhalanskyjb merged commit 3116b8c into develop Apr 23, 2021
@dkhalanskyjb dkhalanskyjb deleted the junit5-CoroutinesTimeout branch April 23, 2021 09:41
pablobaxter pushed a commit to pablobaxter/kotlinx.coroutines that referenced this pull request Sep 14, 2022
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.

None yet

2 participants