IJPL-578 wait for indexes to be ready in tests (maven)

GitOrigin-RevId: 0bc80c99fe633d479eb3db029b40d51c429c9a4a
This commit is contained in:
Liudmila Kornilova
2024-03-13 18:59:26 +00:00
committed by intellij-monorepo-bot
parent ca852d2c96
commit 29b2f62087
3 changed files with 11 additions and 3 deletions
@@ -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")
@@ -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("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -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("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -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())))
@@ -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<VirtualFile>, failOnReadingError: Boolean, vararg profiles: String) {