Minor, tests: make collection synchronized
Attempt to fix flaky test test that use LightClassComputationControl
This commit is contained in:
+3
-2
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
|||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.picocontainer.MutablePicoContainer
|
import org.picocontainer.MutablePicoContainer
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.util.Collections.synchronizedList
|
||||||
|
|
||||||
object LightClassComputationControl {
|
object LightClassComputationControl {
|
||||||
fun testWithControl(project: Project, testText: String, testBody: () -> Unit) {
|
fun testWithControl(project: Project, testText: String, testBody: () -> Unit) {
|
||||||
@@ -33,7 +34,7 @@ object LightClassComputationControl {
|
|||||||
testText, "// $LIGHT_CLASS_DIRECTIVE"
|
testText, "// $LIGHT_CLASS_DIRECTIVE"
|
||||||
).map { it.trim() }
|
).map { it.trim() }
|
||||||
|
|
||||||
val actualFqNames = ArrayList<String>()
|
val actualFqNames = synchronizedList(ArrayList<String>())
|
||||||
val stubComputationTracker = object : StubComputationTracker {
|
val stubComputationTracker = object : StubComputationTracker {
|
||||||
override fun onStubComputed(javaFileStub: PsiJavaFileStub, context: LightClassConstructionContext) {
|
override fun onStubComputed(javaFileStub: PsiJavaFileStub, context: LightClassConstructionContext) {
|
||||||
val qualifiedName = (javaFileStub.childrenStubs.single() as PsiClassStub<*>).qualifiedName!!
|
val qualifiedName = (javaFileStub.childrenStubs.single() as PsiClassStub<*>).qualifiedName!!
|
||||||
@@ -45,7 +46,7 @@ object LightClassComputationControl {
|
|||||||
testBody()
|
testBody()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expectedLightClassFqNames.toSortedSet() != actualFqNames.toSortedSet()) {
|
if (expectedLightClassFqNames.toSortedSet() != synchronized(actualFqNames) { actualFqNames.toSortedSet() }) {
|
||||||
Assert.fail(
|
Assert.fail(
|
||||||
"Expected to compute: ${expectedLightClassFqNames.prettyToString()}\n" +
|
"Expected to compute: ${expectedLightClassFqNames.prettyToString()}\n" +
|
||||||
"Actually computed: ${actualFqNames.prettyToString()}\n" +
|
"Actually computed: ${actualFqNames.prettyToString()}\n" +
|
||||||
|
|||||||
Reference in New Issue
Block a user