summaryrefslogtreecommitdiff
path: root/src/cmd/go/go_test.go
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo@golang.org>2018-07-02 17:50:42 -0400
committerFilippo Valsorda <filippo@golang.org>2018-07-02 22:36:31 +0000
commit0bad1bef406e987b7b749efc3bb7ab5d08b36a1c (patch)
tree34b9f97d1683622d58605928e4d75fb4df711ae5 /src/cmd/go/go_test.go
parent3959ce667657defe1c99984adde93ca496953765 (diff)
parent7df09b4a03f9e53334672674ba7983d5e7128646 (diff)
downloadgo-git-dev.boringcrypto.go1.9.tar.gz
[dev.boringcrypto.go1.9] all: merge go1.9.7 into dev.boringcrypto.go1.9dev.boringcrypto.go1.9
Change-Id: I1f9769a0c2c7c090886afa31c86c403da29d2013
Diffstat (limited to 'src/cmd/go/go_test.go')
-rw-r--r--src/cmd/go/go_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index b496d9d571..e20d7b8f37 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -4500,3 +4500,36 @@ func TestBadCgoDirectives(t *testing.T) {
tg.run("build", "-n", "x")
tg.grepStderr("-D@foo", "did not find -D@foo in commands")
}
+
+func TestTwoPkgConfigs(t *testing.T) {
+ if !canCgo {
+ t.Skip("no cgo")
+ }
+ if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
+ t.Skipf("no shell scripts on %s", runtime.GOOS)
+ }
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.parallel()
+ tg.tempFile("src/x/a.go", `package x
+ // #cgo pkg-config: --static a
+ import "C"
+ `)
+ tg.tempFile("src/x/b.go", `package x
+ // #cgo pkg-config: --static a
+ import "C"
+ `)
+ tg.tempFile("pkg-config.sh", `#!/bin/sh
+echo $* >>`+tg.path("pkg-config.out"))
+ tg.must(os.Chmod(tg.path("pkg-config.sh"), 0755))
+ tg.setenv("GOPATH", tg.path("."))
+ tg.setenv("PKG_CONFIG", tg.path("pkg-config.sh"))
+ tg.run("build", "x")
+ out, err := ioutil.ReadFile(tg.path("pkg-config.out"))
+ tg.must(err)
+ out = bytes.TrimSpace(out)
+ want := "--cflags --static --static -- a a\n--libs --static --static -- a a"
+ if !bytes.Equal(out, []byte(want)) {
+ t.Errorf("got %q want %q", out, want)
+ }
+}