Skip to content

Commit bf2ef26

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
cmd/go: in script tests, avoid checking non-main packages for staleness
Non-main packages in module mode should not be installed to GOPATH/pkg, but due to #37015 they were installed there anyway. Lacking a proper install location, 'go install' becomes a no-op for non-main packages in module mode. This change switches the 'go install' commands in the test_fuzz_cache and build_overlay tests to instead use 'go build', using the '-x' flag to check for compile commands instead of querying 'go list' about staleness. For #37015. Change-Id: I56d80cf2a43efb6163c62082c86cd3e4f0ff73c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/417095 Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Russ Cox <[email protected]>
1 parent 5f5cae7 commit bf2ef26

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,24 @@ go build -overlay overlay.json -o main_call_asm$GOEXE ./call_asm
4747
exec ./main_call_asm$GOEXE
4848
! stdout .
4949

50-
# Change the contents of a file in the overlay and ensure that makes the target stale
51-
go install -overlay overlay.json ./test_cache
52-
go list -overlay overlay.json -f '{{.Stale}}' ./test_cache
53-
stdout '^false$'
54-
cp overlay/test_cache_different.go overlay/test_cache.go
55-
go list -overlay overlay.json -f '{{.Stale}}' ./test_cache
56-
stdout '^true$'
57-
5850
[cgo] go list -compiled -overlay overlay.json -f '{{range .CompiledGoFiles}}{{. | printf "%s\n"}}{{end}}' ./cgo_hello_replace
5951
[cgo] cp stdout compiled_cgo_sources.txt
6052
[cgo] go run ../print_line_comments.go compiled_cgo_sources.txt
6153
[cgo] stdout $GOPATH[/\\]src[/\\]m[/\\]cgo_hello_replace[/\\]cgo_hello_replace.go
6254
[cgo] ! stdout $GOPATH[/\\]src[/\\]m[/\\]overlay[/\\]hello.c
6355

56+
# Change the contents of a file in the overlay and ensure that makes the target stale
57+
env OLD_GOCACHE=$GOCACHE
58+
env GOCACHE=$WORK/cache # use a fresh cache so that multiple runs of the test don't interfere
59+
go build -x -overlay overlay.json ./test_cache
60+
stderr '(compile|gccgo)( |\.exe).*test_cache.go'
61+
go build -x -overlay overlay.json ./test_cache
62+
! stderr '(compile|gccgo)( |\.exe).*test_cache.go' # cached
63+
cp overlay/test_cache_different.go overlay/test_cache.go
64+
go build -x -overlay overlay.json ./test_cache
65+
stderr '(compile|gccgo)( |\.exe).*test_cache.go' # not cached
66+
env CACHE=$OLD_GOCACHE
67+
6468
# Run same tests but with gccgo.
6569
env GO111MODULE=off
6670
[!exec:gccgo] stop

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ go clean -cache
1717
exists $GOCACHE/fuzz
1818

1919
# 'go clean -fuzzcache' should delete the fuzz cache but not the build cache.
20-
go list -f {{.Stale}} ./empty
21-
stdout true
22-
go install ./empty
23-
go list -f {{.Stale}} ./empty
24-
stdout false
20+
go build -x ./empty
21+
stderr '(compile|gccgo)( |\.exe).*empty.go'
2522
go clean -fuzzcache
2623
! exists $GOCACHE/fuzz
27-
go list -f {{.Stale}} ./empty
28-
stdout false
24+
go build -x ./empty
25+
! stderr '(compile|gccgo)( |\.exe).*empty.go'
2926

3027
# Fuzzing indicates that one new interesting value was found with an empty
3128
# corpus, and the total size of the cache is now 1.

0 commit comments

Comments
 (0)