Skip to content

Commit c4113b6

Browse files
author
Bryan C. Mills
committed
cmd/go: fix test failures with -count=2
In each test, either set the -n flag to avoid writing build artifacts to the cache, or set GOCACHE explicitly to point to a clean cache. Tested manually with 'go test -count=2 cmd/go'. Fixes #37820 Change-Id: I24403e738b1a10d5fe9dc8d98ef27a76ebe2704a Reviewed-on: https://go-review.googlesource.com/c/go/+/223140 Run-TryBot: Bryan C. Mills <[email protected]> Reviewed-by: Jay Conrod <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 040855e commit c4113b6

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ env GO111MODULE=off
77
[!linux] skip # test only works if c-archive implies -shared
88
[short] skip
99

10-
go build -x -buildmode=c-archive -gcflags=all=-shared=false ./override.go
10+
env GOCACHE=$WORK/gocache # Looking for compile commands, so need a clean cache.
11+
go build -x -n -buildmode=c-archive -gcflags=all=-shared=false ./override.go
1112
stderr '^.*/compile (.* )?-shared (.* )?-shared=false'
1213

1314
-- override.go --
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
[short] skip
22
[!cgo] skip
33

4-
go run -x main.go
4+
env GOCACHE=$WORK/gocache # Looking for compile flags, so need a clean cache.
5+
go build -x -n main.go
56
stderr '"-I[^"]+c flags"' # find quoted c flags
6-
! stderr '"-I[^"]+c flags".*"-I[^"]+c flags"' # don't find too many quoted c flags
7+
! stderr '"-I[^"]+c flags".*"-I[^"]+c flags"' # don't find too many quoted c flags per line
78
stderr '"-L[^"]+ld flags"' # find quoted ld flags
8-
! stderr '"-L[^"]+c flags".*"-L[^"]+c flags"' # don't find too many quoted ld flags
9+
! stderr '"-L[^"]+c flags".*"-L[^"]+c flags"' # don't find too many quoted ld flags per line
910

1011
-- main.go --
1112
package main
1213
// #cgo CFLAGS: -I"c flags"
1314
// #cgo LDFLAGS: -L"ld flags"
1415
import "C"
15-
func main() {}
16+
func main() {}

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

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ env GO111MODULE=off
33
[!gc] skip 'using -gcflags and -ldflags'
44
[short] skip
55

6+
env GOCACHE=$WORK/gocache # Looking for compile commands, so need a clean cache.
7+
68
# -gcflags=-e applies to named packages, not dependencies
79
go build -n -v -gcflags=-e z1 z2
810
stderr 'compile.* -e.* -p z1'

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

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ go get -d golang.org/x/text@14c0d48
1414

1515
# dropping -d, we should see a build.
1616
[short] skip
17+
18+
env GOCACHE=$WORK/gocache # Looking for compile commands, so need a clean cache.
19+
1720
go get -x golang.org/x/text/language@14c0d48
1821
stderr 'compile|cp|gccgo .*language\.a$'
1922

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ stdout 'rsc.io/quote v1.5.2'
1414
[short] skip
1515

1616
# Packages that are only imported in excluded files should not be built.
17-
go get -x .
17+
env GOCACHE=$WORK/gocache # Looking for compile commands, so need a clean cache.
18+
go get -n -x .
1819
stderr 'compile.* -p m '
1920
! stderr 'compile.* -p example.com/version '
2021
! stderr 'compile.* -p rsc.io/quote '

0 commit comments

Comments
 (0)