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
4 changes: 2 additions & 2 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
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
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>
</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,17 +63,17 @@ 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);
}
// 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);
Expand All @@ -99,17 +99,17 @@ 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 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);
Expand Down Expand Up @@ -141,17 +141,17 @@ 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 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);
Expand All @@ -177,17 +177,17 @@ 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 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);
Expand Down Expand Up @@ -226,17 +226,17 @@ 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 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);
Expand Down Expand Up @@ -286,17 +286,17 @@ 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 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);
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 {
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