mirror of
https://github.com/golang/go
synced 2024-11-16 20:14:48 -07:00
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>
This commit is contained in:
parent
ad641e8521
commit
b8bf820d5d
@ -250,23 +250,14 @@ func testGoLib(t *testing.T, iscgo bool) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
args := []string{"install", "mylib"}
|
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=archive", "-o", "mylib.a", ".")
|
||||||
cmd := exec.Command(testenv.GoToolPath(t), args...)
|
|
||||||
cmd.Dir = libpath
|
cmd.Dir = libpath
|
||||||
cmd.Env = append(os.Environ(), "GOPATH="+gopath)
|
cmd.Env = append(os.Environ(), "GOPATH="+gopath)
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("building test lib failed: %s %s", err, out)
|
t.Fatalf("building test lib failed: %s %s", err, out)
|
||||||
}
|
}
|
||||||
pat := filepath.Join(gopath, "pkg", "*", "mylib.a")
|
mylib := filepath.Join(libpath, "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]
|
|
||||||
|
|
||||||
out, err = exec.Command(testnmpath, mylib).CombinedOutput()
|
out, err = exec.Command(testnmpath, mylib).CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user