Skip to content

Commit

Permalink
CompletionHandlerTest.testCompletion_Lambda fails randomly
Browse files Browse the repository at this point in the history
  • Loading branch information
snjeza committed Sep 3, 2024
1 parent 67ff3b0 commit b12029e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3461,7 +3461,7 @@ public void testCompletion_Lambda() throws Exception {
assertNotNull(lambda);
assertTrue(lambda.getTextEdit().getLeft().getNewText().matches("\\$\\{1:\\w+\\} -> \\$\\{0\\}"));

assertEquals(lambda.getLabel(), "(Object arg0) ->");
assertEquals("(Object arg0) ->", lambda.getLabel());
assertNull(lambda.getLabelDetails().getDetail());
assertEquals(lambda.getLabelDetails().getDescription(), "void");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,20 @@

public class JavaFXTest extends AbstractProjectsManagerBasedTest {

private static final String VERSION_1_8 = "1.8";
private static final String JAVA_SE_8 = "JavaSE-1.8";
private static final String JAVA_SE_17 = "JavaSE-17";

/**
* Test musts run with the -Djdkfx8.home=/path/to/jdk8+fx System property, or it
* will be skipped.
* Test requires Java 8 in toolchains.xml
*/
@Test
public void testJavaFX() throws Exception {
IVMInstall defaultJRE = JavaRuntime.getDefaultVMInstall();
String name = "java8fx";
IProject project = null;
IExecutionEnvironment java8env = JVMConfigurator.getExecutionEnvironment(JAVA_SE_8);
IVMInstall oldJavaVm = java8env.getDefaultVM();
try {
IExecutionEnvironment java8env = JVMConfigurator.getExecutionEnvironment(JAVA_SE_8);
IVMInstall java8vm = null;
IVMInstall java8DefaultVm = null;
if (java8env != null) {
Expand Down Expand Up @@ -89,6 +88,7 @@ public void testJavaFX() throws Exception {
if (environment != null) {
environment.setDefaultVM(defaultJRE);
}
java8env.setDefaultVM(oldJavaVm);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
import org.eclipse.jdt.core.WorkingCopyOwner;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.jdt.core.manipulation.CoreASTProvider;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMInstallType;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
import org.eclipse.jdt.ls.core.internal.DocumentAdapter;
import org.eclipse.jdt.ls.core.internal.JDTUtils;
import org.eclipse.jdt.ls.core.internal.JavaClientConnection.JavaLanguageClient;
Expand All @@ -76,6 +81,7 @@
import org.eclipse.jdt.ls.core.internal.ProjectUtils;
import org.eclipse.jdt.ls.core.internal.ResourceUtils;
import org.eclipse.jdt.ls.core.internal.SimpleLogListener;
import org.eclipse.jdt.ls.core.internal.TestVMType;
import org.eclipse.jdt.ls.core.internal.WorkspaceHelper;
import org.eclipse.jdt.ls.core.internal.handlers.BundleUtils;
import org.eclipse.jdt.ls.core.internal.handlers.ProgressReporterManager;
Expand Down Expand Up @@ -137,6 +143,22 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
public static void initJVMs() {
JobHelpers.waitForLookupJDKToolchainsJob(600000);
CorePlugin.publishedGradleVersions().getVersions();
// see https://github.com/eclipse-jdtls/eclipse.jdt.ls/issues/3261
IVMInstallType[] vmInstallTypes = JavaRuntime.getVMInstallTypes();
for (IVMInstallType vmInstallType : vmInstallTypes) {
if (vmInstallType instanceof TestVMType) {
for (IVMInstall vm : vmInstallType.getVMInstalls()) {
IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
IExecutionEnvironment[] environments = manager.getExecutionEnvironments();
for (IExecutionEnvironment environment : environments) {
if (environment.isStrictlyCompatible(vm)) {
environment.setDefaultVM(vm);
break;
}
}
}
}
}
}

@Before
Expand Down

0 comments on commit b12029e

Please sign in to comment.