Commit b3369063 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

test: skip some tests on noopt builder

Adds a new build tag "gcflags_noopt" that can be used in test/*.go
tests.

Fixes #27833

Change-Id: I4ea0ccd9e9e58c4639de18645fec81eb24a3a929
Reviewed-on: https://go-review.googlesource.com/136898
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent 01b7c2db
// +build amd64 // +build amd64,!gcflags_noopt
// errorcheck -0 -d=ssa/check_bce/debug=3 // errorcheck -0 -d=ssa/check_bce/debug=3
// Copyright 2016 The Go Authors. All rights reserved. // Copyright 2016 The Go Authors. All rights reserved.
......
// +build !gcflags_noopt
// errorcheck -0 -m // errorcheck -0 -m
// Copyright 2018 The Go Authors. All rights reserved. // Copyright 2018 The Go Authors. All rights reserved.
......
// +build !nacl,!js // +build !nacl,!js,!gcflags_noopt
// run // run
// Copyright 2014 The Go Authors. All rights reserved. // Copyright 2014 The Go Authors. All rights reserved.
......
...@@ -356,6 +356,7 @@ func goDirPackages(longdir string, singlefilepkgs bool) ([][]string, error) { ...@@ -356,6 +356,7 @@ func goDirPackages(longdir string, singlefilepkgs bool) ([][]string, error) {
type context struct { type context struct {
GOOS string GOOS string
GOARCH string GOARCH string
noOptEnv bool
} }
// shouldTest looks for build tags in a source file and returns // shouldTest looks for build tags in a source file and returns
...@@ -375,10 +376,13 @@ func shouldTest(src string, goos, goarch string) (ok bool, whyNot string) { ...@@ -375,10 +376,13 @@ func shouldTest(src string, goos, goarch string) (ok bool, whyNot string) {
if len(line) == 0 || line[0] != '+' { if len(line) == 0 || line[0] != '+' {
continue continue
} }
gcFlags := os.Getenv("GO_GCFLAGS")
ctxt := &context{ ctxt := &context{
GOOS: goos, GOOS: goos,
GOARCH: goarch, GOARCH: goarch,
noOptEnv: strings.Contains(gcFlags, "-N") || strings.Contains(gcFlags, "-l"),
} }
words := strings.Fields(line) words := strings.Fields(line)
if words[0] == "+build" { if words[0] == "+build" {
ok := false ok := false
...@@ -425,6 +429,10 @@ func (ctxt *context) match(name string) bool { ...@@ -425,6 +429,10 @@ func (ctxt *context) match(name string) bool {
return true return true
} }
if ctxt.noOptEnv && name == "gcflags_noopt" {
return true
}
if name == "test_run" { if name == "test_run" {
return true return true
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment