From: Kir Kolyshkin Date: Wed, 4 Sep 2024 02:46:46 +0000 (-0700) Subject: cmd/link/internal/ld: rm os.Getwd from dwarf_test X-Git-Tag: go1.24rc1~1004 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9ba8ac253ef366c708b06c66c8e20cbb1572de2f;p=gostls13.git cmd/link/internal/ld: rm os.Getwd from dwarf_test Calls to os.Getwd were needed to set the cwd for go build to an absolute path. Since CL 401340 os/exec takes care of setting PWD to a filepath.Abs(cmd.Dir), so it looks like an absolute path is not really required. Change-Id: Ib3abffc9087a3329d8f40f81eb65f1b2c1a03a9c Reviewed-on: https://go-review.googlesource.com/c/go/+/610038 Auto-Submit: Ian Lance Taylor Commit-Queue: Ian Lance Taylor Reviewed-by: Cherry Mui Reviewed-by: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/link/internal/ld/dwarf_test.go b/src/cmd/link/internal/ld/dwarf_test.go index e14e2edc8f..adb5c2607c 100644 --- a/src/cmd/link/internal/ld/dwarf_test.go +++ b/src/cmd/link/internal/ld/dwarf_test.go @@ -838,13 +838,7 @@ func TestAbstractOriginSanity(t *testing.T) { } mustHaveDWARF(t) - - if wd, err := os.Getwd(); err == nil { - gopathdir := filepath.Join(wd, "testdata", "httptest") - abstractOriginSanity(t, gopathdir, OptAllInl4) - } else { - t.Fatalf("os.Getwd() failed %v", err) - } + abstractOriginSanity(t, "testdata/httptest", OptAllInl4) } func TestAbstractOriginSanityIssue25459(t *testing.T) { @@ -855,24 +849,14 @@ func TestAbstractOriginSanityIssue25459(t *testing.T) { t.Skip("skipping on not-amd64 not-386; location lists not supported") } - if wd, err := os.Getwd(); err == nil { - gopathdir := filepath.Join(wd, "testdata", "issue25459") - abstractOriginSanity(t, gopathdir, DefaultOpt) - } else { - t.Fatalf("os.Getwd() failed %v", err) - } + abstractOriginSanity(t, "testdata/issue25459", DefaultOpt) } func TestAbstractOriginSanityIssue26237(t *testing.T) { testenv.MustHaveGoBuild(t) mustHaveDWARF(t) - if wd, err := os.Getwd(); err == nil { - gopathdir := filepath.Join(wd, "testdata", "issue26237") - abstractOriginSanity(t, gopathdir, DefaultOpt) - } else { - t.Fatalf("os.Getwd() failed %v", err) - } + abstractOriginSanity(t, "testdata/issue26237", DefaultOpt) } func TestRuntimeTypeAttrInternal(t *testing.T) { @@ -1229,12 +1213,7 @@ func TestMachoIssue32233(t *testing.T) { t.Skip("skipping; test only interesting on darwin") } - wd, err := os.Getwd() - if err != nil { - t.Fatalf("where am I? %v", err) - } - pdir := filepath.Join(wd, "testdata", "issue32233", "main") - f := gobuildTestdata(t, pdir, DefaultOpt) + f := gobuildTestdata(t, "testdata/issue32233/main", DefaultOpt) f.Close() } @@ -1309,12 +1288,7 @@ 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. - wd, err := os.Getwd() - if err != nil { - t.Fatalf("where am I? %v", err) - } - pdir := filepath.Join(wd, "testdata", "issue38192") - f := gobuildTestdata(t, pdir, DefaultOpt) + f := gobuildTestdata(t, "testdata/issue38192", DefaultOpt) defer f.Close() // Open the resulting binary and examine the DWARF it contains. @@ -1426,12 +1400,7 @@ 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. - wd, err := os.Getwd() - if err != nil { - t.Fatalf("where am I? %v", err) - } - pdir := filepath.Join(wd, "testdata", "issue39757") - f := gobuildTestdata(t, pdir, DefaultOpt) + f := gobuildTestdata(t, "testdata/issue39757", DefaultOpt) defer f.Close() syms, err := f.Symbols() @@ -1522,12 +1491,7 @@ func TestIssue42484(t *testing.T) { t.Parallel() - wd, err := os.Getwd() - if err != nil { - t.Fatalf("where am I? %v", err) - } - pdir := filepath.Join(wd, "testdata", "issue42484") - f := gobuildTestdata(t, pdir, NoOpt) + f := gobuildTestdata(t, "testdata/issue42484", NoOpt) var lastAddr uint64 var lastFile string