Skip to content

Commit d3ca4c8

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 2d4c1ff commit d3ca4c8

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

src/cmd/go/script_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ func TestScript(t *testing.T) {
4242
file := file
4343
name := strings.TrimSuffix(filepath.Base(file), ".txt")
4444
t.Run(name, func(t *testing.T) {
45-
if strings.HasPrefix(name, "mod_") && runtime.GOOS == "windows" {
46-
// Windows is very unhappy about the module proxy.
47-
t.Skip("golang.org/issue/26457")
48-
}
4945
t.Parallel()
5046
ts := &testScript{t: t, name: name, file: file}
5147
ts.setup()
@@ -76,6 +72,10 @@ type testScript struct {
7672
start time.Time // time phase started
7773
}
7874

75+
var extraEnvKeys = []string{
76+
"SYSTEMROOT", // must be preserved on Windows to find DLLs; golang.org/issue/25210
77+
}
78+
7979
// setup sets up the test execution temporary directory and environment.
8080
func (ts *testScript) setup() {
8181
StartProxy()
@@ -96,11 +96,18 @@ func (ts *testScript) setup() {
9696
tempEnvName() + "=" + filepath.Join(ts.workdir, "tmp"),
9797
"devnull=" + os.DevNull,
9898
}
99+
99100
if runtime.GOOS == "windows" {
100101
ts.env = append(ts.env, "exe=.exe")
101102
} else {
102103
ts.env = append(ts.env, "exe=")
103104
}
105+
for _, key := range extraEnvKeys {
106+
if val := os.Getenv(key); val != "" {
107+
ts.env = append(ts.env, key+"="+val)
108+
}
109+
}
110+
104111
ts.envMap = make(map[string]string)
105112
for _, kv := range ts.env {
106113
if i := strings.Index(kv, "="); i >= 0 {

src/cmd/go/testdata/script/mod_bad_filenames.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ env GO111MODULE=on
22

33
! go get rsc.io/badfile1 rsc.io/badfile2 rsc.io/badfile3 rsc.io/badfile4 rsc.io/badfile5
44
! stderr 'unzip.*badfile1'
5-
stderr 'unzip.*badfile2/@v/v1.0.0.zip:.*malformed file path "☺.go": invalid char ''☺'''
6-
stderr 'unzip.*badfile3/@v/v1.0.0.zip: malformed file path "x\?y.go": invalid char ''\?'''
7-
stderr 'unzip.*badfile4/@v/v1.0.0.zip: case-insensitive file name collision: "x/Y.go" and "x/y.go"'
8-
stderr 'unzip.*badfile5/@v/v1.0.0.zip: case-insensitive file name collision: "x/y" and "x/Y"'
5+
stderr 'unzip.*badfile2[\\/]@v[\\/]v1.0.0.zip:.*malformed file path "☺.go": invalid char ''☺'''
6+
stderr 'unzip.*badfile3[\\/]@v[\\/]v1.0.0.zip: malformed file path "x\?y.go": invalid char ''\?'''
7+
stderr 'unzip.*badfile4[\\/]@v[\\/]v1.0.0.zip: case-insensitive file name collision: "x/Y.go" and "x/y.go"'
8+
stderr 'unzip.*badfile5[\\/]@v[\\/]v1.0.0.zip: case-insensitive file name collision: "x/y" and "x/Y"'
99

1010
-- go.mod --
1111
module x

src/cmd/go/testdata/script/mod_file_proxy.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ go list -getmode=local
1010
grep v1.5.1 $GOPATH/src/mod/cache/download/rsc.io/quote/@v/list
1111

1212
# Use download cache as file:/// proxy.
13+
[windows] stop # TODO: file://$WORK puts backslashes in the URL
1314
env GOPATH=$WORK/gopath2
1415
env GOPROXY=file:///nonexist
1516
! go list -getmode=local

0 commit comments

Comments
 (0)