aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2022-07-11 13:32:40 -0400
committerGopher Robot <gobot@golang.org>2022-07-11 19:01:02 +0000
commitb8bf820d5d4602f7e83ff89c0f8d0f2bd3a220d4 (patch)
tree33b9f003829c4fce7a9ab4c87d5aff4a86c9d9e4
parentad641e8521381886bc6274d78e986f2bb8ac561b (diff)
downloadgo-b8bf820d5d4602f7e83ff89c0f8d0f2bd3a220d4.tar.gz
go-b8bf820d5d4602f7e83ff89c0f8d0f2bd3a220d4.zip
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 #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 #37015. Change-Id: I15781aa33d1b2adc6a4437a58622276f4e20b889 Reviewed-on: https://go-review.googlesource.com/c/go/+/416955 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
-rw-r--r--src/cmd/nm/nm_test.go13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/cmd/nm/nm_test.go b/src/cmd/nm/nm_test.go
index 226c2c3bcd..4bc9bf9079 100644
--- a/src/cmd/nm/nm_test.go
+++ b/src/cmd/nm/nm_test.go
@@ -250,23 +250,14 @@ func testGoLib(t *testing.T, iscgo bool) {
t.Fatal(err)
}
- args := []string{"install", "mylib"}
- cmd := exec.Command(testenv.GoToolPath(t), args...)
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=archive", "-o", "mylib.a", ".")
cmd.Dir = libpath
cmd.Env = append(os.Environ(), "GOPATH="+gopath)
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("building test lib failed: %s %s", err, out)
}
- pat := filepath.Join(gopath, "pkg", "*", "mylib.a")
- ms, err := filepath.Glob(pat)
- if err != nil {
- t.Fatal(err)
- }
- if len(ms) == 0 {
- t.Fatalf("cannot found paths for pattern %s", pat)
- }
- mylib := ms[0]
+ mylib := filepath.Join(libpath, "mylib.a")
out, err = exec.Command(testnmpath, mylib).CombinedOutput()
if err != nil {