Skip to content
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

fix test -args processing #155

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/xgo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ func handleBuild(cmd string, args []string) error {
cmdBuild := cmd == "build"
cmdTest := cmd == "test"
cmdExec := cmd == "exec"
opts, err := parseOptions(args)
opts, err := parseOptions(cmd, args)
if err != nil {
return err
}
remainArgs := opts.remainArgs
testArgs := opts.testArgs
flagA := opts.flagA
projectDir := opts.projectDir
output := opts.output
Expand Down Expand Up @@ -442,6 +443,9 @@ func handleBuild(cmd string, args []string) error {
}
}
buildCmdArgs = append(buildCmdArgs, remainArgs...)
if cmdTest && len(testArgs) > 0 {
buildCmdArgs = append(buildCmdArgs, testArgs...)
}
logDebug("command: %s %v", instrumentGo, buildCmdArgs)
execCmd = exec.Command(instrumentGo, buildCmdArgs...)
} else {
Expand Down
11 changes: 10 additions & 1 deletion cmd/xgo/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ type options struct {
stackTrace string

remainArgs []string

testArgs []string
}

func parseOptions(args []string) (*options, error) {
func parseOptions(cmd string, args []string) (*options, error) {
var flagA bool
var flagV bool
var flagX bool
Expand Down Expand Up @@ -103,6 +105,7 @@ func parseOptions(args []string) (*options, error) {
var trapStdlib bool

var remainArgs []string
var testArgs []string
nArg := len(args)

type FlagValue struct {
Expand Down Expand Up @@ -191,6 +194,11 @@ func parseOptions(args []string) (*options, error) {
remainArgs = append(remainArgs, arg)
continue
}
if cmd == "test" && arg == "-args" {
// pass everything after -args to test binary
testArgs = append(testArgs, args[i:]...)
break
}
if arg == "--" {
remainArgs = append(remainArgs, args[i+1:]...)
break
Expand Down Expand Up @@ -352,6 +360,7 @@ func parseOptions(args []string) (*options, error) {
trapStdlib: trapStdlib,

remainArgs: remainArgs,
testArgs: testArgs,
}, nil
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/xgo/runtime_gen/core/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
)

const VERSION = "1.0.37"
const REVISION = "62c6c037c1f57c371e227dd1bb8b8e141367f1c6+1"
const NUMBER = 239
const REVISION = "6f9a355d360e70a797c4ca0903fb5a6bdd1aa5db+1"
const NUMBER = 240

// these fields will be filled by compiler
const XGO_VERSION = ""
Expand Down
4 changes: 2 additions & 2 deletions cmd/xgo/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import "fmt"

const VERSION = "1.0.37"
const REVISION = "62c6c037c1f57c371e227dd1bb8b8e141367f1c6+1"
const NUMBER = 239
const REVISION = "6f9a355d360e70a797c4ca0903fb5a6bdd1aa5db+1"
const NUMBER = 240

func getRevision() string {
revSuffix := ""
Expand Down
4 changes: 2 additions & 2 deletions runtime/core/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
)

const VERSION = "1.0.37"
const REVISION = "62c6c037c1f57c371e227dd1bb8b8e141367f1c6+1"
const NUMBER = 239
const REVISION = "6f9a355d360e70a797c4ca0903fb5a6bdd1aa5db+1"
const NUMBER = 240

// these fields will be filled by compiler
const XGO_VERSION = ""
Expand Down
Loading