fix: decouple Gradle test delegation from BSP import#1810
Draft
wenytang-ms wants to merge 4 commits intodevelopfrom
Draft
fix: decouple Gradle test delegation from BSP import#1810wenytang-ms wants to merge 4 commits intodevelopfrom
wenytang-ms wants to merge 4 commits intodevelopfrom
Conversation
Replace the BSP-dependent test execution path (java.gradle.delegateTest) with direct Gradle task execution via the existing runBuild API. Previously, 'Delegate to Gradle' required the project to be imported via Gradle Build Server (BSP). If the project was imported via Buildship or any other method, the feature would silently fail with no test results and no error message shown to the user. The new implementation: - Runs 'gradle test --tests <filter>' through the Gradle Language Server - Parses JUnit XML results from build/test-results/ after execution - Works for ALL Gradle projects regardless of import method - Preserves debug support via init script injection - Keeps the same TestRunner interface contract with vscode-java-test Fixes microsoft/vscode-java-test#1771 Fixes microsoft/vscode-java-test#1726 Fixes #1802 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
The init script sets suspend=y, causing the test JVM to block until the debugger connects. startJavaDebug must be called before awaiting runBuild, otherwise neither side can proceed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Delegate to Gradletest execution only works when the project is imported via Gradle Build Server (BSP). If the project was imported via Buildship or any other method, the feature silently fails — no test results, no error message. This affects a significant number of users, especially those with:falsefor these)Create a new Java Projectwizard (incremental import path is hardcoded toreturn falsein BSP importer)The root cause is that
GradleDelegateCommandHandler.javarequiresGradleBuildServerProjectNature, which is only present on BSP-imported projects. When absent, it throwsIllegalArgumentException, which is caught silently.Solution
Decouple test execution from BSP by replacing the
java.gradle.delegateTestBSP command with direct Gradle task execution via the existingrunBuildAPI (Gradle Language Server / gRPC).Key changes:
GradleTestRunner.ts: Rewrittenlaunch()to rungradle test --tests <filter>throughTaskServerClient.runBuild(), then parse JUnit XML results frombuild/test-results/testResultParser.ts(new): Parses standard JUnit XML test result filesBuildServerController.ts: BSP test callbacks replaced with no-ops for backward compatibilityExtension.ts: Test runner now receivesTaskServerClientdirectly instead of going throughBuildServerControllerWhat this means:
Delegate to Gradlenow works for ALL Gradle projects regardless of import methodTestRunnerinterface contract withvscode-java-test— no changes needed thereTrade-off: Test results are reported after Gradle finishes (batch) rather than streamed in real-time via BSP notifications. For single test runs (the most common case), this has no visible impact.
Related Issues
Fixes microsoft/vscode-java-test#1771
Fixes microsoft/vscode-java-test#1726
Fixes #1802
Related: microsoft/vscode-java-test#1045