mirror of
https://github.com/golang/go
synced 2024-11-07 21:06:13 -07:00
cmd/go: preserve %SYSTEMROOT% in TestScript on Windows
Windows networking doesn't work without this environment variable (#25210). Re-enable TestScript on Windows, and fix two minor failures. Fixes #26457. Change-Id: Id9bea49dfb58403195c29c3d831a532ef0f9a233 Reviewed-on: https://go-review.googlesource.com/124858 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
2d4c1ff739
commit
d3ca4c8810
@ -42,10 +42,6 @@ func TestScript(t *testing.T) {
|
|||||||
file := file
|
file := file
|
||||||
name := strings.TrimSuffix(filepath.Base(file), ".txt")
|
name := strings.TrimSuffix(filepath.Base(file), ".txt")
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
if strings.HasPrefix(name, "mod_") && runtime.GOOS == "windows" {
|
|
||||||
// Windows is very unhappy about the module proxy.
|
|
||||||
t.Skip("golang.org/issue/26457")
|
|
||||||
}
|
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ts := &testScript{t: t, name: name, file: file}
|
ts := &testScript{t: t, name: name, file: file}
|
||||||
ts.setup()
|
ts.setup()
|
||||||
@ -76,6 +72,10 @@ type testScript struct {
|
|||||||
start time.Time // time phase started
|
start time.Time // time phase started
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var extraEnvKeys = []string{
|
||||||
|
"SYSTEMROOT", // must be preserved on Windows to find DLLs; golang.org/issue/25210
|
||||||
|
}
|
||||||
|
|
||||||
// setup sets up the test execution temporary directory and environment.
|
// setup sets up the test execution temporary directory and environment.
|
||||||
func (ts *testScript) setup() {
|
func (ts *testScript) setup() {
|
||||||
StartProxy()
|
StartProxy()
|
||||||
@ -96,11 +96,18 @@ func (ts *testScript) setup() {
|
|||||||
tempEnvName() + "=" + filepath.Join(ts.workdir, "tmp"),
|
tempEnvName() + "=" + filepath.Join(ts.workdir, "tmp"),
|
||||||
"devnull=" + os.DevNull,
|
"devnull=" + os.DevNull,
|
||||||
}
|
}
|
||||||
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
ts.env = append(ts.env, "exe=.exe")
|
ts.env = append(ts.env, "exe=.exe")
|
||||||
} else {
|
} else {
|
||||||
ts.env = append(ts.env, "exe=")
|
ts.env = append(ts.env, "exe=")
|
||||||
}
|
}
|
||||||
|
for _, key := range extraEnvKeys {
|
||||||
|
if val := os.Getenv(key); val != "" {
|
||||||
|
ts.env = append(ts.env, key+"="+val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ts.envMap = make(map[string]string)
|
ts.envMap = make(map[string]string)
|
||||||
for _, kv := range ts.env {
|
for _, kv := range ts.env {
|
||||||
if i := strings.Index(kv, "="); i >= 0 {
|
if i := strings.Index(kv, "="); i >= 0 {
|
||||||
|
@ -2,10 +2,10 @@ env GO111MODULE=on
|
|||||||
|
|
||||||
! go get rsc.io/badfile1 rsc.io/badfile2 rsc.io/badfile3 rsc.io/badfile4 rsc.io/badfile5
|
! go get rsc.io/badfile1 rsc.io/badfile2 rsc.io/badfile3 rsc.io/badfile4 rsc.io/badfile5
|
||||||
! stderr 'unzip.*badfile1'
|
! stderr 'unzip.*badfile1'
|
||||||
stderr 'unzip.*badfile2/@v/v1.0.0.zip:.*malformed file path "☺.go": invalid char ''☺'''
|
stderr 'unzip.*badfile2[\\/]@v[\\/]v1.0.0.zip:.*malformed file path "☺.go": invalid char ''☺'''
|
||||||
stderr 'unzip.*badfile3/@v/v1.0.0.zip: malformed file path "x\?y.go": invalid char ''\?'''
|
stderr 'unzip.*badfile3[\\/]@v[\\/]v1.0.0.zip: malformed file path "x\?y.go": invalid char ''\?'''
|
||||||
stderr 'unzip.*badfile4/@v/v1.0.0.zip: case-insensitive file name collision: "x/Y.go" and "x/y.go"'
|
stderr 'unzip.*badfile4[\\/]@v[\\/]v1.0.0.zip: case-insensitive file name collision: "x/Y.go" and "x/y.go"'
|
||||||
stderr 'unzip.*badfile5/@v/v1.0.0.zip: case-insensitive file name collision: "x/y" and "x/Y"'
|
stderr 'unzip.*badfile5[\\/]@v[\\/]v1.0.0.zip: case-insensitive file name collision: "x/y" and "x/Y"'
|
||||||
|
|
||||||
-- go.mod --
|
-- go.mod --
|
||||||
module x
|
module x
|
||||||
|
@ -10,6 +10,7 @@ go list -getmode=local
|
|||||||
grep v1.5.1 $GOPATH/src/mod/cache/download/rsc.io/quote/@v/list
|
grep v1.5.1 $GOPATH/src/mod/cache/download/rsc.io/quote/@v/list
|
||||||
|
|
||||||
# Use download cache as file:/// proxy.
|
# Use download cache as file:/// proxy.
|
||||||
|
[windows] stop # TODO: file://$WORK puts backslashes in the URL
|
||||||
env GOPATH=$WORK/gopath2
|
env GOPATH=$WORK/gopath2
|
||||||
env GOPROXY=file:///nonexist
|
env GOPROXY=file:///nonexist
|
||||||
! go list -getmode=local
|
! go list -getmode=local
|
||||||
|
Loading…
Reference in New Issue
Block a user