From f26c29723f372284ff7dc0dbf30bae5561a3e618 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 29 Aug 2024 19:00:00 -0700 Subject: cmd: use testenv.Executable helper Change-Id: I25ac0e8d25d760bfde3bb7700f0feaa23f3e8ab1 Reviewed-on: https://go-review.googlesource.com/c/go/+/609302 Reviewed-by: Ian Lance Taylor Reviewed-by: Cherry Mui Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI --- src/cmd/nm/nm_test.go | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'src/cmd/nm') diff --git a/src/cmd/nm/nm_test.go b/src/cmd/nm/nm_test.go index 530a720f2b..4ee4217c59 100644 --- a/src/cmd/nm/nm_test.go +++ b/src/cmd/nm/nm_test.go @@ -12,7 +12,6 @@ import ( "path/filepath" "runtime" "strings" - "sync" "testing" "text/template" ) @@ -29,26 +28,6 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -// nmPath returns the path to the "nm" binary to run. -func nmPath(t testing.TB) string { - t.Helper() - testenv.MustHaveExec(t) - - nmPathOnce.Do(func() { - nmExePath, nmPathErr = os.Executable() - }) - if nmPathErr != nil { - t.Fatal(nmPathErr) - } - return nmExePath -} - -var ( - nmPathOnce sync.Once - nmExePath string - nmPathErr error -) - func TestNonGoExecs(t *testing.T) { t.Parallel() testfiles := []string{ @@ -74,7 +53,7 @@ func TestNonGoExecs(t *testing.T) { exepath = tf } - cmd := testenv.Command(t, nmPath(t), exepath) + cmd := testenv.Command(t, testenv.Executable(t), exepath) out, err := cmd.CombinedOutput() if err != nil { t.Errorf("go tool nm %v: %v\n%s", exepath, err, string(out)) @@ -148,7 +127,7 @@ func testGoExec(t *testing.T, iscgo, isexternallinker bool) { runtimeSyms["runtime.epclntab"] = "D" } - out, err = testenv.Command(t, nmPath(t), exe).CombinedOutput() + out, err = testenv.Command(t, testenv.Executable(t), exe).CombinedOutput() if err != nil { t.Fatalf("go tool nm: %v\n%s", err, string(out)) } @@ -259,7 +238,7 @@ func testGoLib(t *testing.T, iscgo bool) { } mylib := filepath.Join(libpath, "mylib.a") - out, err = testenv.Command(t, nmPath(t), mylib).CombinedOutput() + out, err = testenv.Command(t, testenv.Executable(t), mylib).CombinedOutput() if err != nil { t.Fatalf("go tool nm: %v\n%s", err, string(out)) } -- cgit v1.3-5-g9baa