Skip to content

Commit 9ed3fb8

Browse files
committed
[release-branch.go1.13] cmd/go: fix and skip known Windows test failures
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent c67f9cc commit 9ed3fb8

File tree

3 files changed

+82
-27
lines changed

3 files changed

+82
-27
lines changed
Lines changed: 76 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,93 @@
11
[short] skip
2-
3-
env -r GOROOT_REGEXP=$GOROOT
4-
env -r WORK_REGEXP='$WORK' # don't expand $WORK; grep replaces $WORK in text before matching.
5-
env GOROOT GOROOT_REGEXP WORK WORK_REGEXP
2+
env GO111MODULE=on
63

74
# A binary built without -trimpath should contain the current workspace
85
# and GOROOT for debugging and stack traces.
96
cd a
10-
go build -o hello.exe hello.go
11-
grep -q $WORK_REGEXP hello.exe
12-
grep -q $GOROOT_REGEXP hello.exe
7+
go build -o $WORK/paths-a.exe paths.go
8+
exec $WORK/paths-a.exe $WORK/paths-a.exe
9+
stdout 'binary contains GOPATH: true'
10+
stdout 'binary contains GOROOT: true'
1311

1412
# A binary built with -trimpath should not contain the current workspace
1513
# or GOROOT.
16-
go build -trimpath -o hello.exe hello.go
17-
! grep -q $GOROOT_REGEXP hello.exe
18-
! grep -q $WORK_REGEXP hello.exe
19-
cd ..
14+
go build -trimpath -o $WORK/paths-a.exe paths.go
15+
exec $WORK/paths-a.exe $WORK/paths-a.exe
16+
stdout 'binary contains GOPATH: false'
17+
stdout 'binary contains GOROOT: false'
2018

2119
# A binary from an external module built with -trimpath should not contain
2220
# the current workspace or GOROOT.
23-
env GO111MODULE=on
24-
go build -trimpath -o fortune.exe rsc.io/fortune
25-
! grep -q $GOROOT_REGEXP fortune.exe
26-
! grep -q $WORK_REGEXP fortune.exe
21+
cd $WORK
22+
go get -trimpath rsc.io/fortune
23+
exec $WORK/paths-a.exe $GOPATH/bin/fortune$GOEXE
24+
stdout 'binary contains GOPATH: false'
25+
stdout 'binary contains GOROOT: false'
2726

2827
# Two binaries built from identical packages in different directories
2928
# should be identical.
30-
mkdir b
31-
cp a/go.mod a/hello.go b
32-
cd a
33-
go build -trimpath -o ../a.exe .
34-
cd ../b
35-
go build -trimpath -o ../b.exe .
36-
cd ..
37-
cmp -q a.exe b.exe
29+
# TODO(golang.org/issue/35435): at the moment, they are not.
30+
#mkdir $GOPATH/src/b
31+
#cp $GOPATH/src/a/go.mod $GOPATH/src/b/go.mod
32+
#cp $GOPATH/src/a/paths.go $GOPATH/src/b/paths.go
33+
#cd $GOPATH/src/b
34+
#go build -trimpath -o $WORK/paths-b.exe .
35+
#cmp -q $WORK/paths-a.exe $WORK/paths-b.exe
36+
37+
[!exec:gccgo] stop
38+
39+
# A binary built with gccgo without -trimpath should contain the current
40+
# GOPATH and GOROOT.
41+
env GO111MODULE=off # The current released gccgo does not support builds in module mode.
42+
cd $GOPATH/src/a
43+
go build -compiler=gccgo -o $WORK/gccgo-paths-a.exe .
44+
exec $WORK/gccgo-paths-a.exe $WORK/gccgo-paths-b.exe
45+
stdout 'binary contains GOPATH: true'
46+
stdout 'binary contains GOROOT: true'
47+
48+
# A binary built with gccgo with -trimpath should not contain GOPATH or GOROOT.
49+
go build -compiler=gccgo -trimpath -o $WORK/gccgo-paths-a.exe .
50+
exec $WORK/gccgo-paths-a.exe $WORK/gccgo-paths-b.exe
51+
stdout 'binary contains GOPATH: false'
52+
stdout 'binary contains GOROOT: false'
3853

39-
-- a/hello.go --
54+
# Two binaries built from identical packages in different directories
55+
# should be identical.
56+
# TODO(golang.org/issue/35435): at the moment, they are not.
57+
#cd ../b
58+
#go build -compiler=gccgo -trimpath -o $WORK/gccgo-paths-b.exe .
59+
#cmp -q $WORK/gccgo-paths-a.exe $WORK/gccgo-paths-b.exe
60+
61+
-- $GOPATH/src/a/paths.go --
4062
package main
41-
func main() { println("hello") }
4263

43-
-- a/go.mod --
44-
module m
64+
import (
65+
"bytes"
66+
"fmt"
67+
"io/ioutil"
68+
"log"
69+
"os"
70+
"path/filepath"
71+
)
72+
73+
func main() {
74+
exe := os.Args[1]
75+
data, err := ioutil.ReadFile(exe)
76+
if err != nil {
77+
log.Fatal(err)
78+
}
79+
80+
gopath := []byte(filepath.ToSlash(os.Getenv("GOPATH")))
81+
if len(gopath) == 0 {
82+
log.Fatal("GOPATH not set")
83+
}
84+
fmt.Printf("binary contains GOPATH: %v\n", bytes.Contains(data, gopath))
85+
86+
goroot := []byte(filepath.ToSlash(os.Getenv("GOROOT")))
87+
if len(goroot) == 0 {
88+
log.Fatal("GOROOT not set")
89+
}
90+
fmt.Printf("binary contains GOROOT: %v\n", bytes.Contains(data, goroot))
91+
}
92+
-- $GOPATH/src/a/go.mod --
93+
module example.com/a

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[short] skip
2+
[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
23

34
# go list with path to directory should work
45

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
env GO111MODULE=on
22
[short] skip
33

4+
# Check that 'go version' and 'go version -m' work on a binary built in module mode.
45
go build -o fortune.exe rsc.io/fortune
56
go version fortune.exe
67
stdout '^fortune.exe: .+'
78
go version -m fortune.exe
89
stdout '^\tpath\trsc.io/fortune'
910
stdout '^\tmod\trsc.io/fortune\tv1.0.0'
1011

12+
# Repeat the test with -buildmode=pie.
13+
# TODO(golang.org/issue/27144): don't skip after -buildmode=pie is implemented
14+
# on Windows.
15+
[windows] skip # -buildmode=pie not supported
1116
go build -buildmode=pie -o external.exe rsc.io/fortune
1217
go version external.exe
1318
stdout '^external.exe: .+'

0 commit comments

Comments
 (0)