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

Cleanup VirtualThreadTest #507

Merged
merged 1 commit into from
Sep 23, 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
2 changes: 1 addition & 1 deletion org.eclipse.jdt.debug.jdi.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: JDI Tests
Bundle-SymbolicName: org.eclipse.jdt.debug.jdi.tests; singleton:=true
Bundle-Version: 1.1.100.qualifier
Bundle-Version: 1.1.200.qualifier
Bundle-ClassPath: .
Bundle-Vendor: Eclipse
Require-Bundle: org.junit,
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.debug.jdi.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.debug.jdi.tests</artifactId>
<version>1.1.100-SNAPSHOT</version>
<version>1.1.200-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
package org.eclipse.debug.jdi.tests;

import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Locale;

Expand Down Expand Up @@ -56,10 +58,6 @@ public class VirtualThreadTest extends AbstractJDITest {
private ThreadReference fThread;
private ThreadReference fMainThread;

public VirtualThreadTest() {
fVmArgs = "--enable-preview";
}

/**
* Init the fields that are used by this test only.
*/
Expand All @@ -82,7 +80,13 @@ public void localTearDown() {

@Override
protected void setUp() {
compileTestProgram();
try {
compileTestProgram();
} catch (Exception e) {
StringWriter err = new StringWriter();
e.printStackTrace(new PrintWriter(err));
fail("Error in setup: " + err.toString());
}
super.setUp();
}

Expand All @@ -91,12 +95,12 @@ public void setVMInfo(VMInformation info) {
// do nothing
}

public static void main(String[] args) {
public static void main(String[] args) throws Exception {
compileTestProgram();
new VirtualThreadTest().runSuite(args);
}

protected static void compileTestProgram() {
protected static void compileTestProgram() throws Exception {
if (Runtime.version().feature() < 19) {
return;
}
Expand All @@ -106,20 +110,21 @@ protected static void compileTestProgram() {
compileFiles(sourceFilePath, outputFilePath);
}

private static void compileFiles(String sourceFilePath, String outputPath) {
private static void compileFiles(String sourceFilePath, String outputPath) throws Exception {
DiagnosticCollector<? super JavaFileObject> diagnosticCollector = new DiagnosticCollector<>();
StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnosticCollector, Locale.ENGLISH, StandardCharsets.UTF_8);
Iterable<? extends JavaFileObject> javaFileObjects = fileManager.getJavaFileObjects(new File(sourceFilePath));
File outputFolder = new File(outputPath);
if (!outputFolder.exists()) {
outputFolder.mkdir();
Files.createDirectories(outputFolder.toPath());
}
String[] options = new String[] { "--release", "21", "-d", outputFolder.getAbsolutePath(), "-g", "-proc:none" };
final StringWriter output = new StringWriter();
CompilationTask task = compiler.getTask(output, fileManager, diagnosticCollector, Arrays.asList(options), null, javaFileObjects);
boolean result = task.call();
if (!result) {
throw new IllegalArgumentException("Compilation failed:\n" + output);
throw new IllegalArgumentException("Compilation failed:\n'" + output + "', compiler name: '" + compiler.name()
+ "', supported source versions: " + compiler.getSourceVersions());
}

}
Expand Down