Skip to content

Commit c77ca70

Browse files
ChangWangMagopherbot
authored andcommitted
cmd/link, go/internal/gccgoimporter: get ar from env by default in tests
Change-Id: Ib64b1f641fcf795a51aaf31639d37927dab519e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/622237 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent c5d424b commit c77ca70

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/cmd/link/dwarf_test.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,14 @@ func testDWARF(t *testing.T, buildmode string, expectDWARF bool, env ...string)
121121

122122
if buildmode == "c-archive" {
123123
// Extract the archive and use the go.o object within.
124-
cmd := testenv.Command(t, "ar", "-x", exe)
124+
ar := os.Getenv("AR")
125+
if ar == "" {
126+
ar = "ar"
127+
}
128+
cmd := testenv.Command(t, ar, "-x", exe)
125129
cmd.Dir = tmpDir
126130
if out, err := cmd.CombinedOutput(); err != nil {
127-
t.Fatalf("ar -x %s: %v\n%s", exe, err, out)
131+
t.Fatalf("%s -x %s: %v\n%s", ar, exe, err, out)
128132
}
129133
exe = filepath.Join(tmpDir, "go.o")
130134
}

src/go/internal/gccgoimporter/importer_test.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,15 @@ func TestObjImporter(t *testing.T) {
180180

181181
runImporterTest(t, imp, initmap, &test)
182182

183-
cmd = testenv.Command(t, "ar", "cr", afile, ofile)
183+
ar := os.Getenv("AR")
184+
if ar == "" {
185+
ar = "ar"
186+
}
187+
cmd = testenv.Command(t, ar, "cr", afile, ofile)
184188
out, err = cmd.CombinedOutput()
185189
if err != nil {
186190
t.Logf("%s", out)
187-
t.Fatalf("ar cr %s %s failed: %s", afile, ofile, err)
191+
t.Fatalf("%s cr %s %s failed: %s", ar, afile, ofile, err)
188192
}
189193

190194
runImporterTest(t, arimp, arinitmap, &test)

0 commit comments

Comments
 (0)