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.
pull/13032/head
Lucas Bajolet 2 years ago committed by Lucas Bajolet
parent a31507d575
commit 646f1c46a1

@ -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)

Loading…
Cancel
Save