Skip to content

Commit 4a82d1c

Browse files
Report external ar tool output on TestWriteValidArchive failure (#18)
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.
1 parent 9dff68c commit 4a82d1c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

writer_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ func TestWriteValidArchive(t *testing.T) {
122122
err = f.Close()
123123
require.NoError(t, err)
124124

125-
cmd := exec.Command(tc.ArPath, append(tc.ArArgs, "-x", tmp)...)
126-
err = cmd.Run()
127-
require.NoError(t, err)
125+
out, err := exec.Command(tc.ArPath, append(tc.ArArgs, "-x", tmp)...).CombinedOutput()
126+
if !assert.NoError(t, err) {
127+
t.Fatalf("%s output:\n%s\n", tc.ArPath, out)
128+
}
128129

129130
for i, fileName := range fileNames {
130131
fi, err := os.Stat(fileName)

0 commit comments

Comments
 (0)