mirror of
https://github.com/golang/go
synced 2024-11-22 05:34:39 -07:00
cmd/link/internal/ld: simplify gobuildTestdata
Drop the second argument, which is is always a one-time temporary directory, thus it can be created right here. Change-Id: I73e5be2ccd4bddec249c7cb2a8ff9242d99f7e20 Reviewed-on: https://go-review.googlesource.com/c/go/+/610037 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Commit-Queue: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
fbe74d8ddb
commit
dfae83c9db
@ -131,8 +131,8 @@ func gobuild(t *testing.T, dir string, testfile string, gcflags string) *builtFi
|
||||
|
||||
// Similar to gobuild() above, but uses a main package instead of a test.go file.
|
||||
|
||||
func gobuildTestdata(t *testing.T, tdir string, pkgDir string, gcflags string) *builtFile {
|
||||
dst := filepath.Join(tdir, "out.exe")
|
||||
func gobuildTestdata(t *testing.T, pkgDir string, gcflags string) *builtFile {
|
||||
dst := filepath.Join(t.TempDir(), "out.exe")
|
||||
|
||||
// Run a build with an updated GOPATH
|
||||
cmd := testenv.Command(t, testenv.GoToolPath(t), "build", gcflags, "-o", dst)
|
||||
@ -762,10 +762,8 @@ func main() {
|
||||
func abstractOriginSanity(t *testing.T, pkgDir string, flags string) {
|
||||
t.Parallel()
|
||||
|
||||
dir := t.TempDir()
|
||||
|
||||
// Build with inlining, to exercise DWARF inlining support.
|
||||
f := gobuildTestdata(t, dir, filepath.Join(pkgDir, "main"), flags)
|
||||
f := gobuildTestdata(t, filepath.Join(pkgDir, "main"), flags)
|
||||
defer f.Close()
|
||||
|
||||
d, err := f.DWARF()
|
||||
@ -1231,14 +1229,12 @@ func TestMachoIssue32233(t *testing.T) {
|
||||
t.Skip("skipping; test only interesting on darwin")
|
||||
}
|
||||
|
||||
tmpdir := t.TempDir()
|
||||
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatalf("where am I? %v", err)
|
||||
}
|
||||
pdir := filepath.Join(wd, "testdata", "issue32233", "main")
|
||||
f := gobuildTestdata(t, tmpdir, pdir, DefaultOpt)
|
||||
f := gobuildTestdata(t, pdir, DefaultOpt)
|
||||
f.Close()
|
||||
}
|
||||
|
||||
@ -1313,13 +1309,12 @@ func TestIssue38192(t *testing.T) {
|
||||
|
||||
// Build a test program that contains a translation unit whose
|
||||
// text (from am assembly source) contains only a single instruction.
|
||||
tmpdir := t.TempDir()
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatalf("where am I? %v", err)
|
||||
}
|
||||
pdir := filepath.Join(wd, "testdata", "issue38192")
|
||||
f := gobuildTestdata(t, tmpdir, pdir, DefaultOpt)
|
||||
f := gobuildTestdata(t, pdir, DefaultOpt)
|
||||
defer f.Close()
|
||||
|
||||
// Open the resulting binary and examine the DWARF it contains.
|
||||
@ -1431,14 +1426,12 @@ func TestIssue39757(t *testing.T) {
|
||||
// compiler/runtime in ways that aren't happening now, so this
|
||||
// might be something to check for if it does start failing.
|
||||
|
||||
tmpdir := t.TempDir()
|
||||
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatalf("where am I? %v", err)
|
||||
}
|
||||
pdir := filepath.Join(wd, "testdata", "issue39757")
|
||||
f := gobuildTestdata(t, tmpdir, pdir, DefaultOpt)
|
||||
f := gobuildTestdata(t, pdir, DefaultOpt)
|
||||
defer f.Close()
|
||||
|
||||
syms, err := f.Symbols()
|
||||
@ -1529,17 +1522,12 @@ func TestIssue42484(t *testing.T) {
|
||||
|
||||
t.Parallel()
|
||||
|
||||
tmpdir, err := os.MkdirTemp("", "TestIssue42484")
|
||||
if err != nil {
|
||||
t.Fatalf("could not create directory: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(tmpdir)
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatalf("where am I? %v", err)
|
||||
}
|
||||
pdir := filepath.Join(wd, "testdata", "issue42484")
|
||||
f := gobuildTestdata(t, tmpdir, pdir, NoOpt)
|
||||
f := gobuildTestdata(t, pdir, NoOpt)
|
||||
|
||||
var lastAddr uint64
|
||||
var lastFile string
|
||||
|
Loading…
Reference in New Issue
Block a user