aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJay Conrod <jayconrod@google.com>2021-01-25 10:34:28 -0500
committerJay Conrod <jayconrod@google.com>2021-01-25 19:40:02 +0000
commit54514c6b2896c6a634a7b8017ade909985172e4d (patch)
treeb18e3e3dd23681496fbfe06beeb0fd33ce1b2c7f /src
parent6de8443f3b324be69a3082a67ce71fa869d1a32b (diff)
downloadgo-54514c6b2896c6a634a7b8017ade909985172e4d.tar.gz
go-54514c6b2896c6a634a7b8017ade909985172e4d.zip
cmd/go: fix TestScript/cgo_path, cgo_path_space when CC set
These tests failed if CC was set to a path containing a separator during make.bash. They now set CC explicitly. Fixes #43897 Change-Id: Ic6e7f192fcb363f0ac9f45b329113255453bf76f Reviewed-on: https://go-review.googlesource.com/c/go/+/286292 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/testdata/script/cgo_path.txt7
-rw-r--r--src/cmd/go/testdata/script/cgo_path_space.txt27
2 files changed, 21 insertions, 13 deletions
diff --git a/src/cmd/go/testdata/script/cgo_path.txt b/src/cmd/go/testdata/script/cgo_path.txt
index 98c56ff40ec..be9609e86f0 100644
--- a/src/cmd/go/testdata/script/cgo_path.txt
+++ b/src/cmd/go/testdata/script/cgo_path.txt
@@ -1,5 +1,12 @@
[!cgo] skip
+# Set CC explicitly to something that requires a PATH lookup.
+# Normally, the default is gcc or clang, but if CC was set during make.bash,
+# that becomes the default.
+[exec:clang] env CC=clang
+[exec:gcc] env CC=gcc
+[!exec:clang] [!exec:gcc] skip 'Unknown C compiler'
+
env GOCACHE=$WORK/gocache # Looking for compile flags, so need a clean cache.
[!windows] env PATH=.:$PATH
[!windows] chmod 0755 p/gcc p/clang
diff --git a/src/cmd/go/testdata/script/cgo_path_space.txt b/src/cmd/go/testdata/script/cgo_path_space.txt
index 6d203b04d61..654295dc692 100644
--- a/src/cmd/go/testdata/script/cgo_path_space.txt
+++ b/src/cmd/go/testdata/script/cgo_path_space.txt
@@ -1,13 +1,14 @@
# Check that if the PATH directory containing the C compiler has a space,
# we can still use that compiler with cgo.
# Verifies #43808.
-
[!cgo] skip
-# Check if default CC was set by make.bash.
-# If it was, this test is not valid.
-go env CC
-stdout '^(clang|gcc)$'
+# Set CC explicitly to something that requires a PATH lookup.
+# Normally, the default is gcc or clang, but if CC was set during make.bash,
+# that becomes the default.
+[exec:clang] env CC=clang
+[exec:gcc] env CC=gcc
+[!exec:clang] [!exec:gcc] skip 'Unknown C compiler'
[!windows] chmod 0755 $WORK/'program files'/clang
[!windows] chmod 0755 $WORK/'program files'/gcc
@@ -18,10 +19,10 @@ stdout '^(clang|gcc)$'
[windows] exists -exec $WORK/'program files'/clang.bat
[windows] env PATH=$WORK\'program files';%PATH%
-! exists log.txt
+! exists $WORK/log.txt
? go build -x
-exists log.txt
-rm log.txt
+exists $WORK/log.txt
+rm $WORK/log.txt
# TODO(#41400, #43078): when CC is set explicitly, it should be allowed to
# contain spaces separating arguments, and it should be possible to quote
@@ -30,7 +31,7 @@ rm log.txt
[!windows] env CC=$WORK/'program files'/gcc
[windows] env CC=$WORK\'program files'\gcc.bat
! go build -x
-! exists log.txt
+! exists $WORK/log.txt
-- go.mod --
module m
@@ -44,12 +45,12 @@ import "C"
-- $WORK/program files/gcc --
#!/bin/sh
-echo ok >log.txt
+echo ok >$WORK/log.txt
-- $WORK/program files/clang --
#!/bin/sh
-echo ok >log.txt
+echo ok >$WORK/log.txt
-- $WORK/program files/gcc.bat --
-echo ok >log.txt
+echo ok >%WORK%\log.txt
-- $WORK/program files/clang.bat --
-echo ok >log.txt
+echo ok >%WORK%\log.txt