IJPL-578 log "waitNow will be waiting" in tests

"waitNow will be waiting" in test log means that test behavior has been changed by IndexingTestUtil: some indexing tasks that supposed to run synchronously didn't finish yet, and IndexingTestUtil will wait for them. In most cases tests are running on EDT, so this means that IndexingTestUtil will pump EDT events, which may change test behavior (e.g. some write action may occur and invalidate something, e.g. highlighting)

GitOrigin-RevId: bd530f882840ff83fdc5c1ab6901c2fa9b9430e2
This commit is contained in:
Andrei.Kuznetsov
2024-01-31 13:25:23 +01:00
committed by intellij-monorepo-bot
parent a82baf0789
commit ffe26e54cd

View File

@@ -74,7 +74,11 @@ class IndexingTestUtil(private val project: Project) {
thisLogger().debug("waitNow, thread=${Thread.currentThread()}")
Assert.assertFalse("Should not be invoked from write action", ApplicationManager.getApplication().isWriteAccessAllowed)
if (!isRunning()) return // TODO: CodeInsightTestFixtureImpl.configureInner via GroovyHighlightUsagesTest
if (!isRunning()) {
return // TODO: CodeInsightTestFixtureImpl.configureInner via GroovyHighlightUsagesTest
} else {
thisLogger().warn("waitNow will be waiting, thread=${Thread.currentThread()}", Throwable())
}
if (ApplicationManager.getApplication().isWriteIntentLockAcquired) {
val scope = GlobalScope.namedChildScope("Indexing waiter", Dispatchers.IO)
@@ -102,6 +106,11 @@ class IndexingTestUtil(private val project: Project) {
}
suspend fun suspendUntilIndexesAreReady() {
if (!isRunning()) {
return
} else {
thisLogger().warn("suspendUntilIndexesAreReady will be waiting, thread=${Thread.currentThread()}", Throwable())
}
UnindexedFilesScannerExecutor.getInstance(project).waitUntilFinished()
DumbServiceImpl.getInstance(project).waitUntilFinished()
}