From: Russ Cox Date: Wed, 5 Nov 2025 18:42:44 +0000 (-0500) Subject: cmd/go: fix TestCgoPkgConfig on darwin with pkg-config installed X-Git-Tag: go1.26rc1~364 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3ae9e95002;p=gostls13.git cmd/go: fix TestCgoPkgConfig on darwin with pkg-config installed Most darwin systems don't have pkg-config installed and skip this test. (And it doesn't run in all.bash because it is skipped during -short.) But for those systems that have pkg-config and run the non-short tests, it fails because the code was not writing out the bar.pc on darwin and then expecting pkg-config to be able to tell us about the bar package. Change the code to write out the bar entry always. Fixes one failing case in 'go test cmd/go' on my Mac. Change-Id: Ibc4e9826a652ce2e7c609b905b159ccf2d5a6444 Reviewed-on: https://go-review.googlesource.com/c/go/+/718182 Reviewed-by: Michael Matloob Reviewed-by: Michael Matloob Auto-Submit: Russ Cox LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index e4ee9bd1e8..1722f1a2c3 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -1506,15 +1506,17 @@ func main() { tg.setenv("PKG_CONFIG_PATH", tg.path(".")) tg.run("run", tg.path("foo.go")) - if runtime.GOOS != "darwin" { // darwin doesn't like these ldflags - // test for ldflags - tg.tempFile("bar.pc", ` + libs := `Libs: -Wl,-rpath=/path\ with\ spaces/bin` + if runtime.GOOS == "darwin" { + libs = "" // darwin linker doesn't have -rpath + } + // test for ldflags + tg.tempFile("bar.pc", ` Name: bar Description: The bar library Version: 1.0.0 -Libs: -Wl,-rpath=/path\ with\ spaces/bin +`+libs+` `) - } tg.tempFile("bar.go", `package main /*