CompilationLog (@NotNull Consumer<? super CompileStatusNotification> action) { final Ref<CompilationLog> result = new Ref<>(null); final Semaphore semaphore = new Semaphore(); semaphore.down(); final List<String> generatedFilePaths = new ArrayList<>(); myProject.getMessageBus().connect(getTestRootDisposable()).subscribe(CompilerTopics.COMPILATION_STATUS, new CompilationStatusListener() { @Override public void fileGenerated(@NotNull String outputRoot, @NotNull String relativePath) { generatedFilePaths.add(relativePath); } }); PlatformTestUtil.saveProject(myProject); CompilerTestUtil.saveApplicationSettings(); ApplicationManager.getApplication().invokeAndWait(() -> { CompilerTester.enableDebugLogging(); action.accept(new CompileStatusNotification() { @Override public void finished(boolean aborted, int errors, int warnings, @NotNull CompileContext compileContext) { try { if (aborted) { Assert.fail("compilation aborted"); } ExitStatus status = CompileDriver.getExternalBuildExitStatus(compileContext); result.set(new CompilationLog(status == ExitStatus.UP_TO_DATE, generatedFilePaths, compileContext.getMessages(CompilerMessageCategory.ERROR), compileContext.getMessages(CompilerMessageCategory.WARNING))); } finally { semaphore.up(); } } }); }); try { final long start = System.currentTimeMillis(); while (!semaphore.waitFor(10)) { if (!BuildManager.getInstance().isBuildProcessDebuggingEnabled() && System.currentTimeMillis() - start > 5 * 60 * 1000) { throw new RuntimeException("timeout"); } if (SwingUtilities.isEventDispatchThread()) { UIUtil.dispatchAllInvocationEvents(); } } if (SwingUtilities.isEventDispatchThread()) { UIUtil.dispatchAllInvocationEvents(); } } finally { CompilerTester.printBuildLog(); } return result.get(); }