"testing"
"time"
+ "cmd/go/internal/cfg"
"cmd/go/internal/imports"
"cmd/go/internal/par"
"cmd/go/internal/txtar"
"CCACHE_DISABLE=1", // ccache breaks with non-existent HOME
"GOARCH=" + runtime.GOARCH,
"GOCACHE=" + testGOCACHE,
+ "GOEXE=" + cfg.ExeSuffix,
"GOOS=" + runtime.GOOS,
"GOPATH=" + filepath.Join(ts.workdir, "gopath"),
"GOPROXY=" + proxyURL,
ts.env = append(ts.env, "path="+testBin+string(filepath.ListSeparator)+os.Getenv("path"))
}
- if runtime.GOOS == "windows" {
- ts.env = append(ts.env, "exe=.exe")
- } else {
- ts.env = append(ts.env, "exe=")
- }
for _, key := range extraEnvKeys {
if val := os.Getenv(key); val != "" {
ts.env = append(ts.env, key+"="+val)
GOARCH=<target GOARCH>
GOCACHE=<actual GOCACHE being used outside the test>
+ GOEXE=<executable file suffix: .exe on Windows, empty on other systems>
GOOS=<target GOOS>
GOPATH=$WORK/gopath
GOPROXY=<local module proxy serving from cmd/go/testdata/mod>
devnull=<value of os.DevNull>
goversion=<current Go version; for example, 1.12>
-The environment variable $exe (lowercase) is an empty string on most systems, ".exe" on Windows.
-
The scripts supporting files are unpacked relative to $GOPATH/src (aka $WORK/gopath/src)
and then the script begins execution in that directory as well. Thus the example above runs
in $WORK/gopath/src with GOPATH=$WORK/gopath and $WORK/gopath/src/hello.go
stderr '(link|gccgo)( |\.exe)'
# ... but the output binary can serve as a cache.
-go build -o main$exe -x main.go
+go build -o main$GOEXE -x main.go
stderr '(link|gccgo)( |\.exe)'
-go build -o main$exe -x main.go
+go build -o main$GOEXE -x main.go
! stderr '(link|gccgo)( |\.exe)'
-- main.go --
-- pkg2/pkg2.go --
package pkg2
--- c1$exe/keep.txt --
+-- c1$GOEXE/keep.txt --
Create c1 directory.
# 'go install' with no arguments should clean up after go build
cd mycmd
go build
-exists mycmd$exe
+exists mycmd$GOEXE
go install
-! exists mycmd$exe
+! exists mycmd$GOEXE
# 'go install mycmd' does not clean up, even in the mycmd directory
go build
-exists mycmd$exe
+exists mycmd$GOEXE
go install mycmd
-exists mycmd$exe
+exists mycmd$GOEXE
# 'go install mycmd' should not clean up in an unrelated current directory either
cd ..
-cp mycmd/mycmd$exe mycmd$exe
+cp mycmd/mycmd$GOEXE mycmd$GOEXE
go install mycmd
-exists mycmd$exe
+exists mycmd$GOEXE
-- mycmd/main.go --
package main
go get -d rsc.io/fortune/v2
-# The default executable name shouldn't be v2$exe
+# The default executable name shouldn't be v2$GOEXE
go build rsc.io/fortune/v2
-! exists v2$exe
-exists fortune$exe
+! exists v2$GOEXE
+exists fortune$GOEXE
-# The default test binary name shouldn't be v2.test$exe
+# The default test binary name shouldn't be v2.test$GOEXE
go test -c rsc.io/fortune/v2
-! exists v2.test$exe
-exists fortune.test$exe
+! exists v2.test$GOEXE
+exists fortune.test$GOEXE
-- go.mod --
module scratch
# should work (see golang.org/issue/28035).
cd x
go test -o=$devnull -c
-! exists x.test$exe
+! exists x.test$GOEXE
-- x/x_test.go --
package x_test