From ce25721c7e8d15479d6276ba09385e5cdf9db1ca Mon Sep 17 00:00:00 2001 From: xhd2015 Date: Sat, 2 Nov 2024 10:19:01 +0800 Subject: [PATCH] honoring bypass go flags when debugging --- cmd/xgo/test-explorer/debug.go | 11 ++++++++--- cmd/xgo/test-explorer/index.html | 11 +++++++---- cmd/xgo/test-explorer/run_session.go | 2 +- cmd/xgo/version.go | 4 ++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cmd/xgo/test-explorer/debug.go b/cmd/xgo/test-explorer/debug.go index bf53f40e..fd985688 100644 --- a/cmd/xgo/test-explorer/debug.go +++ b/cmd/xgo/test-explorer/debug.go @@ -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" } @@ -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)...) diff --git a/cmd/xgo/test-explorer/index.html b/cmd/xgo/test-explorer/index.html index ec364985..cc9524b7 100644 --- a/cmd/xgo/test-explorer/index.html +++ b/cmd/xgo/test-explorer/index.html @@ -1,5 +1,6 @@ + @@ -7,20 +8,22 @@ +
- + + \ No newline at end of file diff --git a/cmd/xgo/test-explorer/run_session.go b/cmd/xgo/test-explorer/run_session.go index 305e4ed2..1765eb84 100644 --- a/cmd/xgo/test-explorer/run_session.go +++ b/cmd/xgo/test-explorer/run_session.go @@ -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 { diff --git a/cmd/xgo/version.go b/cmd/xgo/version.go index 832018cb..74546e35 100644 --- a/cmd/xgo/version.go +++ b/cmd/xgo/version.go @@ -6,8 +6,8 @@ import "fmt" // VERSION is manually updated when needed a new tag // see also runtime/core/version.go const VERSION = "1.0.49" -const REVISION = "1d8b33c2ca5fafec9439a1ec7adcdc591db705b9+1" -const NUMBER = 311 +const REVISION = "4cf7b6dcf1391dc87b5f7bd736986c8a01988ed4+1" +const NUMBER = 312 // the matching runtime/core's version // manually updated