Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gotooltest: move default GOPATH out of the main module #156

Merged
merged 1 commit into from Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions cmd/testscript/testdata/env_var_with_go.txt
Expand Up @@ -12,7 +12,7 @@ unquote withproxy.txt
# Baseline
testscript -v noproxy.txt
stdout ^BANANA=$
stdout '^GOPATH=\$WORK[/\\]gopath'$
stdout '^GOPATH=\$WORK[/\\]\.gopath'$
[!go1.13] stdout ^GOPROXY=$
[go1.13] stdout ^GOPROXY=https://proxy.golang.org,direct$
! stderr .+
Expand All @@ -25,15 +25,15 @@ env GOPROXY=
# no GOPROXY, no pass-through, no proxy
testscript -v noproxy.txt
stdout ^BANANA=$
stdout '^GOPATH=\$WORK[/\\]gopath'$
stdout '^GOPATH=\$WORK[/\\]\.gopath'$
[!go1.13] stdout ^GOPROXY=$
[go1.13] stdout ^GOPROXY=https://proxy.golang.org,direct$
! stderr .+

# no GOPROXY, no pass-through, with proxy
testscript -v withproxy.txt
stdout ^BANANA=$
stdout '^GOPATH=\$WORK[/\\]gopath'$
stdout '^GOPATH=\$WORK[/\\]\.gopath'$
stdout ^GOPROXY=http://.*/mod$
! stderr .+

Expand All @@ -56,14 +56,14 @@ setfilegoproxy $WORK/proxy
# with GOPROXY, no pass-through, no proxy
testscript -v noproxy.txt
stdout ^BANANA=$
stdout '^GOPATH=\$WORK[/\\]gopath'$
stdout '^GOPATH=\$WORK[/\\]\.gopath'$
stdout ^GOPROXY=$GOPROXY$
! stderr .+

# with GOPROXY, no pass-through, with proxy
testscript -v withproxy.txt
stdout ^BANANA=$
stdout '^GOPATH=\$WORK[/\\]gopath'$
stdout '^GOPATH=\$WORK[/\\]\.gopath'$
stdout ^GOPROXY=http://.*/mod$
! stderr .+

Expand Down
7 changes: 7 additions & 0 deletions goproxytest/testdata/list.txt
Expand Up @@ -7,6 +7,13 @@ stdout 'v1.0.0 v1.1.0'
go get -d fruit.com@v1.0.0
go get -d fruit.com@v1.1.0

# On Go 1.18 and later, this will error out if GOPATH is ${WORK}/gopath,
# as that places GOMODCACHE inside the Go module and "mod tidy" walks it.
# "mod tidy" then complains about invalid import paths such as
# "mod/gopath/pkg/mod/fruit.com@v1.1.0/fruit".
# It's for that reason that we moved the default GOPATH to ${WORK}/.gopath.
go mod tidy

-- go.mod --
module mod

2 changes: 1 addition & 1 deletion gotooltest/setup.go
Expand Up @@ -110,7 +110,7 @@ func goEnviron(env0 []string) []string {
env := environ(env0)
workdir := env.get("WORK")
return append(env, []string{
"GOPATH=" + filepath.Join(workdir, "gopath"),
"GOPATH=" + filepath.Join(workdir, ".gopath"),
"CCACHE_DISABLE=1", // ccache breaks with non-existent HOME
"GOARCH=" + runtime.GOARCH,
"GOOS=" + runtime.GOOS,
Expand Down