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 4cf7b6d commit ce25721
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 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
11 changes: 7 additions & 4 deletions cmd/xgo/test-explorer/index.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
<!DOCTYPE html>
<html lang="en" style="height: 100%;">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Xgo Test Explorer</title>
<style>
</style>
<script>
window.onload = function(){
const {renderReact,UrlXgoTestingExplorer} = Open
renderReact(root,UrlXgoTestingExplorer,{
window.onload = function () {
const { renderReact, UrlXgoTestingExplorer } = Open
renderReact(root, UrlXgoTestingExplorer, {
apiPrefix: "http://localhost:8080"
})
}
</script>
</head>

<body style="height: 100%;">
<div id="root" style="height: 100%; background-color: #F6F7F9;"></div>
</body>
<!--after body because document.body may be null-->
<!--available in CN and Global-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/index.js"></script>
<!-- <script src="http://127.0.0.1:8080/build/index.js"></script> --> <!--for local dev-->
<!-- <script src="http://127.0.0.1:8080/build/index.js"></script> for local dev -->
<!-- <script src="http://127.0.0.1:8080/npm-publish/index.js"></script> -->

</html>
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 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
Expand Down

0 comments on commit ce25721

Please sign in to comment.