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: Keith Randall <khr@golang.org>
This commit is contained in:
Brad Fitzpatrick 2018-09-24 16:48:54 +00:00
parent 01b7c2db15
commit b3369063e5
4 changed files with 15 additions and 6 deletions

View file

@ -1,4 +1,4 @@
// +build amd64
// +build amd64,!gcflags_noopt
// errorcheck -0 -d=ssa/check_bce/debug=3
// Copyright 2016 The Go Authors. All rights reserved.

View file

@ -1,3 +1,4 @@
// +build !gcflags_noopt
// errorcheck -0 -m
// Copyright 2018 The Go Authors. All rights reserved.

View file

@ -1,4 +1,4 @@
// +build !nacl,!js
// +build !nacl,!js,!gcflags_noopt
// run
// Copyright 2014 The Go Authors. All rights reserved.

View file

@ -354,8 +354,9 @@ func goDirPackages(longdir string, singlefilepkgs bool) ([][]string, error) {
}
type context struct {
GOOS string
GOARCH string
GOOS string
GOARCH string
noOptEnv bool
}
// 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) {
if len(line) == 0 || line[0] != '+' {
continue
}
gcFlags := os.Getenv("GO_GCFLAGS")
ctxt := &context{
GOOS: goos,
GOARCH: goarch,
GOOS: goos,
GOARCH: goarch,
noOptEnv: strings.Contains(gcFlags, "-N") || strings.Contains(gcFlags, "-l"),
}
words := strings.Fields(line)
if words[0] == "+build" {
ok := false
@ -425,6 +429,10 @@ func (ctxt *context) match(name string) bool {
return true
}
if ctxt.noOptEnv && name == "gcflags_noopt" {
return true
}
if name == "test_run" {
return true
}