Skip to content

Commit

Permalink
Merge pull request #8066 from lahodaj/stabilize-java-cc-tests
Browse files Browse the repository at this point in the history
Improve stability of Java code completion (sealed) tests.
  • Loading branch information
lahodaj authored Dec 18, 2024
2 parents 8a420a7 + f5cd319 commit 0a5a17e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public class CompletionTestBaseBase extends NbTestCase {
JavaCompletionTaskBasicTest.class.getClassLoader().setDefaultAssertionStatus(true);
SourceUtilsTestUtil2.disableArtificalParameterNames();
System.setProperty("org.netbeans.modules.java.source.parsing.JavacParser.no_parameter_names", "true");
// bump tresholds to avoid context dumps from "excessive indexing" warnings
System.setProperty("org.netbeans.modules.parsing.impl.indexing.LogContext$EventType.PATH.treshold", "100");
System.setProperty("org.netbeans.modules.parsing.impl.indexing.LogContext$EventType.MANAGER.treshold", "100");
}

static final int FINISH_OUTTIME = 5 * 60 * 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@

package org.netbeans.modules.java.completion;

import java.util.concurrent.CountDownLatch;
import org.netbeans.api.java.classpath.ClassPath;
import org.netbeans.api.java.classpath.GlobalPathRegistry;
import org.netbeans.api.java.source.ClassIndexListener;
import org.netbeans.api.java.source.ClasspathInfo;
import org.netbeans.api.java.source.RootsEvent;
import org.netbeans.api.java.source.SourceUtils;
import org.netbeans.api.java.source.TypesEvent;
import org.netbeans.modules.java.source.parsing.JavacParser;
import org.netbeans.modules.parsing.api.indexing.IndexingManager;
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
Expand Down Expand Up @@ -171,8 +176,27 @@ public void testNonSealedTypeSwitch1() throws Exception {
protected void afterTestSetup() throws Exception {
if (getName().startsWith("testSealed")) {
classPathRegistered = ClassPathSupport.createClassPath(getWorkDir().toURI().toURL());
CountDownLatch started = new CountDownLatch(1);
ClasspathInfo info = ClasspathInfo.create(ClassPath.EMPTY, ClassPath.EMPTY, classPathRegistered);
ClassIndexListener listener = new ClassIndexListener() {
@Override
public void typesAdded(TypesEvent event) {}
@Override
public void typesRemoved(TypesEvent event) {}
@Override
public void typesChanged(TypesEvent event) {}
@Override
public void rootsAdded(RootsEvent event) {
started.countDown();
}
@Override
public void rootsRemoved(RootsEvent event) {}
};
info.getClassIndex().addClassIndexListener(listener);
GlobalPathRegistry.getDefault().register(ClassPath.SOURCE, new ClassPath[] {classPathRegistered});
IndexingManager.getDefault().refreshAllIndices(true, true, getWorkDir());
started.await();
info.getClassIndex().removeClassIndexListener(listener);
SourceUtils.waitScanFinished();
}
}
Expand Down

0 comments on commit 0a5a17e

Please sign in to comment.