void () { Project project = getProject(); ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project); FakeRunConfiguration rc = new FakeRunConfiguration(project, true); RunnerAndConfigurationSettingsImpl settings = new RunnerAndConfigurationSettingsImpl( RunManagerImpl.getInstanceImpl(project), rc, false ); ExecutionEnvironment env1 = createEnv(project, settings); executionManager.restartRunProfile(env1); UIUtil.dispatchAllInvocationEvents(); NonBlockingReadActionImpl.waitForAsyncTaskCompletion(); ProcessHandler processHandler1 = getProcessHandler(executionManager); ExecutionEnvironment env2 = createEnv(project, settings); executionManager.restartRunProfile(env2); // Dispatching all events at this point will run into an endless cycle, because // runContentDescriptors of the same type are asked to terminate and then are awaited for termination: // com.intellij.execution.impl.ExecutionManagerImpl.awaitTermination // // However, the created processHandler is not willing to terminate on the first request (surviveSoftKill=true). // It will be terminated on the second request: executionManager.restartRunProfile(env3) NonBlockingReadActionImpl.waitForAsyncTaskCompletion(); ProcessHandler processHandler2 = getProcessHandler(executionManager); assertSame(processHandler1, processHandler2); assertTrue(processHandler1.isProcessTerminating()); ExecutionEnvironment env3 = createEnv(project, settings); executionManager.restartRunProfile(env3); UIUtil.dispatchAllInvocationEvents(); NonBlockingReadActionImpl.waitForAsyncTaskCompletion(); FakeProcessHandler processHandler3 = getProcessHandler(executionManager); assertNotSame(processHandler1, processHandler3); assertTrue(!processHandler3.isProcessTerminating() && !processHandler3.isProcessTerminated()); processHandler3.killProcess(); }