From 344a0405a5ea3582fee34c1dfea1adbcec63d9b0 Mon Sep 17 00:00:00 2001 From: Chris Novakovic Date: Wed, 8 Oct 2025 16:58:00 +0100 Subject: [PATCH 1/2] Report external ar tool output on `TestWriteValidArchive` failure It's not very helpful seeing ``` Failure: in TestWriteValidArchive/GNU_ar writer_test.go:126: Error Trace: Error: Received unexpected error: exit status 1 Test: TestWriteValidArchive/GNU_ar ``` when one of the `TestWriteValidArchive` subtests fails. Additionally report what the tool printed on stderr and stdout to make the nature of the failure more obvious. --- writer_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/writer_test.go b/writer_test.go index 24333cb..745136a 100644 --- a/writer_test.go +++ b/writer_test.go @@ -122,9 +122,10 @@ func TestWriteValidArchive(t *testing.T) { err = f.Close() require.NoError(t, err) - cmd := exec.Command(tc.ArPath, append(tc.ArArgs, "-x", tmp)...) - err = cmd.Run() - require.NoError(t, err) + out, err = exec.Command(tc.ArPath, append(tc.ArArgs, "-x", tmp)...).CombinedOutput() + if !assert.NoError(t, err) { + t.Fatalf("%s output:\n%s\n", tc.ArPath, out) + } for i, fileName := range fileNames { fi, err := os.Stat(fileName) From e59e9b21ea9607a4dbafd2bcfd0002f18969e565 Mon Sep 17 00:00:00 2001 From: Chris Novakovic Date: Wed, 8 Oct 2025 17:03:39 +0100 Subject: [PATCH 2/2] Syntax --- writer_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/writer_test.go b/writer_test.go index 745136a..a3efdb1 100644 --- a/writer_test.go +++ b/writer_test.go @@ -122,7 +122,7 @@ func TestWriteValidArchive(t *testing.T) { err = f.Close() require.NoError(t, err) - out, err = exec.Command(tc.ArPath, append(tc.ArArgs, "-x", tmp)...).CombinedOutput() + out, err := exec.Command(tc.ArPath, append(tc.ArArgs, "-x", tmp)...).CombinedOutput() if !assert.NoError(t, err) { t.Fatalf("%s output:\n%s\n", tc.ArPath, out) }