From f77da46b3fce2161f0f1981a7f8d2e8d74c845c1 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 15 May 2024 17:33:08 -0400 Subject: [PATCH] packer_test: compile packer with .exe for Windows Since on Windows extensions are mandatory in order to have something executable, we compile Packer with a `.exe` suffix during tests, so we can use the executable afterwards to run tests with. --- packer_test/base_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packer_test/base_test.go b/packer_test/base_test.go index e3e56b306..4fe675d31 100644 --- a/packer_test/base_test.go +++ b/packer_test/base_test.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "testing" ) @@ -21,6 +22,9 @@ func BuildTestPacker(t *testing.T) (string, error) { packerCoreDir := filepath.Dir(testDir) outBin := filepath.Join(os.TempDir(), fmt.Sprintf("packer_core-%d", rand.Int())) + if runtime.GOOS == "windows" { + outBin = fmt.Sprintf("%s.exe", outBin) + } compileCommand := exec.Command("go", "build", "-C", packerCoreDir, "-o", outBin) logs, err := compileCommand.CombinedOutput()