From: Russ Cox Date: Fri, 1 Dec 2017 16:26:09 +0000 (-0500) Subject: cmd/go: apply same per-package flags to test and xtest builds X-Git-Tag: go1.10beta1~66 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1c55f579be28c2e959bdfbe7688cba06556dff4b;p=gostls13.git cmd/go: apply same per-package flags to test and xtest builds If package strings has a particular set of gcflags, then the strings_test pseudo-package built as part of the test binary should inherit the same flags. Fixes #22831. Change-Id: I0e896b6c0f1063454300b7323f577feffbd6650b Reviewed-on: https://go-review.googlesource.com/81496 Run-TryBot: Russ Cox TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index cf6a9175b0..abff432ffb 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -5191,6 +5191,12 @@ func TestGcflagsPatterns(t *testing.T) { tg.grepStderr("reflect", "did not rebuild reflect") tg.grepStderr("compile.* -N .*-p reflect", "did not build reflect with -N flag") tg.grepStderrNot("compile.* -N .*-p fmt", "incorrectly built fmt with -N flag") + + tg.run("test", "-c", "-n", "-gcflags=-N", "strings") + tg.grepStderr("compile.* -N .*compare_test.go", "did not build strings_test package with -N flag") + + tg.run("test", "-c", "-n", "-gcflags=strings=-N", "strings") + tg.grepStderr("compile.* -N .*compare_test.go", "did not build strings_test package with -N flag") } func TestGoTestMinusN(t *testing.T) { diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index 9740b45276..1513a8083f 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -892,6 +892,11 @@ func builderTest(b *work.Builder, p *load.Package) (buildAction, runAction, prin }, Imports: ximports, RawImports: rawXTestImports, + + Asmflags: p.Internal.Asmflags, + Gcflags: p.Internal.Gcflags, + Ldflags: p.Internal.Ldflags, + Gccgoflags: p.Internal.Gccgoflags, }, } if pxtestNeedsPtest {