diff --git a/packer_test/common/check/gadgets.go b/packer_test/common/check/gadgets.go index 14761d98c..ec8e53fd3 100644 --- a/packer_test/common/check/gadgets.go +++ b/packer_test/common/check/gadgets.go @@ -195,6 +195,20 @@ func (d dump) Check(stdout, stderr string, err error) error { return nil } +func DumpCommand(t *testing.T, command string) Checker { + return &dumpCommand{t, command} +} + +type dumpCommand struct { + t *testing.T + command string +} + +func (d dumpCommand) Check(_, _ string, _ error) error { + d.t.Logf("ran command %s", d.command) + return nil +} + type PanicCheck struct{} func (_ PanicCheck) Check(stdout, stderr string, _ error) error { diff --git a/packer_test/common/commands.go b/packer_test/common/commands.go index c0c043674..c9bfd3119 100644 --- a/packer_test/common/commands.go +++ b/packer_test/common/commands.go @@ -135,6 +135,17 @@ func (pc *packerCommand) Dump() *packerCommand { return pc } +func (pc *packerCommand) commandString() string { + buf := &strings.Builder{} + + fmt.Fprintf(buf, "%q", pc.packerPath) + for _, arg := range pc.args { + fmt.Fprintf(buf, " %q", arg) + } + + return buf.String() +} + // Run executes the packer command with the args/env requested and returns the // output streams (stdout, stderr) // @@ -194,6 +205,7 @@ func (pc *packerCommand) Output() (string, string, error) { func (pc *packerCommand) Assert(checks ...check.Checker) { if pc.dump { tmpChecks := []check.Checker{ + check.DumpCommand(pc.t, pc.commandString()), check.Dump(pc.t), }