CompilerTester: ensure vfs up to date state when saving module files; fixes tests failing when run second time reusing temp directory

This commit is contained in:
peter
2016-01-25 15:54:08 +01:00
parent 33cd748abd
commit 2f01419a49
@@ -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<Throwable>() {
@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;