Skip to content

VSCode: Running all tests in project fixed.#7993

Merged
dbalek merged 1 commit intoapache:masterfrom
dbalek:dbalek/vscode-test-project-fix
Dec 2, 2024
Merged

VSCode: Running all tests in project fixed.#7993
dbalek merged 1 commit intoapache:masterfrom
dbalek:dbalek/vscode-test-project-fix

Conversation

@dbalek
Copy link
Copy Markdown
Contributor

@dbalek dbalek commented Nov 26, 2024

If running tests, do not add the mainClass attribute if it is missing. On the server side it causes invocation of a single file action instead of a project action.

@dbalek dbalek added this to the NB25 milestone Nov 26, 2024
@dbalek dbalek requested review from MartinBalin and sdedic November 26, 2024 10:13
@dbalek dbalek self-assigned this Nov 26, 2024
@lahodaj
Copy link
Copy Markdown
Contributor

lahodaj commented Nov 26, 2024

This may need a bit more, to avoid the mainClass/mainFilePath being re-computed in NbLaunchRequestHandler. Unless I am missing something. Seems like something like this:

diff --git a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchRequestHandler.java b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchRequestHandler.java
index 8fe3046049..0b1a26d387 100644
--- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchRequestHandler.java
+++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchRequestHandler.java
@@ -87,9 +87,10 @@ public final class NbLaunchRequestHandler {
         String filePath = (String)launchArguments.get("file");
         String projectFilePath = (String)launchArguments.get("projectFile");
         String mainFilePath = (String)launchArguments.get("mainClass");
+        boolean testRun = (Boolean) launchArguments.getOrDefault("testRun", Boolean.FALSE);
 
         if (!isNative && (StringUtils.isBlank(mainFilePath) && StringUtils.isBlank(filePath) && StringUtils.isBlank(projectFilePath)
-                          || modulePaths.isEmpty() && classPaths.isEmpty())) {
+                          || modulePaths.isEmpty() && classPaths.isEmpty()) && !testRun) {
             if (modulePaths.isEmpty() && classPaths.isEmpty()) {
                 ErrorUtilities.completeExceptionally(resultFuture,
                     "Failed to launch debuggee VM. Missing modulePaths/classPaths options in launch configuration.",
@@ -244,7 +245,6 @@ public final class NbLaunchRequestHandler {
             context.setSourcePaths((String[]) launchArguments.get("sourcePaths"));
         }
         String singleMethod = (String)launchArguments.get("methodName");
-        boolean testRun = (Boolean) launchArguments.getOrDefault("testRun", Boolean.FALSE);
         activeLaunchHandler.nbLaunch(file, preferProjActions, nativeImageFile, singleMethod, launchArguments, context, !noDebug, testRun, new OutputListener(context)).thenRun(() -> {
             activeLaunchHandler.postLaunch(launchArguments, context);
             resultFuture.complete(null);

@dbalek dbalek requested a review from lahodaj November 27, 2024 09:39
@dbalek dbalek force-pushed the dbalek/vscode-test-project-fix branch from af13f60 to b559da9 Compare November 27, 2024 10:14
@dbalek
Copy link
Copy Markdown
Contributor Author

dbalek commented Nov 27, 2024

This may need a bit more, to avoid the mainClass/mainFilePath being re-computed in NbLaunchRequestHandler.

Fixed. Thanks for pointing this out.

Copy link
Copy Markdown
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@dbalek dbalek merged commit f7ec163 into apache:master Dec 2, 2024
@dbalek dbalek deleted the dbalek/vscode-test-project-fix branch December 2, 2024 11:22
Achal1607 added a commit to Achal1607/netbeans that referenced this pull request Feb 24, 2025
Achal1607 added a commit to Achal1607/netbeans that referenced this pull request Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants