]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: apply same per-package flags to test and xtest builds
authorRuss Cox <rsc@golang.org>
Fri, 1 Dec 2017 16:26:09 +0000 (11:26 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 1 Dec 2017 19:47:39 +0000 (19:47 +0000)
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 <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/go/go_test.go
src/cmd/go/internal/test/test.go

index cf6a9175b0cf05adcb4056405782b92780aeaeef..abff432ffb5cdec2c73a8719b1c7db2e94643d34 100644 (file)
@@ -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) {
index 9740b45276e6d4db110ecbc1601b51008b3cb074..1513a8083f88c8443e607be69d24a8d8ea7cf956 100644 (file)
@@ -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 {