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
Use ConTester to prove that the synchronized block is required #4672
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package io.github.detekt.parser | ||
|
||
import io.github.davidburstrom.contester.ConTesterDriver | ||
import io.github.detekt.psi.BASE_PATH | ||
import io.github.detekt.psi.LINE_SEPARATOR | ||
import io.github.detekt.psi.RELATIVE_PATH | ||
|
@@ -8,10 +9,24 @@ import org.assertj.core.api.Assertions.assertThat | |
import org.assertj.core.api.Assertions.assertThatIllegalArgumentException | ||
import org.jetbrains.kotlin.com.intellij.psi.PsiErrorElement | ||
import org.jetbrains.kotlin.psi.KtTreeVisitorVoid | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.Nested | ||
import org.junit.jupiter.api.Test | ||
|
||
class KtCompilerSpec { | ||
@AfterEach | ||
internal fun tearDown() { | ||
ConTesterDriver.cleanUp() | ||
} | ||
|
||
@Test | ||
fun `parallel construction of KtCompilers should be thread safe`() { | ||
val thread1 = ConTesterDriver.thread { KtCompiler() } | ||
val thread2 = ConTesterDriver.thread { KtCompiler() } | ||
ConTesterDriver.runToBreakpoint(thread1, "DetektPomModel.registerExtensionPoint") | ||
ConTesterDriver.runUntilBlockedOrTerminated(thread2) | ||
ConTesterDriver.join(thread1) | ||
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: That's mostly an API design decision, but they would read better if they're extension function instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get what you're saying, though I'm not too keen on extension functions, especially since they would be called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agree. If you end up this way, I would not use those names and be a bit more specific with function naming.
That also works eventually :) |
||
} | ||
|
||
@Nested | ||
inner class `Kotlin Compiler` { | ||
|
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.
could you put a named parameter here?
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.
Could you provide an example of what you'd like it to look like?
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.
Something along those lines.
onlyWhen
could bewhen
orcondition
or whatever you preferThere 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.
Ah. That's not possible unless there are Kotlin bindings for the library.
condition
is preferable, to mimic debugger terminology.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.
Sorry. I naively thought you wrote this in Kotlin, my bad :) You could add bindings for that btw.
Yup that sounds great to me 👍
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.
Yeah, I would not want to impose a Kotlin runtime dependency for such a specific tool :)