Skip to content

Commit

Permalink
Try to fix & clean up VirtualThreadsDebugViewTests
Browse files Browse the repository at this point in the history
+ add java23 to build.properties to fix failures on the build server
+ change explicit (duplicate) creation to the normal style 'assert...'
+ allow running it on 23+
  • Loading branch information
stephan-herrmann committed Feb 4, 2025
1 parent 2e98d98 commit 6135b1e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 34 deletions.
1 change: 1 addition & 0 deletions org.eclipse.jdt.debug.tests/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ bin.includes = plugin.xml,\
java8/,\
java9/,\
java16_/,\
java23/,\
java24/
source.javadebugtests.jar = test plugin/,\
tests/,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ public static boolean isJava21_Compatible() {
return isCompatible(21);
}

/**
* Returns if the currently running VM is version compatible with Java 23
*
* @return <code>true</code> if a Java 23 (or greater) VM is running <code>false</code> otherwise
*/
public static boolean isJava23_Compatible() {
return isCompatible(23);
}

/**
* Returns if the currently running VM is version compatible with Java 24
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
private static boolean loaded9 = false;
private static boolean loaded16_ = false;
private static boolean loaded21 = false;
private static boolean loaded23 = false;
private static boolean loaded24 = false;
private static boolean loadedEE = false;
private static boolean loadedJRE = false;
Expand Down Expand Up @@ -626,6 +627,34 @@ synchronized void assert21Project() {
}
}

synchronized void assert23Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loaded23) {
jp = createProject(TWENTYTHREE_PROJECT_NAME, JavaProjectHelper.TEST_23_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_23_EE_NAME, false);
jp.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_23);
jp.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_23);
cfgs.add(createLaunchConfiguration(jp, "Main21"));
loaded23 = true;
waitForBuild();
assertNoErrorMarkersExist(jp.getProject());
}
} catch (Exception e) {
try {
if (jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
} catch (CoreException ce) {
// ignore
}
handleProjectCreationException(e, TWENTYTHREE_PROJECT_NAME, jp);
}
}

/**
* Creates the Java 24 compliant project
*/
Expand Down Expand Up @@ -957,6 +986,16 @@ protected IJavaProject get21Project() {
return getJavaProject(TWENTYONE_PROJECT_NAME);
}

/**
* Returns the 'Two_Three' project, used for Java 23 tests.
*
* @return the test project
*/
protected IJavaProject get23Project() {
assert23Project();
return getJavaProject(TWENTYTHREE_PROJECT_NAME);
}

/**
* Returns the 'Two_Four' project, used for Java 24 tests.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public AutomatedSuite() {
if (JavaProjectHelper.isJava16_Compatible()) {
addTest(new TestSuite(RecordBreakpointTests.class));
}
if (Runtime.version().feature() == 24 && JavaProjectHelper.isJava24_Compatible()) {
if (JavaProjectHelper.isJava23_Compatible()) {
addTest(new TestSuite(VirtualThreadsDebugViewTests.class));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@
*******************************************************************************/
package org.eclipse.jdt.debug.tests.ui;

import java.util.ArrayList;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.internal.ui.views.console.ProcessConsole;
Expand All @@ -31,10 +27,8 @@
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IDebugView;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.debug.core.IJavaBreakpoint;
import org.eclipse.jdt.debug.core.IJavaThread;
import org.eclipse.jdt.debug.testplugin.JavaProjectHelper;
import org.eclipse.jdt.debug.tests.TestUtil;
import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
import org.eclipse.jdt.internal.debug.core.model.JDIThread;
Expand Down Expand Up @@ -86,33 +80,7 @@ protected void tearDown() throws Exception {

@Override
protected IJavaProject getProjectContext() {
create23Project();
return getJavaProject(TWENTYTHREE_PROJECT_NAME);
}

synchronized void create23Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
jp = createProject(TWENTYTHREE_PROJECT_NAME, JavaProjectHelper.TEST_23_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_23_EE_NAME, false);
jp.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_23);
jp.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_23);
cfgs.add(createLaunchConfiguration(jp, "Main21"));
waitForBuild();
assertNoErrorMarkersExist(jp.getProject());
} catch (Exception e) {
try {
if (jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
} catch (CoreException ce) {
// ignore
}
super.handleProjectCreationException(e, TWENTYTHREE_PROJECT_NAME, jp);
}
return get23Project();
}

public void testVirtualThreadDebugView() throws Exception {
Expand Down

0 comments on commit 6135b1e

Please sign in to comment.