public static VirtualFile createTestProjectStructure( String tempName, Module module, String rootPath, Collection<File> filesToDelete, boolean addProjectRoots) throws IOException { File dir = FileUtil.createTempDirectory(tempName, null, false); filesToDelete.add(dir); VirtualFile vDir = LocalFileSystem.getInstance() .refreshAndFindFileByPath(dir.getCanonicalPath().replace(File.separatorChar, '/')); assert vDir != null && vDir.isDirectory() : dir; PlatformTestCase.synchronizeTempDirVfs(vDir); EdtTestUtil.runInEdtAndWait( () -> { AccessToken token = WriteAction.start(); try { if (rootPath != null) { VirtualFile vDir1 = LocalFileSystem.getInstance() .findFileByPath(rootPath.replace(File.separatorChar, '/')); if (vDir1 == null) { throw new Exception(rootPath + " not found"); } VfsUtil.copyDirectory(null, vDir1, vDir, null); } if (addProjectRoots) { addSourceContentToRoots(module, vDir); } } finally { token.finish(); } }); return vDir; }