cmd/go: avoid hard-coding runtime dependencies in TestNewReleaseRebuildsStalePackagesInGOPATH

Fixes #64583.

Change-Id: Idbe50fe77f6030f2402ac436abe6710cb1183730
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/547995
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Bryan C. Mills 2023-12-06 12:47:32 -05:00 committed by Gopher Robot
parent fecaea97e4
commit 0ff2b33ea0
1 changed files with 12 additions and 14 deletions

View File

@ -881,22 +881,17 @@ func TestNewReleaseRebuildsStalePackagesInGOPATH(t *testing.T) {
// Copy the runtime packages into a temporary GOROOT // Copy the runtime packages into a temporary GOROOT
// so that we can change files. // so that we can change files.
for _, copydir := range []string{ var dirs []string
"src/runtime", tg.run("list", "-deps", "runtime")
"src/internal/abi", pkgs := strings.Split(strings.TrimSpace(tg.getStdout()), "\n")
"src/internal/bytealg", for _, pkg := range pkgs {
"src/internal/coverage/rtcov", dirs = append(dirs, filepath.Join("src", pkg))
"src/internal/cpu", }
"src/internal/goarch", dirs = append(dirs,
"src/internal/godebugs",
"src/internal/goexperiment",
"src/internal/goos",
"src/internal/coverage/rtcov",
"src/math/bits",
"src/unsafe",
filepath.Join("pkg/tool", goHostOS+"_"+goHostArch), filepath.Join("pkg/tool", goHostOS+"_"+goHostArch),
"pkg/include", "pkg/include",
} { )
for _, copydir := range dirs {
srcdir := filepath.Join(testGOROOT, copydir) srcdir := filepath.Join(testGOROOT, copydir)
tg.tempDir(filepath.Join("goroot", copydir)) tg.tempDir(filepath.Join("goroot", copydir))
err := filepath.WalkDir(srcdir, err := filepath.WalkDir(srcdir,
@ -912,6 +907,9 @@ func TestNewReleaseRebuildsStalePackagesInGOPATH(t *testing.T) {
return err return err
} }
dest := filepath.Join("goroot", copydir, srcrel) dest := filepath.Join("goroot", copydir, srcrel)
if _, err := os.Stat(dest); err == nil {
return nil
}
data, err := os.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
return err return err