]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link, go/internal/gccgoimporter: get ar from env by default in tests
authorchangwang ma <machangwang.cn@gmail.com>
Thu, 24 Oct 2024 15:02:46 +0000 (23:02 +0800)
committerGopher Robot <gobot@golang.org>
Mon, 28 Oct 2024 13:39:24 +0000 (13:39 +0000)
Change-Id: Ib64b1f641fcf795a51aaf31639d37927dab519e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/622237
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/link/dwarf_test.go
src/go/internal/gccgoimporter/importer_test.go

index 25d906bc821f9398e2fed6c576c58dd94e64bf77..68849d7db9efa2c2e4da3205b5b5dfb9703c6b1a 100644 (file)
@@ -121,10 +121,14 @@ func testDWARF(t *testing.T, buildmode string, expectDWARF bool, env ...string)
 
                        if buildmode == "c-archive" {
                                // Extract the archive and use the go.o object within.
-                               cmd := testenv.Command(t, "ar", "-x", exe)
+                               ar := os.Getenv("AR")
+                               if ar == "" {
+                                       ar = "ar"
+                               }
+                               cmd := testenv.Command(t, ar, "-x", exe)
                                cmd.Dir = tmpDir
                                if out, err := cmd.CombinedOutput(); err != nil {
-                                       t.Fatalf("ar -x %s: %v\n%s", exe, err, out)
+                                       t.Fatalf("%s -x %s: %v\n%s", ar, exe, err, out)
                                }
                                exe = filepath.Join(tmpDir, "go.o")
                        }
index 76b4500f3b53ffce2ef6f5968655a56a538573d1..a965a55409afd7eab2f0eef7af13b642add0a18f 100644 (file)
@@ -180,11 +180,15 @@ func TestObjImporter(t *testing.T) {
 
                runImporterTest(t, imp, initmap, &test)
 
-               cmd = testenv.Command(t, "ar", "cr", afile, ofile)
+               ar := os.Getenv("AR")
+               if ar == "" {
+                       ar = "ar"
+               }
+               cmd = testenv.Command(t, ar, "cr", afile, ofile)
                out, err = cmd.CombinedOutput()
                if err != nil {
                        t.Logf("%s", out)
-                       t.Fatalf("ar cr %s %s failed: %s", afile, ofile, err)
+                       t.Fatalf("%s cr %s %s failed: %s", ar, afile, ofile, err)
                }
 
                runImporterTest(t, arimp, arinitmap, &test)