Skip to content
Draft
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
15 changes: 5 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1575,8 +1575,8 @@ jobs:
- name: debugger.jpda.projectsui
run: ant $OPTS -f java/debugger.jpda.projectsui test

# - name: debugger.jpda.truffle
# run: ant $OPTS -f java/debugger.jpda.truffle test
- name: debugger.jpda.truffle
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, I am really glad to see the tests being run regularly!

run: ant $OPTS -f java/debugger.jpda.truffle test

- name: debugger.jpda.ui
run: ant $OPTS -f java/debugger.jpda.ui test-unit
Expand Down Expand Up @@ -2560,9 +2560,7 @@ jobs:
timeout-minutes: 60
strategy:
matrix:
# TODO uses GraalVM 17 / 22.3.1 which is the last known release which offers all required language extensions
# GraalVM based on JDK 21+ doesn't support the 'gu' tool anymore - extensions are now regular application dependencies
graal: [ '22.3.1' ]
graal: [ '21.0.2' ]
fail-fast: false

steps:
Expand All @@ -2581,14 +2579,11 @@ jobs:

- name: Setup GraalVM ${{ matrix.graal }}
run: |
URL=https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${{ matrix.graal }}/graalvm-ce-java17-linux-amd64-${{ matrix.graal }}.tar.gz
URL=https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${{ matrix.graal }}/graalvm-community-jdk-${{ matrix.graal }}_linux-x64_bin.tar.gz
curl -L $URL | tar -xz
GRAALVM=`pwd`/graalvm-ce-java17-${{ matrix.graal }}
GRAALVM=`pwd`/graalvm-community-jdk-${{ matrix.graal }}
Comment on lines -2586 to +2584
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the extracted folder is now different from the archive name.

this worked for me locally:

GRAALVM=$(realpath graalvm-community-openjdk-*)

echo "JAVA_HOME=$GRAALVM" >> $GITHUB_ENV

- name: Setup GraalVM Languages (python, R, ruby and js)
run: $JAVA_HOME/bin/gu install --no-progress python R ruby js

- name: platform/core.network
run: ant $OPTS -f platform/core.network test

Expand Down
21 changes: 12 additions & 9 deletions java/debugger.jpda.truffle/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@
<test-dependencies>
<test-type>
<name>unit</name>
<test-dependency>
<code-name-base>org.netbeans.api.debugger.jpda</code-name-base>
<recursive/>
<compile-dependency/>
<test/>
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.core.startup</code-name-base>
<recursive/>
Expand All @@ -266,25 +272,22 @@
<code-name-base>org.netbeans.libs.freemarker</code-name-base>
<recursive/>
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.libs.graaljs</code-name-base>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graal.js is packaged as NetBeans module, so reusing it is a great idea.

</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.libs.javacapi</code-name-base>
<recursive/>
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.modules.debugger.jpda</code-name-base>
<compile-dependency/>
<test/>
<code-name-base>org.netbeans.libs.junit4</code-name-base>
<compile-dependency/>
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.api.debugger.jpda</code-name-base>
<recursive/>
<code-name-base>org.netbeans.modules.debugger.jpda</code-name-base>
<compile-dependency/>
<test/>
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.libs.junit4</code-name-base>
<compile-dependency/>
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.modules.nbjunit</code-name-base>
<recursive/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,6 @@ public void testBreakpoints_JS() throws Exception {
runBreakpointsTest(JS_LAUNCHER);
}

public void testBreakpoints_Python() throws Exception {
runBreakpointsTest(PYTHON_LAUNCHER);
}

public void testBreakpoints_R() throws Exception {
runBreakpointsTest(RSCRIPT_LAUNCHER);
}

public void testBreakpoints_Ruby() throws Exception {
runBreakpointsTest(RUBY_LAUNCHER);
}

private void runBreakpointsTest(String launcher) throws Exception {
File source = getScriptSourceFileForLauncher(launcher);
DebuggerManager dm = DebuggerManager.getDebuggerManager();
Expand All @@ -99,18 +87,6 @@ public void testBreakpointsConditional_JS() throws Exception {
runBreakpointsConditionalTest(JS_LAUNCHER);
}

public void testBreakpointsConditional_Python() throws Exception {
runBreakpointsConditionalTest(PYTHON_LAUNCHER);
}

public void testBreakpointsConditional_R() throws Exception {
runBreakpointsConditionalTest(RSCRIPT_LAUNCHER);
}

public void testBreakpointsConditional_Ruby() throws Exception {
runBreakpointsConditionalTest(RUBY_LAUNCHER);
}

public void runBreakpointsConditionalTest(String launcher) throws Exception {
File source = getScriptSourceFileForLauncher(launcher);
DebuggerManager dm = DebuggerManager.getDebuggerManager();
Expand Down Expand Up @@ -141,18 +117,6 @@ public void testSteps_JS() throws Exception {
runStepsTest(JS_LAUNCHER);
}

public void testSteps_Python() throws Exception {
runStepsTest(PYTHON_LAUNCHER);
}

public void testSteps_R() throws Exception {
runStepsTest(RSCRIPT_LAUNCHER);
}

public void testSteps_Ruby() throws Exception {
runStepsTest(RUBY_LAUNCHER);
}

public void runStepsTest(String launcher) throws Exception {
File source = getScriptSourceFileForLauncher(launcher);
DebuggerManager dm = DebuggerManager.getDebuggerManager();
Expand All @@ -177,18 +141,6 @@ public void testEval_JS() throws Exception {
runEvalTest(JS_LAUNCHER);
}

public void testEval_Python() throws Exception {
runEvalTest(PYTHON_LAUNCHER);
}

public void testEval_R() throws Exception {
runEvalTest(RSCRIPT_LAUNCHER);
}

public void testEval_Ruby() throws Exception {
runEvalTest(RUBY_LAUNCHER);
}

public void runEvalTest(String launcher) throws Exception {
File source = getScriptSourceFileForLauncher(launcher);
DebuggerManager dm = DebuggerManager.getDebuggerManager();
Expand Down Expand Up @@ -226,18 +178,6 @@ public void testLocalVariables_JS() throws Exception {
runLocalVariablesTest(JS_LAUNCHER);
}

public void testLocalVariables_Python() throws Exception {
runLocalVariablesTest(PYTHON_LAUNCHER);
}

public void testLocalVariables_R() throws Exception {
runLocalVariablesTest(RSCRIPT_LAUNCHER);
}

public void testLocalVariables_Ruby() throws Exception {
runLocalVariablesTest(RUBY_LAUNCHER);
}

public void runLocalVariablesTest(String launcher) throws Exception {
File source = getScriptSourceFileForLauncher(launcher);
DebuggerManager dm = DebuggerManager.getDebuggerManager();
Expand Down Expand Up @@ -286,18 +226,6 @@ public void testObjectProperties_JS() throws Exception {
runObjectPropertiesTest(JS_LAUNCHER);
}

public void testObjectProperties_Python() throws Exception {
runObjectPropertiesTest(PYTHON_LAUNCHER);
}

public void testObjectProperties_R() throws Exception {
runObjectPropertiesTest(RSCRIPT_LAUNCHER);
}

public void testObjectProperties_Ruby() throws Exception {
runObjectPropertiesTest(RUBY_LAUNCHER);
}

public void runObjectPropertiesTest(String launcher) throws Exception {
File source = getScriptSourceFileForLauncher(launcher);
DebuggerManager dm = DebuggerManager.getDebuggerManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
package org.netbeans.modules.debugger.jpda.truffle;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import java.util.logging.Level;
import junit.framework.Test;
import junit.framework.TestCase;
import org.netbeans.api.debugger.jpda.DebuggerStartException;
import org.netbeans.api.debugger.jpda.JPDADebugger;
import org.netbeans.api.debugger.jpda.JPDASupport;
import org.netbeans.api.debugger.jpda.JPDAThread;
Expand All @@ -39,6 +43,10 @@

public abstract class JPDATestCase extends NbTestCase {

private static final Map<String, String> LAUNCHER_TO_MAIN_CLASS = Map.of(
"js", "com.oracle.truffle.js.shell.JSLauncher"
);

protected final File sourceRoot = new File(System.getProperty("test.dir.src"));

protected static Test createSuite(Class<? extends TestCase> clazz) {
Expand Down Expand Up @@ -80,10 +88,10 @@ protected final File getJavaSourceFile(String javaFileName) {
}

protected final void runScriptUnderJPDA(String launcher, String scriptPath, ThrowableConsumer<JPDASupport> supportConsumer) throws Exception {
assertTrue("'"+launcher+"' launcher not available", JPDASupport.isLauncherAvailable(launcher));
assertTrue("does not have launcher - main class mapping", LAUNCHER_TO_MAIN_CLASS.containsKey(launcher));
// Translate script path from source dir to target dir:
scriptPath = getBinariesPath(scriptPath);
JPDASupport support = JPDASupport.attachScript(launcher, scriptPath);
JPDASupport support = attachScript(launcher, scriptPath);
run(support, supportConsumer, false);
}

Expand Down Expand Up @@ -133,6 +141,15 @@ protected static TruffleVariable findVariable(TruffleScope scope, String name) {
return null;
}

public static JPDASupport attachScript(String launcher, String path) throws IOException, DebuggerStartException {
return JPDASupport.attach(LAUNCHER_TO_MAIN_CLASS.get(launcher),
new String[] {path},
Arrays.stream(System.getProperty("java.class.path")
.split(File.pathSeparator))
.map(loc -> new File(loc))
.toArray(File[]::new));
}

@FunctionalInterface
protected interface ThrowableConsumer<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,50 +209,10 @@ public static JPDASupport attach (String[] vmArgs, String mainClass, String[] ar
return new JPDASupport (jpdaDebugger, pio);
}

public static JPDASupport attachScript(String launcher, String path) throws IOException, DebuggerStartException {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge simplification by deleting a lot of code. Good work!

String [] cmdArray = new String [] {
launcherPath(launcher),
"--jvm",
"--vm.agentlib:jdwp=transport=dt_socket,suspend=y,server=y",
path
};
Process process = Runtime.getRuntime ().exec (cmdArray);
String line = readLine (process.getInputStream ());
int port = Integer.parseInt (line.substring (line.lastIndexOf (':') + 1).trim ());
ProcessIO pio = new ProcessIO (process);
pio.go();

VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
List aconnectors = vmm.attachingConnectors();
AttachingConnector connector = null;
for (Iterator i = aconnectors.iterator(); i.hasNext();) {
AttachingConnector ac = (AttachingConnector) i.next();
Transport t = ac.transport ();
if (t != null && t.name().equals("dt_socket")) {
connector = ac;
break;
}
}
if (connector == null) {
throw new RuntimeException("No attaching socket connector available");
}

JPDADebugger jpdaDebugger = JPDADebugger.attach (
"localhost",
port,
new Object[]{}
);
return new JPDASupport(jpdaDebugger, pio);
}

private static String launcherPath(String launcher) {
return System.getProperty("java.home") + File.separatorChar + "bin" + File.separatorChar + launcher;
}

public static boolean isLauncherAvailable(String launcher) {
return Files.exists(Paths.get(launcherPath(launcher)));
}

// public interface ........................................................

public void doContinue () {
Expand Down
Loading