]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert TestUserOverrideFlags to a script test
authorBryan C. Mills <bcmills@google.com>
Mon, 18 Nov 2019 19:52:16 +0000 (14:52 -0500)
committerBryan C. Mills <bcmills@google.com>
Mon, 18 Nov 2019 22:08:03 +0000 (22:08 +0000)
Updates #28387
Updates #30316

Change-Id: I08eb0e144387735f7a7811a82e547a581991b335
Reviewed-on: https://go-review.googlesource.com/c/go/+/207697
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/go_test.go
src/cmd/go/testdata/script/build_gcflags.txt [new file with mode: 0644]

index e1516a5db1fca85f96daf4943bcc4301778bd63a..4181c878f5e36a7c905c5a981b9ae16f08969bea 100644 (file)
@@ -4387,36 +4387,6 @@ func TestNeedVersion(t *testing.T) {
        tg.grepStderr("compile", "does not match go tool version")
 }
 
-// Test that user can override default code generation flags.
-func TestUserOverrideFlags(t *testing.T) {
-       skipIfGccgo(t, "gccgo does not use -gcflags")
-       if !canCgo {
-               t.Skip("skipping because cgo not enabled")
-       }
-       if runtime.GOOS != "linux" {
-               // We are testing platform-independent code, so it's
-               // OK to skip cases that work differently.
-               t.Skipf("skipping on %s because test only works if c-archive implies -shared", runtime.GOOS)
-       }
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       // Don't call tg.parallel, as creating override.h and override.a may
-       // confuse other tests.
-       tg.tempFile("override.go", `package main
-
-import "C"
-
-//export GoFunc
-func GoFunc() {}
-
-func main() {}`)
-       tg.creatingTemp("override.a")
-       tg.creatingTemp("override.h")
-       tg.run("build", "-x", "-buildmode=c-archive", "-gcflags=all=-shared=false", tg.path("override.go"))
-       tg.grepStderr("compile .*-shared .*-shared=false", "user can not override code generation flag")
-}
-
 func TestCgoFlagContainsSpace(t *testing.T) {
        tooSlow(t)
        if !canCgo {
diff --git a/src/cmd/go/testdata/script/build_gcflags.txt b/src/cmd/go/testdata/script/build_gcflags.txt
new file mode 100644 (file)
index 0000000..e0accb1
--- /dev/null
@@ -0,0 +1,21 @@
+env GO111MODULE=off
+
+# Test that the user can override default code generation flags.
+
+[gccgo] skip  # gccgo does not use -gcflags
+[!cgo] skip
+[!linux] skip  # test only works if c-archive implies -shared
+[short] skip
+
+go build -x -buildmode=c-archive -gcflags=all=-shared=false ./override.go
+stderr '^.*/compile (.* )?-shared (.* )?-shared=false'
+
+-- override.go --
+package main
+
+import "C"
+
+//export GoFunc
+func GoFunc() {}
+
+func main() {}