From 29b2f620878d6e14d6bb6ca8e3fedfada5e866c9 Mon Sep 17 00:00:00 2001 From: Liudmila Kornilova Date: Tue, 5 Mar 2024 18:37:54 +0100 Subject: [PATCH] IJPL-578 wait for indexes to be ready in tests (maven) GitOrigin-RevId: 0bc80c99fe633d479eb3db029b40d51c429c9a4a --- .../dom/MavenDependencyCompletionAndResolutionTest.kt | 3 +++ .../idea/maven/statistics/MavenPluginCollectorTest.kt | 10 +++++++--- .../maven/testFramework/MavenImportingTestCase.kt | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.kt index 7e5921ad5032..79edafa479bd 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.kt @@ -9,6 +9,7 @@ import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.psi.codeStyle.CodeStyleSettingsManager import com.intellij.psi.codeStyle.CommonCodeStyleSettings import com.intellij.psi.formatter.xml.XmlCodeStyleSettings +import com.intellij.testFramework.IndexingTestUtil import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext @@ -370,6 +371,8 @@ class MavenDependencyCompletionAndResolutionTest : MavenDomWithIndicesTestCase() importProjectsWithErrors(projectPom, m1, m2) + IndexingTestUtil.waitUntilIndexesAreReady(project) + assertCompletionVariantsInclude(projectPom, RENDERING_TEXT, "m1", "m2") assertCompletionVariantsInclude(projectPom, LOOKUP_STRING, "project-group:m1:1", "project-group:m2:1") diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/statistics/MavenPluginCollectorTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/statistics/MavenPluginCollectorTest.kt index 5005e851f577..23ad89e986e6 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/statistics/MavenPluginCollectorTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/statistics/MavenPluginCollectorTest.kt @@ -5,13 +5,17 @@ import com.intellij.internal.statistic.FUCollectorTestCase.collectProjectStateCo import com.intellij.internal.statistic.eventLog.validator.ValidationResultType import com.intellij.internal.statistic.eventLog.validator.rules.EventContext import com.intellij.maven.testFramework.MavenImportingTestCase +import com.intellij.openapi.application.EDT +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking import org.junit.Test class MavenPluginCollectorTest : MavenImportingTestCase() { + override fun runInDispatchThread(): Boolean = false + @Test - fun `test should collect info about plugins`() = runBlocking { + fun `test should collect info about plugins`() = runBlocking(Dispatchers.EDT) { importProjectAsync(""" test project @@ -41,7 +45,7 @@ class MavenPluginCollectorTest : MavenImportingTestCase() { } @Test - fun `test should not collect info for private plugins`() = runBlocking { + fun `test should not collect info for private plugins`() = runBlocking(Dispatchers.EDT) { importProjectAsync(""" test project @@ -74,7 +78,7 @@ class MavenPluginCollectorTest : MavenImportingTestCase() { } @Test - fun `test check whitelist plugin Rule`() = runBlocking { + fun `test check whitelist plugin Rule`() = runBlocking(Dispatchers.EDT) { val rule = MavenPluginCoordinatesWhitelistValidationRule() assertEquals(ValidationResultType.ACCEPTED, rule.validate("org.apache.maven.plugins:maven-eclipse-plugin", EventContext.create("", emptyMap()))) diff --git a/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenImportingTestCase.kt b/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenImportingTestCase.kt index d2397595c625..3393e64a03b2 100644 --- a/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenImportingTestCase.kt +++ b/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenImportingTestCase.kt @@ -424,6 +424,7 @@ abstract class MavenImportingTestCase : MavenTestCase() { assertFalse("Failed to import Maven project: " + each.getProblems(), each.hasReadingProblems()) } } + IndexingTestUtil.waitUntilIndexesAreReady(project); } protected suspend fun doImportProjectsAsync(files: List, failOnReadingError: Boolean, vararg profiles: String) {