mirror of
https://github.com/golang/go
synced 2024-10-02 22:25:08 +00:00
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 <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
5f5cae7200
commit
bf2ef26be3
20
src/cmd/go/testdata/script/build_overlay.txt
vendored
20
src/cmd/go/testdata/script/build_overlay.txt
vendored
|
@ -47,20 +47,24 @@ go build -overlay overlay.json -o main_call_asm$GOEXE ./call_asm
|
|||
exec ./main_call_asm$GOEXE
|
||||
! stdout .
|
||||
|
||||
# Change the contents of a file in the overlay and ensure that makes the target stale
|
||||
go install -overlay overlay.json ./test_cache
|
||||
go list -overlay overlay.json -f '{{.Stale}}' ./test_cache
|
||||
stdout '^false$'
|
||||
cp overlay/test_cache_different.go overlay/test_cache.go
|
||||
go list -overlay overlay.json -f '{{.Stale}}' ./test_cache
|
||||
stdout '^true$'
|
||||
|
||||
[cgo] go list -compiled -overlay overlay.json -f '{{range .CompiledGoFiles}}{{. | printf "%s\n"}}{{end}}' ./cgo_hello_replace
|
||||
[cgo] cp stdout compiled_cgo_sources.txt
|
||||
[cgo] go run ../print_line_comments.go compiled_cgo_sources.txt
|
||||
[cgo] stdout $GOPATH[/\\]src[/\\]m[/\\]cgo_hello_replace[/\\]cgo_hello_replace.go
|
||||
[cgo] ! stdout $GOPATH[/\\]src[/\\]m[/\\]overlay[/\\]hello.c
|
||||
|
||||
# Change the contents of a file in the overlay and ensure that makes the target stale
|
||||
env OLD_GOCACHE=$GOCACHE
|
||||
env GOCACHE=$WORK/cache # use a fresh cache so that multiple runs of the test don't interfere
|
||||
go build -x -overlay overlay.json ./test_cache
|
||||
stderr '(compile|gccgo)( |\.exe).*test_cache.go'
|
||||
go build -x -overlay overlay.json ./test_cache
|
||||
! stderr '(compile|gccgo)( |\.exe).*test_cache.go' # cached
|
||||
cp overlay/test_cache_different.go overlay/test_cache.go
|
||||
go build -x -overlay overlay.json ./test_cache
|
||||
stderr '(compile|gccgo)( |\.exe).*test_cache.go' # not cached
|
||||
env CACHE=$OLD_GOCACHE
|
||||
|
||||
# Run same tests but with gccgo.
|
||||
env GO111MODULE=off
|
||||
[!exec:gccgo] stop
|
||||
|
|
11
src/cmd/go/testdata/script/test_fuzz_cache.txt
vendored
11
src/cmd/go/testdata/script/test_fuzz_cache.txt
vendored
|
@ -17,15 +17,12 @@ go clean -cache
|
|||
exists $GOCACHE/fuzz
|
||||
|
||||
# 'go clean -fuzzcache' should delete the fuzz cache but not the build cache.
|
||||
go list -f {{.Stale}} ./empty
|
||||
stdout true
|
||||
go install ./empty
|
||||
go list -f {{.Stale}} ./empty
|
||||
stdout false
|
||||
go build -x ./empty
|
||||
stderr '(compile|gccgo)( |\.exe).*empty.go'
|
||||
go clean -fuzzcache
|
||||
! exists $GOCACHE/fuzz
|
||||
go list -f {{.Stale}} ./empty
|
||||
stdout false
|
||||
go build -x ./empty
|
||||
! stderr '(compile|gccgo)( |\.exe).*empty.go'
|
||||
|
||||
# Fuzzing indicates that one new interesting value was found with an empty
|
||||
# corpus, and the total size of the cache is now 1.
|
||||
|
|
Loading…
Reference in a new issue