Skip to content

Commit ea0fd46

Browse files
Bryan C. Millsjproberts
authored andcommitted
cmd/nm: don't rely on an erroneous install target in tests
Non-main packages in module mode should not be installed to GOPATH/pkg, but due to golang#37015 they were installed there anyway. This change switches the 'go install' command in testGoLib to instead use 'go build -buildmode=archive' with an explicit output file. For golang#37015. Change-Id: I15781aa33d1b2adc6a4437a58622276f4e20b889 Reviewed-on: https://go-review.googlesource.com/c/go/+/416955 Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Auto-Submit: Bryan Mills <[email protected]>
1 parent e0ba7e1 commit ea0fd46

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/cmd/nm/nm_test.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -250,23 +250,14 @@ func testGoLib(t *testing.T, iscgo bool) {
250250
t.Fatal(err)
251251
}
252252

253-
args := []string{"install", "mylib"}
254-
cmd := exec.Command(testenv.GoToolPath(t), args...)
253+
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=archive", "-o", "mylib.a", ".")
255254
cmd.Dir = libpath
256255
cmd.Env = append(os.Environ(), "GOPATH="+gopath)
257256
out, err := cmd.CombinedOutput()
258257
if err != nil {
259258
t.Fatalf("building test lib failed: %s %s", err, out)
260259
}
261-
pat := filepath.Join(gopath, "pkg", "*", "mylib.a")
262-
ms, err := filepath.Glob(pat)
263-
if err != nil {
264-
t.Fatal(err)
265-
}
266-
if len(ms) == 0 {
267-
t.Fatalf("cannot found paths for pattern %s", pat)
268-
}
269-
mylib := ms[0]
260+
mylib := filepath.Join(libpath, "mylib.a")
270261

271262
out, err = exec.Command(testnmpath, mylib).CombinedOutput()
272263
if err != nil {

0 commit comments

Comments
 (0)