-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go,cmd/link: do not check for staleness in most tests
Instead, check that stale packages in the standard library are not rebuilt when already present in the build cache, and are not installed implicitly when rebuilt. We retain the staleness checks for the runtime package in tests involving '-i', because those are guaranteed to fail anyway if the package is stale and the "stale" failure message is arguably clearer. They can be removed if/when we remove the '-i' flag, but the runtime package is less likely to become stale because it does not have cgo dependencies. Fixes #46347 Updates #33598 Updates #35459 Updates #41696 Change-Id: I7b0a808addd930f9f4911ff53ded62272af75a40 Reviewed-on: https://go-review.googlesource.com/c/go/+/322629 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
- Loading branch information
Bryan C. Mills
committed
May 27, 2021
1 parent
6ff0ae2
commit 9bc5268
Showing
7 changed files
with
112 additions
and
63 deletions.
There are no files selected for viewing
13 changes: 0 additions & 13 deletions
13
src/cmd/go/testdata/script/build_package_not_stale_trailing_slash.txt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# golang.org/issue/46347: a stale runtime/cgo should only force a single rebuild | ||
|
||
[!cgo] skip | ||
[short] skip | ||
|
||
|
||
# If we set a unique CGO_CFLAGS, the installed copy of runtime/cgo | ||
# should be reported as stale. | ||
|
||
env CGO_CFLAGS=-DTestScript_cgo_stale=true | ||
stale runtime/cgo | ||
|
||
|
||
# If we then build a package that uses cgo, runtime/cgo should be rebuilt and | ||
# cached with the new flag, but not installed to GOROOT (and thus still stale). | ||
|
||
env GOCACHE=$WORK/cache # Use a fresh cache to avoid interference between runs. | ||
|
||
go build -x . | ||
stderr '[/\\]cgo'$GOEXE'["]? .* -importpath runtime/cgo' | ||
stale runtime/cgo | ||
|
||
|
||
# After runtime/cgo has been rebuilt and cached, it should not be rebuilt again | ||
# even though it is still reported as stale. | ||
|
||
go build -x . | ||
! stderr '[/\\]cgo'$GOEXE'["]? .* -importpath runtime/cgo' | ||
stale runtime/cgo | ||
|
||
|
||
-- go.mod -- | ||
module example.com/m | ||
|
||
go 1.17 | ||
-- m.go -- | ||
package m | ||
|
||
import "C" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# https://golang.org/issue/44725: packages in std should have the same | ||
# dependencies regardless of whether they are listed from within or outside | ||
# GOROOT/src. | ||
|
||
# Control case: net, viewed from outside the 'std' module, | ||
# should depend on vendor/golang.org/… instead of golang.org/…. | ||
|
||
go list -deps net | ||
stdout '^vendor/golang.org/x/net' | ||
! stdout '^golang.org/x/net' | ||
cp stdout $WORK/net-deps.txt | ||
|
||
|
||
# It should still report the same package dependencies when viewed from | ||
# within GOROOT/src. | ||
|
||
cd $GOROOT/src | ||
|
||
go list -deps net | ||
stdout '^vendor/golang.org/x/net' | ||
! stdout '^golang.org/x/net' | ||
cmp stdout $WORK/net-deps.txt | ||
|
||
|
||
# However, 'go mod' and 'go get' subcommands should report the original module | ||
# dependencies, not the vendored packages. | ||
|
||
[!net] stop | ||
|
||
env GOPROXY= | ||
go mod why -m golang.org/x/net | ||
stdout '^# golang.org/x/net\nnet\ngolang.org/x/net' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters