-
Notifications
You must be signed in to change notification settings - Fork 752
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
Test does not run correctly if subtest name contains regexp metacharacters #3070
Comments
This is due to the use of |
Ah interesting. I ran into this issue with my actual test suite and when putting this minimal reproduction together for this report, I was able to reproduce it because I happened to also choose a character that was a regexp metacharacter. You can see I even tested whether the test name was related to the issue by changing my test name in this minimal reproduction from I don't recall what the test names were in my actual codebase, but if it would help with solving this issue I can go back to it and try this again, and report back. |
I fixed this (by chance this morning!) in https://go.dev/cl/546419 (see gopls/internal/server/command.go), when I noticed the code looked wrong. I confirmed the fix using VS Code and the gopls binary before/after this commit. Run |
Thanks Alan. But VS Code Go extension does not use gopls for its test and debug execution functionality. p.s does gopls test codelens already support subtests? That will be great. EDIT: the relevant code location is more deep in the test explorer run.ts. Keep looking... |
Funny, that's what I thought, but I tested the old and new gopls binaries, ABAB, and got consistent results. How strange.
The codelens only lists top-level functions. But the the executeCommand(gopls.test) operation accepts any test name, including subtests, and passes it straight through to go test. I assumed that VS Code was using its native logic to figure out the names of all the subtests, but executeCommand to re-run a selected subtest. |
VS Code uses completely separate logic and implementation. |
Thanks for clarifying. I just checked again and now I can't reproduce what I saw before. Sorry for the confusion. |
Change https://go.dev/cl/546260 mentions this issue: |
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.go version go1.21.3 linux/amd64
gopls -v version
to get version of Gopls from the VS Code integrated terminal.v0.14.2
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.1.84.2
v0.40.0
Go: Locate Configured Go Tools
command.Share the Go related settings you have added/edited
Run
Preferences: Open Settings (JSON)
command to open your settings.json file.Share all the settings with the
go.
or["go"]
orgopls
prefixes.Describe the bug
I expected that when clicking on "Debug Test" for a subtest in the test explorer, with a valid breakpoint set, my breakpoint would be hit. Instead, my breakpoint isn't hit, and I get a message in the debug console telling me that there are "no tests to run".
Steps to reproduce the behavior:
Complete these steps as I did earlier...
I created a function and a test table for it using
Go: Generate Unit Tests For Function
from the command palette. I filled in the test table with one test that I expected to pass and one that I expected to fail. My code:I opened the test explorer tab:
I clicked "Run Test" on the root test (where my module name is). It then ran my tests:
I added a break point to my test body:
I clicked "Debug Test" just for that subtest/test table entry:
My breakpoint was not hit. The process finished and the debug console displayed:
I clicked "Debug Test" at the test level instead of the subtest level:
This time, my breakpoint was hit, presumably because all of the subtests are being run now, in debug mode:
The text was updated successfully, but these errors were encountered: