From bdcf68dca11b6fc5424ba2a702732c9d642d3c3c Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Mon, 17 Jun 2024 16:19:35 +0000 Subject: [PATCH] backport of commit 7823d159aff5a4a713a82c1ad537963a9bacfc92 --- packer_test/commands_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packer_test/commands_test.go b/packer_test/commands_test.go index fa6520996..b8d7bc584 100644 --- a/packer_test/commands_test.go +++ b/packer_test/commands_test.go @@ -138,6 +138,12 @@ func (pc *packerCommand) Run() (string, string, error) { pc.err = cmd.Run() + // Check that the command didn't panic, and if it did, we can immediately error + panicErr := PanicCheck{}.Check(pc.stdout.String(), pc.stderr.String(), pc.err) + if panicErr != nil { + pc.t.Fatalf("Packer panicked during execution: %s", panicErr) + } + return pc.stdout.String(), pc.stderr.String(), pc.err } @@ -147,8 +153,6 @@ func (pc *packerCommand) Assert(checks ...Checker) { attempt++ stdout, stderr, err := pc.Run() - checks = append(checks, PanicCheck{}) - for _, check := range checks { checkErr := check.Check(stdout, stderr, err) if checkErr != nil {