From 7a5fc2525ac988909a4f4742496af8ae25b263aa Mon Sep 17 00:00:00 2001 From: Anurag Sharma Date: Wed, 19 Mar 2025 18:49:48 +0530 Subject: [PATCH] packer_test: added shell provisioner test with empty inline list --- .../provisioner_tests/shell/provisioner_test.go | 15 +++++++++++++++ .../shell/templates/empty_inline_list.pkr.hcl | 12 ++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 packer_test/provisioner_tests/shell/templates/empty_inline_list.pkr.hcl diff --git a/packer_test/provisioner_tests/shell/provisioner_test.go b/packer_test/provisioner_tests/shell/provisioner_test.go index 480544b8e..205d3a71f 100644 --- a/packer_test/provisioner_tests/shell/provisioner_test.go +++ b/packer_test/provisioner_tests/shell/provisioner_test.go @@ -80,3 +80,18 @@ func (ts *PackerShellProvisionerTestSuite) TestInvalidShebangAsOption() { SetArgs("build", "templates/shebang_as_option_invalid.pkr.hcl"). Assert(check.MustFail()) } + +func (ts *PackerShellProvisionerTestSuite) TestEmptyInlineCommands() { + dir := ts.MakePluginDir() + defer dir.Cleanup() + + ts.PackerCommand().UsePluginDir(dir). + SetArgs("plugins", "install", "github.com/hashicorp/docker"). + Assert(check.MustSucceed()) + + ts.PackerCommand().UsePluginDir(dir). + AddEnv("HOME", os.Getenv("HOME")). + AddEnv("PATH", os.Getenv("PATH")). + SetArgs("build", "templates/empty_inline_list.pkr.hcl"). + Assert(check.MustFail()) +} diff --git a/packer_test/provisioner_tests/shell/templates/empty_inline_list.pkr.hcl b/packer_test/provisioner_tests/shell/templates/empty_inline_list.pkr.hcl new file mode 100644 index 000000000..57ddc5dbf --- /dev/null +++ b/packer_test/provisioner_tests/shell/templates/empty_inline_list.pkr.hcl @@ -0,0 +1,12 @@ +source "docker" "test" { + image = "debian:bookworm" + discard = true +} + +build { + sources = ["docker.test"] + + provisioner "shell" { + inline = [] + } +}