From b3369063e52571be1cdf0e7a16f99b12c2a23914 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 24 Sep 2018 16:48:54 +0000 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- test/checkbce.go | 2 +- test/fixedbugs/issue7921.go | 1 + test/nosplit.go | 2 +- test/run.go | 16 ++++++++++++---- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/test/checkbce.go b/test/checkbce.go index 770c4c2a94..ef4e584ca0 100644 --- a/test/checkbce.go +++ b/test/checkbce.go @@ -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. diff --git a/test/fixedbugs/issue7921.go b/test/fixedbugs/issue7921.go index e30e556353..ac2b494ebc 100644 --- a/test/fixedbugs/issue7921.go +++ b/test/fixedbugs/issue7921.go @@ -1,3 +1,4 @@ +// +build !gcflags_noopt // errorcheck -0 -m // Copyright 2018 The Go Authors. All rights reserved. diff --git a/test/nosplit.go b/test/nosplit.go index b821d23859..1855c010ae 100644 --- a/test/nosplit.go +++ b/test/nosplit.go @@ -1,4 +1,4 @@ -// +build !nacl,!js +// +build !nacl,!js,!gcflags_noopt // run // Copyright 2014 The Go Authors. All rights reserved. diff --git a/test/run.go b/test/run.go index 24a4d4f425..d0dccb4f23 100644 --- a/test/run.go +++ b/test/run.go @@ -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 } -- 2.50.0