kotest / kotest-intellij-plugin

The official Kotest plugin for Intellij and Android Studio
Apache License 2.0
180 stars 25 forks source link

Don't Run Tests When Indexes Are Not Ready #324

Open solonovamax opened 1 month ago

solonovamax commented 1 month ago

Don't allow running tests when the indexes are not ready, instead present a dialog saying that the indexes have not been built yet (similar to the refactor dialog in the base IDE)

Attempting to run tests while the indexes are not built/ready throws this exception:

Failed to execute debug configuration async

com.intellij.openapi.project.IndexNotReadyException: Please change caller according to com.intellij.openapi.project.IndexNotReadyException documentation. Dumb mode start trace is in the cause.
    at com.intellij.openapi.project.IndexNotReadyException.create(IndexNotReadyException.java:68)
    at com.intellij.util.indexing.FileBasedIndexImpl.handleDumbMode(FileBasedIndexImpl.java:879)
    at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:827)
    at com.intellij.psi.stubs.StubIndexEx.getContainingIds(StubIndexEx.java:358)
    at com.intellij.psi.stubs.StubIndexEx.processElements(StubIndexEx.java:168)
    at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:107)
    at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:95)
    at com.intellij.psi.impl.java.stubs.index.JavaFullClassNameIndex.getClasses(JavaFullClassNameIndex.java:37)
    at com.intellij.psi.impl.file.impl.JavaFileManagerImpl.doFindClasses(JavaFileManagerImpl.java:82)
    at com.intellij.psi.impl.file.impl.JavaFileManagerImpl.findClass(JavaFileManagerImpl.java:105)
    at com.intellij.psi.impl.PsiElementFinderImpl.findClass(PsiElementFinderImpl.java:41)
    at com.intellij.psi.impl.JavaPsiFacadeImpl.doFindClass(JavaPsiFacadeImpl.java:106)
    at com.intellij.psi.impl.JavaPsiFacadeImpl.findClass(JavaPsiFacadeImpl.java:85)
    at io.kotest.plugin.intellij.run.MainKt.is421(main.kt:44)
    at io.kotest.plugin.intellij.run.MainKt.determineKotestLauncher(main.kt:61)
    at io.kotest.plugin.intellij.run.KotestRunnableState.configureRTClasspath(KotestRunnableState.kt:60)
    at com.intellij.execution.JavaTestFrameworkRunnableState.configureClasspath(JavaTestFrameworkRunnableState.java:499)
    at com.intellij.execution.JavaTestFrameworkRunnableState.lambda$createJavaParameters$4(JavaTestFrameworkRunnableState.java:352)
    at com.intellij.openapi.application.ReadAction.lambda$run$1(ReadAction.java:54)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runReadAction(AnyThreadWriteThreadingSupport.kt:264)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runReadAction(AnyThreadWriteThreadingSupport.kt:221)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:857)
    at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:66)
    at com.intellij.openapi.application.ReadAction.run(ReadAction.java:53)
    at com.intellij.execution.JavaTestFrameworkRunnableState.createJavaParameters(JavaTestFrameworkRunnableState.java:351)
    at io.kotest.plugin.intellij.run.KotestRunnableState.createJavaParameters(KotestRunnableState.kt:27)
    at com.intellij.execution.configurations.JavaCommandLineState.getJavaParameters(JavaCommandLineState.java:41)
    at com.intellij.debugger.impl.GenericDebuggerRunner.lambda$doExecuteAsync$4(GenericDebuggerRunner.java:103)
    at com.intellij.execution.target.TargetEnvironmentAwareRunProfileState$1.run(TargetEnvironmentAwareRunProfileState.java:58)
    at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:477)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:133)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$6(CoreProgressManager.java:528)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:249)
    at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:98)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:221)
    at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.use(trace.kt:49)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:220)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:660)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:735)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:691)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:659)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:202)
    at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:98)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$5(ProgressRunner.java:249)
    at com.intellij.openapi.progress.impl.ProgressRunner$ProgressRunnable.run(ProgressRunner.java:501)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$launchTask$18(ProgressRunner.java:466)
    at com.intellij.util.concurrency.ChildContext$runAsCoroutine$1.invoke(propagation.kt:92)
    at com.intellij.util.concurrency.ChildContext$runAsCoroutine$1.invoke(propagation.kt:92)
    at com.intellij.util.concurrency.ChildContext.runAsCoroutine(propagation.kt:97)
    at com.intellij.util.concurrency.ChildContext.runAsCoroutine(propagation.kt:92)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$launchTask$19(ProgressRunner.java:464)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:735)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:732)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:732)
    at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.Throwable
    at com.intellij.openapi.project.DumbServiceImpl.queueTask(DumbServiceImpl.kt:368)
    at com.intellij.openapi.project.DumbModeTask.queue(DumbModeTask.java:66)
    at com.intellij.openapi.roots.impl.PushedFilePropertiesUpdaterImpl.queueTasks(PushedFilePropertiesUpdaterImpl.kt:220)
    at com.intellij.openapi.roots.impl.PushedFilePropertiesUpdaterImpl.processAfterVfsChanges(PushedFilePropertiesUpdaterImpl.kt:153)
    at com.intellij.psi.impl.file.impl.PsiVFSListener$1.after(PsiVFSListener.java:137)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:722)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:682)
    at com.intellij.util.messages.impl.MessageBusImplKt.executeOrAddToQueue(MessageBusImpl.kt:514)
    at com.intellij.util.messages.impl.ToDirectChildrenMessagePublisher.publish$intellij_platform_core(CompositeMessageBus.kt:279)
    at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:471)
    at jdk.proxy2/jdk.proxy2.$Proxy96.after(Unknown Source)
    at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.lambda$fireAfterEvents$20(PersistentFSImpl.java:1510)
    at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.runSuppressing(PersistentFSImpl.java:1140)
    at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.fireAfterEvents(PersistentFSImpl.java:1507)
    at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.applyMultipleEvents(PersistentFSImpl.java:1484)
    at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.processEventsImpl(PersistentFSImpl.java:1447)
    at com.intellij.openapi.vfs.newvfs.AsyncEventSupport.processEventsFromRefresh(AsyncEventSupport.java:153)
    at com.intellij.openapi.vfs.newvfs.RefreshSessionImpl.fireEventsInWriteAction(RefreshSessionImpl.java:247)
    at com.intellij.openapi.vfs.newvfs.RefreshSessionImpl.lambda$fireEvents$1(RefreshSessionImpl.java:229)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runEdtProgressWriteAction$lambda$7$lambda$6(AnyThreadWriteThreadingSupport.kt:429)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:221)
    at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.use(trace.kt:49)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:220)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:660)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:735)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:691)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:659)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:202)
    at com.intellij.openapi.progress.util.PotemkinProgress.runInSwingThread(PotemkinProgress.java:158)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runEdtProgressWriteAction$lambda$7(AnyThreadWriteThreadingSupport.kt:429)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteAction(AnyThreadWriteThreadingSupport.kt:328)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runEdtProgressWriteAction(AnyThreadWriteThreadingSupport.kt:427)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteActionWithNonCancellableProgressInDispatchThread(AnyThreadWriteThreadingSupport.kt:413)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithNonCancellableProgressInDispatchThread(ApplicationImpl.java:876)
    at com.intellij.openapi.vfs.newvfs.RefreshSessionImpl.fireEvents(RefreshSessionImpl.java:225)
    at com.intellij.openapi.vfs.newvfs.RefreshQueueImpl.lambda$processEvents$3(RefreshQueueImpl.java:125)
    at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.lambda$safeTransferToEdt$7(NonBlockingReadActionImpl.java:717)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:229)
    at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:22)
    at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runIntendedWriteActionOnCurrentThread$lambda$1(AnyThreadWriteThreadingSupport.kt:184)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:84)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runIntendedWriteActionOnCurrentThread(AnyThreadWriteThreadingSupport.kt:183)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:836)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:424)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWithImplicitRead(AnyThreadWriteThreadingSupport.kt:122)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWithImplicitRead(ApplicationImpl.java:1162)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:78)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:119)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:41)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:781)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:728)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:750)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:696)
    at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$16(IdeEventQueue.kt:590)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWithoutImplicitRead(AnyThreadWriteThreadingSupport.kt:117)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:590)
    at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:73)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1$1.compute(IdeEventQueue.kt:357)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1$1.compute(IdeEventQueue.kt:356)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:843)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.invoke(IdeEventQueue.kt:356)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.invoke(IdeEventQueue.kt:351)
    at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke$lambda$0(IdeEventQueue.kt:1035)
    at com.intellij.openapi.application.WriteIntentReadAction.lambda$run$0(WriteIntentReadAction.java:24)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:84)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteIntentReadAction(ApplicationImpl.java:910)
    at com.intellij.openapi.application.WriteIntentReadAction.compute(WriteIntentReadAction.java:55)
    at com.intellij.openapi.application.WriteIntentReadAction.run(WriteIntentReadAction.java:23)
    at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke(IdeEventQueue.kt:1035)
    at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke(IdeEventQueue.kt:1035)
    at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:1036)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106)
    at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1036)
    at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$10(IdeEventQueue.kt:351)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:397)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

Related issues: #165

sschuberth commented 2 weeks ago

With version 1.3.86-2024.2.2 of the plugin and K2 mode enabled I'm getting this also right at the start of the IDE, without any test runs triggered. Any idea how to solve this @akozlova?