test in a faster (and less flaky) way that unrelated folder creation doesn't lead to RootIndex rebuild

GitOrigin-RevId: 7ea55d075e7f73bf93b9e6434b67957631362ee6
This commit is contained in:
Peter Gromov
2020-06-15 18:12:12 +03:00
committed by intellij-monorepo-bot
parent 034a2eb3c1
commit 4715136e24
2 changed files with 10 additions and 14 deletions
@@ -988,24 +988,20 @@ public class DirectoryIndexTest extends DirectoryIndexTestCase {
}
}
public void testUnrelatedDirectoriesCreationMustNotLeadToDirectoryIndexRebuildToImproveCheckoutPerformance() {
public void testUnrelatedDirectoriesCreationMustNotLeadToDirectoryIndexRebuildToImproveCheckoutSpeed() {
VirtualFile root = ModuleRootManager.getInstance(myModule).getContentRoots()[0];
WriteAction.run(()->ModuleRootModificationUtil.updateModel(myModule, model -> {
ContentEntry rootEntry = model.getContentEntries()[0];
for (int i=0;i<10_000;i++) {
VirtualFile src = createChildDirectory(root, "extsrc" + i);
rootEntry.addSourceFolder(src, false);
}
rootEntry.addSourceFolder(createChildDirectory(root, "extsrc"), false);
}));
ProjectFileIndex fileIndex = ProjectFileIndex.getInstance(getProject());
PlatformTestUtil.startPerformanceTest("dir creation must not lead to dirindex rebuild", 30_000, ()->{
for (int i=0; i<2_000; i++) {
VirtualFile xxx = createChildDirectory(root, "xxx");
assertFalse(fileIndex.isInSource(xxx));
delete(xxx);
}
}).assertTiming();
DirectoryIndexImpl dirIndex = (DirectoryIndexImpl)DirectoryIndex.getInstance(myProject);
RootIndex rootIndex = dirIndex.getRootIndex();
VirtualFile xxx = createChildDirectory(root, "xxx");
assertFalse(ProjectFileIndex.getInstance(getProject()).isInSource(xxx));
delete(xxx);
assertSame(rootIndex, dirIndex.getRootIndex());
}
public void testSourceRootResidingUnderExcludedDirectoryMustBeIndexed() throws IOException {
@@ -128,7 +128,7 @@ public final class DirectoryIndexImpl extends DirectoryIndex implements Disposab
}
@NotNull
private RootIndex getRootIndex() {
RootIndex getRootIndex() {
RootIndex rootIndex = myRootIndex;
if (rootIndex == null) {
myRootIndex = rootIndex = new RootIndex(myProject);