]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: preserve %SYSTEMROOT% in TestScript on Windows
authorRuss Cox <rsc@golang.org>
Thu, 19 Jul 2018 13:31:55 +0000 (09:31 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 19 Jul 2018 18:15:12 +0000 (18:15 +0000)
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>
src/cmd/go/script_test.go
src/cmd/go/testdata/script/mod_bad_filenames.txt
src/cmd/go/testdata/script/mod_file_proxy.txt

index db34252cc15d96d85641d92e4a4b06648e7cfcfd..a525e27ada33c8d8cc43b10a9da3bb187297d599 100644 (file)
@@ -42,10 +42,6 @@ func TestScript(t *testing.T) {
                file := file
                name := strings.TrimSuffix(filepath.Base(file), ".txt")
                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()
                        ts := &testScript{t: t, name: name, file: file}
                        ts.setup()
@@ -76,6 +72,10 @@ type testScript struct {
        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.
 func (ts *testScript) setup() {
        StartProxy()
@@ -96,11 +96,18 @@ func (ts *testScript) setup() {
                tempEnvName() + "=" + filepath.Join(ts.workdir, "tmp"),
                "devnull=" + os.DevNull,
        }
+
        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)
+               }
+       }
+
        ts.envMap = make(map[string]string)
        for _, kv := range ts.env {
                if i := strings.Index(kv, "="); i >= 0 {
index b59e737c5276abd256ab1dc15628abc2429863fa..6e0c8bd3023b649989d498a39420aa43e3a98e3f 100644 (file)
@@ -2,10 +2,10 @@ env GO111MODULE=on
 
 ! go get rsc.io/badfile1 rsc.io/badfile2 rsc.io/badfile3 rsc.io/badfile4 rsc.io/badfile5
 ! stderr 'unzip.*badfile1'
-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.*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.*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.*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"'
 
 -- go.mod --
 module x
index c82b9cf0319bb5a893b47528dfea60b5f82f4f20..144d06a2e0b680d2fd5e1e3de7795b0c98b31898 100644 (file)
@@ -10,6 +10,7 @@ go list -getmode=local
 grep v1.5.1 $GOPATH/src/mod/cache/download/rsc.io/quote/@v/list
 
 # Use download cache as file:/// proxy.
+[windows] stop # TODO: file://$WORK puts backslashes in the URL
 env GOPATH=$WORK/gopath2
 env GOPROXY=file:///nonexist
 ! go list -getmode=local