From 2f01419a49a4aa4e0bb1adfc84e28251b0945397 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 25 Jan 2016 15:52:58 +0100 Subject: [PATCH] CompilerTester: ensure vfs up to date state when saving module files; fixes tests failing when run second time reusing temp directory --- .../com/intellij/testFramework/CompilerTester.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/java/testFramework/src/com/intellij/testFramework/CompilerTester.java b/java/testFramework/src/com/intellij/testFramework/CompilerTester.java index 739ea68802a0..95fc232f6a38 100644 --- a/java/testFramework/src/com/intellij/testFramework/CompilerTester.java +++ b/java/testFramework/src/com/intellij/testFramework/CompilerTester.java @@ -28,6 +28,7 @@ import com.intellij.openapi.roots.CompilerModuleExtension; import com.intellij.openapi.roots.CompilerProjectExtension; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.ModuleRootModificationUtil; +import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; @@ -207,6 +208,11 @@ public class CompilerTester { EdtTestUtil.runInEdtAndWait(new ThrowableRunnable() { @Override public void run() throws Throwable { + refreshVfs(getProject().getProjectFilePath()); + for (Module module : myModules) { + refreshVfs(module.getModuleFilePath()); + } + PlatformTestUtil.saveProject(getProject()); CompilerTestUtil.saveApplicationSettings(); for (Module module : myModules) { @@ -232,6 +238,13 @@ public class CompilerTester { return callback.getMessages(); } + private static void refreshVfs(String path) { + VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(path)); + if (vFile != null) { + vFile.refresh(false, false); + } + } + private static class ErrorReportingCallback implements CompileStatusNotification { private final Semaphore mySemaphore; private Throwable myError;