mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/testdir: support -godebug
Similar with what we are doing for -goexperiment. For #65778 Change-Id: I7dda69512a3ffb491e3de31941ae1c3d34fececf Reviewed-on: https://go-review.googlesource.com/c/go/+/568156 Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
parent
b79a4801a4
commit
4b43913f40
1 changed files with 13 additions and 1 deletions
|
|
@ -62,6 +62,7 @@ var (
|
|||
goarch string // Target GOARCH
|
||||
cgoEnabled bool
|
||||
goExperiment string
|
||||
goDebug string
|
||||
|
||||
// dirs are the directories to look for *.go files in.
|
||||
// TODO(bradfitz): just use all directories?
|
||||
|
|
@ -100,6 +101,7 @@ func Test(t *testing.T) {
|
|||
GOOS string
|
||||
GOARCH string
|
||||
GOEXPERIMENT string
|
||||
GODEBUG string
|
||||
CGO_ENABLED string
|
||||
}
|
||||
if err := json.NewDecoder(stdout).Decode(&env); err != nil {
|
||||
|
|
@ -112,6 +114,7 @@ func Test(t *testing.T) {
|
|||
goarch = env.GOARCH
|
||||
cgoEnabled, _ = strconv.ParseBool(env.CGO_ENABLED)
|
||||
goExperiment = env.GOEXPERIMENT
|
||||
goDebug = env.GODEBUG
|
||||
|
||||
common := testCommon{
|
||||
gorootTestDir: filepath.Join(testenv.GOROOT(t), "test"),
|
||||
|
|
@ -537,6 +540,7 @@ func (t test) run() error {
|
|||
}
|
||||
|
||||
goexp := goExperiment
|
||||
godebug := goDebug
|
||||
|
||||
// collect flags
|
||||
for len(args) > 0 && strings.HasPrefix(args[0], "-") {
|
||||
|
|
@ -569,6 +573,14 @@ func (t test) run() error {
|
|||
goexp += args[0]
|
||||
runenv = append(runenv, "GOEXPERIMENT="+goexp)
|
||||
|
||||
case "-godebug": // set GODEBUG environment
|
||||
args = args[1:]
|
||||
if godebug != "" {
|
||||
godebug += ","
|
||||
}
|
||||
godebug += args[0]
|
||||
runenv = append(runenv, "GODEBUG="+godebug)
|
||||
|
||||
default:
|
||||
flags = append(flags, args[0])
|
||||
}
|
||||
|
|
@ -1014,7 +1026,7 @@ func (t test) run() error {
|
|||
runInDir = ""
|
||||
var out []byte
|
||||
var err error
|
||||
if len(flags)+len(args) == 0 && t.goGcflagsIsEmpty() && !*linkshared && goarch == runtime.GOARCH && goos == runtime.GOOS && goexp == goExperiment {
|
||||
if len(flags)+len(args) == 0 && t.goGcflagsIsEmpty() && !*linkshared && goarch == runtime.GOARCH && goos == runtime.GOOS && goexp == goExperiment && godebug == goDebug {
|
||||
// If we're not using special go command flags,
|
||||
// skip all the go command machinery.
|
||||
// This avoids any time the go command would
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue