cmd/nm: fix testGoLib helper to be module-agnostic

Updates #30228

Change-Id: I3c7864e6725312df5ec978cdc130ccfe8fc2e738
Reviewed-on: https://go-review.googlesource.com/c/162836
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Bryan C. Mills 2019-02-19 13:53:39 -05:00
parent d7d3887e3e
commit 8827147932

View file

@ -222,12 +222,16 @@ func testGoLib(t *testing.T, iscgo bool) {
if e := file.Close(); err == nil {
err = e
}
if err == nil {
err = ioutil.WriteFile(filepath.Join(libpath, "go.mod"), []byte("module mylib\n"), 0666)
}
if err != nil {
t.Fatal(err)
}
args := []string{"install", "mylib"}
cmd := exec.Command(testenv.GoToolPath(t), args...)
cmd.Dir = libpath
cmd.Env = append(os.Environ(), "GOPATH="+gopath)
out, err := cmd.CombinedOutput()
if err != nil {