-
Notifications
You must be signed in to change notification settings - Fork 797
Add Bazel Run/Debug Support to GoTestRunner #2539
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
Comments
/cc @hyangah for any feedback on supporting run/debug for Bazel. |
Interestingly enough, this need not be a bazel specific thing. Rather, vscode-go could be made a somewhat more flexible:
To my opinion, making vscode-go work with bazel like build system does not seem like a major undertaking and it's a pity something like this was not done already. |
We implemented small wrappers around go and dlv, which will be called by vscode instead of the actual binaries. These wrappers then call bazel with the correct arguments to discover and build artifacts and in the dlv case, forward them to dlv for debugging. With this, we're able to debug mains and tests (mostly) without issues. Direct support in either this extension or rules_go would be nice though. Here is for example what I wrote for dlv: https://gist.github.com/bluec0re/af19ded857749fd2ec145f4e06f0e9b3 |
Thanks, this is very useful for anyone affected by this. Any chance you could also provide the Thanks |
We ended up using a fork. This is a bit out of date (https://github.com/uber/vscode-go) but we keep it up to date internally - basically using a modified version of the GoTestExplorer that parses executes via Bazel and then parses the build events. I'm also curious to see what the wrapped Go command above looks like. We took this approach a couple of years ago because there were other issues (such as different output paths for coverage files, parsing the test.xml results from build events, selecting correct flags/test filter formatting) that seem like they might be a bit hard to fully control by just overriding On a related note, @firelizzard18 has been doing some ongoing work to move test discovery into gopls (https://github.com/golang/vscode-go/blob/master/docs/experiments.md#test-explorer, #2504 (comment)) - I have not had a chance to try it out yet but maybe there is opportunity there as well to add some kind of integration point that defers to Bazel and then receives a response in some standard format (thinking something similar to how gopls is able to use gopackagesdriver to request package info, maybe there is possibility to let users to provide their own test executor that can receive/return responses in some standard format and provide a way to delegate the run to Bazel. |
I am open to contributions to Go Companion. If you do contribute, please keep in mind that the eventual goal is to merge my extension (or at least the test explorer system) into vscode-go, so contributions will be held to that standard.
That would be ideal; however while the gopls team and I have discussed leaning on gopls for test execution that hasn't gotten much past "it would be neat". My point is, currently execution of tests is 100% handled by vscode-go and has nothing to do with gopls. The only way in which the test system interacts with gopls is that the newest version (Go Companion) uses gopls for discovery. So it would be admittedly elegant and powerful if we used something like gopackagesdriver, but that would be a long term project, not something that could get completed in a couple weeks. If someone wants to work on it today, here is the code; specifically |
On my side, I've got a bazel rule + go helper binary. The helper binary diffs and edits the "launch.json" file in the ".vscode" dir under the workspace it's working in. So it's a 2 step process: 1. "run" the appropriate bazel rule. 2. "click" on the magically prepared job in vscode. |
@csobrinho I updated the gist with the missing files |
Is your feature request related to a problem? Please describe.
Our team uses Bazel with our Go projects. Currently, this extension is able to discover tests but the run/debug functionalities do not work correctly since they run
go
commands instead of Bazel.Describe the solution you'd like
Allow customizable user option to use Bazel to run/debug tests. Override a few of the methods in GoTestRunner with an alternate implementation that runs the Bazel version of the needed command. Add parsing of Bazel build events to report pass/fail status.
Describe alternatives you've considered
GoTestExplorer
with the missing Bazel functionality. Users that wish to use this functionality could then turn off the test explorer setting on this extension, then run the separate extension side-by-side with this one. Not ideal due to the overhead of maintaining a separate extension / project where only a few areas of functionality actually differ.Additional context
Would also be open to any other general feedback about how other teams are supporting Run/Debug functionality in the IDE for Bazel users (other than command line, which is our current state).
The text was updated successfully, but these errors were encountered: