Skip to content

Commit

Permalink
honoring bypass go flags when debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
xhd2015 committed Nov 2, 2024
1 parent 1d8b33c commit 0851e4e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions cmd/xgo/test-explorer/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ func debug(ctx *RunContext) error {
args := ctx.Args
env := ctx.Env

err := debugTest(goCmd, projectDir, file, buildFlags, []string{"./" + filepath.Dir(relPath)}, fmt.Sprintf("^%s$", name), stdout, stderr, args, env)
err := debugTest(goCmd, projectDir, file, buildFlags, []string{"./" + filepath.Dir(relPath)}, false, fmt.Sprintf("^%s$", name), stdout, stderr, args, env)
if err != nil {
return err
}
return nil
}

func debugTest(goCmd string, dir string, file string, buildFlags []string, buildArgs []string, runNames string, stdout io.Writer, stderr io.Writer, args []string, env []string) error {
func debugTest(goCmd string, dir string, file string, buildFlags []string, buildArgs []string, bypassGoFlags bool, runNames string, stdout io.Writer, stderr io.Writer, args []string, env []string) error {
if goCmd == "" {
goCmd = "go"
}
Expand Down Expand Up @@ -91,7 +91,12 @@ func debugTest(goCmd string, dir string, file string, buildFlags []string, build
fmt.Fprintln(stderr, debug_util.FormatDlvPrompt(port))
}, func(port int) error {
// dlv exec --api-version=2 --listen=localhost:2345 --accept-multiclient --headless ./debug.bin
runArgs := append([]string{"-test.v", "-test.run", runNames}, args...)
runArgs := make([]string, 0, 3+len(args))
runArgs = append(runArgs, "-test.v", "-test.run", runNames)
if bypassGoFlags {
runArgs = append(runArgs, "--")
}
runArgs = append(runArgs, args...)
return cmd.Dir(filepath.Dir(file)).Debug().Stderr(stderr).Stdout(stdout).
Env(env).
Run("dlv", debug_util.FormatDlvArgs(tmpBin, port, runArgs)...)
Expand Down
2 changes: 1 addition & 1 deletion cmd/xgo/test-explorer/run_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func (c *runSession) Start() error {
testArgs := joinTestArgs(pathArgs, runNames)
err = runTest(c.goCmd, c.dir, testFlags, testArgs, c.bypassGoFlags, c.progArgs, c.env, stdout, stderr)
} else {
err = debugTest(c.goCmd, c.dir, item.File, testFlags, pathArgs, runNames, stdout, stderr, c.progArgs, c.env)
err = debugTest(c.goCmd, c.dir, item.File, testFlags, pathArgs, c.bypassGoFlags, runNames, stdout, stderr, c.progArgs, c.env)
}

if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/xgo/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import "fmt"
// VERSION is manully updated when needed a new tag

Check warning on line 6 in cmd/xgo/version.go

View workflow job for this annotation

GitHub Actions / check-build

"manully" should be "manually".

Check warning on line 6 in cmd/xgo/version.go

View workflow job for this annotation

GitHub Actions / check-build

"manully" should be "manually".
// see also runtime/core/version.go
const VERSION = "1.0.49"
const REVISION = "bfe5f14d7bfaf52b5dfecb95aaaa717e0ff4d3c9+1"
const NUMBER = 310
const REVISION = "1d8b33c2ca5fafec9439a1ec7adcdc591db705b9+1"
const NUMBER = 311

// the matching runtime/core's version
// manually updated
Expand Down

0 comments on commit 0851e4e

Please sign in to comment.