Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve stability of Java code completion (sealed) tests. #8066

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading