]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.13] cmd/go: fix and skip known Windows test failures
authorDmitri Shuralyov <dmitshur@golang.org>
Tue, 17 Mar 2020 21:50:25 +0000 (17:50 -0400)
committerDmitri Shuralyov <dmitshur@golang.org>
Tue, 31 Mar 2020 23:11:12 +0000 (23:11 +0000)
These non-short Windows test failures were resolved fully in CL 206144.

Both TestScript/build_trimpath and TestScript/version tests can be fixed
by backporting the changes to test scripts only, so that is done here.

Fixing TestScript/mod_list_dir requires backporting non-test changes in
addition to the test script changes, which is unlikely to be appropriate
this late in Go 1.13 release cycle. A failing test can cover up other
regressions, so skip this known failing test to fix the builder.

For #36181.

Change-Id: I4f140bd373554eb4664f04638666dee77986ec3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/223782
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/testdata/script/build_trimpath.txt
src/cmd/go/testdata/script/mod_list_dir.txt
src/cmd/go/testdata/script/version.txt

index 668f75599e77b406b0a10b4f47d92725cb183b44..ba414372d347abe986b262c9cc067ad764b02e6d 100644 (file)
@@ -1,44 +1,93 @@
 [short] skip
-
-env -r GOROOT_REGEXP=$GOROOT
-env -r WORK_REGEXP='$WORK'  # don't expand $WORK; grep replaces $WORK in text before matching.
-env GOROOT GOROOT_REGEXP WORK WORK_REGEXP
+env GO111MODULE=on
 
 # A binary built without -trimpath should contain the current workspace
 # and GOROOT for debugging and stack traces.
 cd a
-go build -o hello.exe hello.go
-grep -q $WORK_REGEXP hello.exe
-grep -q $GOROOT_REGEXP hello.exe
+go build -o $WORK/paths-a.exe paths.go
+exec $WORK/paths-a.exe $WORK/paths-a.exe
+stdout 'binary contains GOPATH: true'
+stdout 'binary contains GOROOT: true'
 
 # A binary built with -trimpath should not contain the current workspace
 # or GOROOT.
-go build -trimpath -o hello.exe hello.go
-! grep -q $GOROOT_REGEXP hello.exe
-! grep -q $WORK_REGEXP hello.exe
-cd ..
+go build -trimpath -o $WORK/paths-a.exe paths.go
+exec $WORK/paths-a.exe $WORK/paths-a.exe
+stdout 'binary contains GOPATH: false'
+stdout 'binary contains GOROOT: false'
 
 # A binary from an external module built with -trimpath should not contain
 # the current workspace or GOROOT.
-env GO111MODULE=on
-go build -trimpath -o fortune.exe rsc.io/fortune
-! grep -q $GOROOT_REGEXP fortune.exe
-! grep -q $WORK_REGEXP fortune.exe
+cd $WORK
+go get -trimpath rsc.io/fortune
+exec $WORK/paths-a.exe $GOPATH/bin/fortune$GOEXE
+stdout 'binary contains GOPATH: false'
+stdout 'binary contains GOROOT: false'
 
 # Two binaries built from identical packages in different directories
 # should be identical.
-mkdir b
-cp a/go.mod a/hello.go b
-cd a
-go build -trimpath -o ../a.exe .
-cd ../b
-go build -trimpath -o ../b.exe .
-cd ..
-cmp -q a.exe b.exe
+# TODO(golang.org/issue/35435): at the moment, they are not.
+#mkdir $GOPATH/src/b
+#cp $GOPATH/src/a/go.mod $GOPATH/src/b/go.mod
+#cp $GOPATH/src/a/paths.go $GOPATH/src/b/paths.go
+#cd $GOPATH/src/b
+#go build -trimpath -o $WORK/paths-b.exe .
+#cmp -q $WORK/paths-a.exe $WORK/paths-b.exe
+
+[!exec:gccgo] stop
+
+# A binary built with gccgo without -trimpath should contain the current
+# GOPATH and GOROOT.
+env GO111MODULE=off # The current released gccgo does not support builds in module mode.
+cd $GOPATH/src/a
+go build -compiler=gccgo -o $WORK/gccgo-paths-a.exe .
+exec $WORK/gccgo-paths-a.exe $WORK/gccgo-paths-b.exe
+stdout 'binary contains GOPATH: true'
+stdout 'binary contains GOROOT: true'
+
+# A binary built with gccgo with -trimpath should not contain GOPATH or GOROOT.
+go build -compiler=gccgo -trimpath -o $WORK/gccgo-paths-a.exe .
+exec $WORK/gccgo-paths-a.exe $WORK/gccgo-paths-b.exe
+stdout 'binary contains GOPATH: false'
+stdout 'binary contains GOROOT: false'
 
--- a/hello.go --
+# Two binaries built from identical packages in different directories
+# should be identical.
+# TODO(golang.org/issue/35435): at the moment, they are not.
+#cd ../b
+#go build -compiler=gccgo -trimpath -o $WORK/gccgo-paths-b.exe .
+#cmp -q $WORK/gccgo-paths-a.exe $WORK/gccgo-paths-b.exe
+
+-- $GOPATH/src/a/paths.go --
 package main
-func main() { println("hello") }
 
--- a/go.mod --
-module m
+import (
+       "bytes"
+       "fmt"
+       "io/ioutil"
+       "log"
+       "os"
+       "path/filepath"
+)
+
+func main() {
+       exe := os.Args[1]
+       data, err := ioutil.ReadFile(exe)
+       if err != nil {
+               log.Fatal(err)
+       }
+
+       gopath := []byte(filepath.ToSlash(os.Getenv("GOPATH")))
+       if len(gopath) == 0 {
+               log.Fatal("GOPATH not set")
+       }
+       fmt.Printf("binary contains GOPATH: %v\n", bytes.Contains(data, gopath))
+
+       goroot := []byte(filepath.ToSlash(os.Getenv("GOROOT")))
+       if len(goroot) == 0 {
+               log.Fatal("GOROOT not set")
+       }
+       fmt.Printf("binary contains GOROOT: %v\n", bytes.Contains(data, goroot))
+}
+-- $GOPATH/src/a/go.mod --
+module example.com/a
index a8023cce9c5b787c20e5e3b6501c82c3d09f52bb..39834f2249cf91a4a362670978be9ef92327eae8 100644 (file)
@@ -1,4 +1,5 @@
 [short] skip
+[windows] skip # known Windows test failure on release-branch.go1.13; fix is in CL 206144 but requires non-test code changes unlikely to be appropriate for backporting this late
 
 # go list with path to directory should work
 
index 9086f047e4bbfbb9eae239df9f298348127edeb7..42526247f1e7e62a67222911d01390d648569609 100644 (file)
@@ -1,6 +1,7 @@
 env GO111MODULE=on
 [short] skip
 
+# Check that 'go version' and 'go version -m' work on a binary built in module mode.
 go build -o fortune.exe rsc.io/fortune
 go version fortune.exe
 stdout '^fortune.exe: .+'
@@ -8,6 +9,10 @@ go version -m fortune.exe
 stdout '^\tpath\trsc.io/fortune'
 stdout '^\tmod\trsc.io/fortune\tv1.0.0'
 
+# Repeat the test with -buildmode=pie.
+# TODO(golang.org/issue/27144): don't skip after -buildmode=pie is implemented
+# on Windows.
+[windows] skip # -buildmode=pie not supported
 go build -buildmode=pie -o external.exe rsc.io/fortune
 go version external.exe
 stdout '^external.exe: .+'