Skip to content

Commit

Permalink
cmd/go: avoid hard-coding runtime dependencies in TestNewReleaseRebui…
Browse files Browse the repository at this point in the history
…ldsStalePackagesInGOPATH

Fixes golang#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>
  • Loading branch information
Bryan C. Mills authored and ezz-no committed Feb 17, 2024
1 parent e526bdc commit 13c693e
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/cmd/go/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -881,22 +881,17 @@ func TestNewReleaseRebuildsStalePackagesInGOPATH(t *testing.T) {

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

0 comments on commit 13c693e

Please sign in to comment.