mirror of
https://github.com/golang/go
synced 2024-11-12 03:00:22 -07:00
cmd/link/internal/ld: make dwarf_test and associated testdata module-agnostic
Updates #30228 Change-Id: I31aac4cb113c0c88a54329181ad27aee3d8acc71 Reviewed-on: https://go-review.googlesource.com/c/162835 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
b88462ef8b
commit
1e4a88fa0a
@ -114,26 +114,14 @@ func gobuild(t *testing.T, dir string, testfile string, gcflags string) *builtFi
|
||||
return &builtFile{f, dst}
|
||||
}
|
||||
|
||||
func envWithGoPathSet(gp string) []string {
|
||||
env := os.Environ()
|
||||
for i := 0; i < len(env); i++ {
|
||||
if strings.HasPrefix(env[i], "GOPATH=") {
|
||||
env[i] = "GOPATH=" + gp
|
||||
return env
|
||||
}
|
||||
}
|
||||
env = append(env, "GOPATH="+gp)
|
||||
return env
|
||||
}
|
||||
// Similar to gobuild() above, but uses a main package instead of a test.go file.
|
||||
|
||||
// Similar to gobuild() above, but runs off a separate GOPATH environment
|
||||
|
||||
func gobuildTestdata(t *testing.T, tdir string, gopathdir string, packtobuild string, gcflags string) *builtFile {
|
||||
func gobuildTestdata(t *testing.T, tdir string, pkgDir string, gcflags string) *builtFile {
|
||||
dst := filepath.Join(tdir, "out.exe")
|
||||
|
||||
// Run a build with an updated GOPATH
|
||||
cmd := exec.Command(testenv.GoToolPath(t), "build", gcflags, "-o", dst, packtobuild)
|
||||
cmd.Env = envWithGoPathSet(gopathdir)
|
||||
cmd := exec.Command(testenv.GoToolPath(t), "build", gcflags, "-o", dst)
|
||||
cmd.Dir = pkgDir
|
||||
if b, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Logf("build: %s\n", b)
|
||||
t.Fatalf("build error: %v", err)
|
||||
@ -727,7 +715,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func abstractOriginSanity(t *testing.T, gopathdir string, flags string) {
|
||||
func abstractOriginSanity(t *testing.T, pkgDir string, flags string) {
|
||||
t.Parallel()
|
||||
|
||||
dir, err := ioutil.TempDir("", "TestAbstractOriginSanity")
|
||||
@ -737,7 +725,7 @@ func abstractOriginSanity(t *testing.T, gopathdir string, flags string) {
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
// Build with inlining, to exercise DWARF inlining support.
|
||||
f := gobuildTestdata(t, dir, gopathdir, "main", flags)
|
||||
f := gobuildTestdata(t, dir, filepath.Join(pkgDir, "main"), flags)
|
||||
|
||||
d, err := f.DWARF()
|
||||
if err != nil {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package main
|
||||
|
||||
import "a"
|
||||
import "cmd/link/internal/ld/testdata/issue25459/a"
|
||||
|
||||
var Glob int
|
||||
|
@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
b "b.dir"
|
||||
b "cmd/link/internal/ld/testdata/issue26237/b.dir"
|
||||
)
|
||||
|
||||
var skyx int
|
Loading…
Reference in New Issue
Block a user