From 268a1ffbc38ffcd621094471c5b22b08a2feeeb7 Mon Sep 17 00:00:00 2001 From: Ayush Rangwala Date: Mon, 29 Jan 2024 21:45:20 +0530 Subject: [PATCH] Print error and output on test metal cli command error Signed-off-by: Ayush Rangwala --- test/helper/helper.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/helper/helper.go b/test/helper/helper.go index 8e278d41..ca9fbdd1 100644 --- a/test/helper/helper.go +++ b/test/helper/helper.go @@ -587,15 +587,15 @@ func ExecuteAndCaptureOutput(t *testing.T, root *cobra.Command) []byte { os.Stdout = rescueStdout - if err != nil { - t.Fatal(err) - } - out, ioErr := io.ReadAll(r) if ioErr != nil { t.Logf("error while reading command output: %v", ioErr) } + if err != nil { + t.Fatalf("Failed to execute command with err: [%s]\n with output:\n%s", err.Error(), out) + } + return out }