From 646f1c46a17682c55782afb5744f12efef676b54 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Tue, 7 May 2024 15:58:05 -0400 Subject: [PATCH] test: allow custom Packer executable for acctests When running the core acceptance tests we compile a temporary Packer binary to run the tests with. However in some cases we may want to run a test with another, pre-compiled version of Packer. For this use-case, we introduce an environment variable to change the executable we're running tests with. --- test/suite_test.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/suite_test.go b/test/suite_test.go index abf22f2ec..b0d74cccb 100644 --- a/test/suite_test.go +++ b/test/suite_test.go @@ -56,15 +56,23 @@ func Test_PackerCoreSuite(t *testing.T) { ts.pluginsDirectory = pluginsDirectory ts.buildPluginBinaries(t) - t.Logf("Building test packer binary...") - packerPath, err := BuildTestPacker(t) - if err != nil { - t.Fatalf("failed to build Packer binary: %s", err) + packerPath := os.Getenv("PACKER_CUSTOM_PATH") + if packerPath == "" { + var err error + t.Logf("Building test packer binary...") + packerPath, err = BuildTestPacker(t) + if err != nil { + t.Fatalf("failed to build Packer binary: %s", err) + } } ts.packerPath = packerPath t.Logf("Done") defer func() { + if os.Getenv("PACKER_CUSTOM_PATH") != "" { + return + } + err := os.Remove(ts.packerPath) if err != nil { t.Logf("failed to cleanup compiled packer binary %q: %s. This will need manual aciton", packerPath, err)