What version of Delve are you using (dlv version)?
1.22.1
What version of Go are you using? (go version)?
go version go1.22.0 darwin/arm64
What operating system and processor architecture are you using?
macOS 14.5, arm64
What did you do?
$ dlv test ./withtestmain -- -test.run ^TestDebug$
#Type 'help' for list of commands.
(dlv) b TestDebug:1
#Breakpoint 1 set at 0x1021c23cc for github.com/jnathanh/delve-test-main/withtestmain_test.TestDebug() #./withtestmain/debug_test.go:13
(dlv) c
What did you expect to see?
> github.com/jnathanh/delve-test-main/withouttestmain.TestDebug() ./withouttestmain/debug_test.go:9 (hits goroutine(21):1 total:1) (PC: 0x1001c5e6c)
4: "fmt"
5: "testing"
6: )
7:
8: func TestDebug(t *testing.T) {
=> 9: fmt.Println("stopping on a breakpoint in this test works with delve")
10: }
What did you see instead?
TestMain
Process 52848 has exited with status 0
To repro:
Clone this repo and try and stop on a breakpoint in the TestDebug function in the withtestmain package. Setting the breakpoint succeeds, but I am unable to stop on it. You can do the same in the withouttestmain package without a problem. The only material difference is the presence of a TestMain function, with the *testing.M parameter.
I originally encountered this in vscode executing the "debug test" functionality and it took a few hours to narrow down the issue. Ideally the breakpoint would work, but if that is not possible, I would at least want delve to throw an error or output a warning to indicate the issue and give some indication of how I can work around it.
dlv version
)?go version
)?To repro:
Clone this repo and try and stop on a breakpoint in the
TestDebug
function in thewithtestmain
package. Setting the breakpoint succeeds, but I am unable to stop on it. You can do the same in thewithouttestmain
package without a problem. The only material difference is the presence of aTestMain
function, with the*testing.M
parameter.I originally encountered this in vscode executing the "debug test" functionality and it took a few hours to narrow down the issue. Ideally the breakpoint would work, but if that is not possible, I would at least want delve to throw an error or output a warning to indicate the issue and give some indication of how I can work around it.