From d65074c05cf2f40d65a9b9c6ec170cc9e4abcb98 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 12 Jun 2024 11:27:41 -0400 Subject: [PATCH] packer_test: dump command outs in case of failure When a test fails to exert its assertions on the command-line output, a test fails, but we don't necessarily can troubleshoot what happened, especially when this happens in a CI environment. Therefore, for convenience, we add the faculty for packerCommand.Assert to automatically dump a command's output (both stdout and stderr) if a test fails. --- packer_test/commands_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packer_test/commands_test.go b/packer_test/commands_test.go index 0c362e823..6537698ba 100644 --- a/packer_test/commands_test.go +++ b/packer_test/commands_test.go @@ -155,6 +155,10 @@ func (pc *packerCommand) Assert(checks ...Checker) { if pc.t.Failed() { pc.t.Errorf("attempt %d failed validation", attempt) + + pc.t.Logf("dumping stdout: %s", stdout) + pc.t.Logf("dumping stdout: %s", stderr) + break } }