diff --git a/tfexec/internal/e2etest/show_test.go b/tfexec/internal/e2etest/show_test.go index 4268fe74..115438de 100644 --- a/tfexec/internal/e2etest/show_test.go +++ b/tfexec/internal/e2etest/show_test.go @@ -192,12 +192,10 @@ func TestShowStateFile013(t *testing.T) { // Plan files cannot be transferred between different Terraform versions, // so we maintain one fixture per supported version -func TestShowPlanFile012(t *testing.T) { +func TestShowPlanFile012_linux(t *testing.T) { runTestVersions(t, []string{testutil.Latest012}, "non_default_planfile_012", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) { - // plan file fixture was created in Linux, and is - // not compatible with Windows - if runtime.GOOS == "windows" { - t.Skip("plan file created in 0.12 on Linux is not compatible with Windows") + if runtime.GOOS != "linux" { + t.Skip("plan file created in 0.12 on Linux is not compatible with other systems") } providerName := "null" @@ -322,12 +320,10 @@ func TestShowPlanFile013(t *testing.T) { }) } -func TestShowPlanFileRaw012(t *testing.T) { +func TestShowPlanFileRaw012_linux(t *testing.T) { runTestVersions(t, []string{testutil.Latest012}, "non_default_planfile_012", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) { - // plan file fixture was created in Linux, and is - // not compatible with Windows - if runtime.GOOS == "windows" { - t.Skip("plan file created in 0.12 on Linux is not compatible with Windows") + if runtime.GOOS != "linux" { + t.Skip("plan file created in 0.12 on Linux is not compatible with other systems") } // crlf will standardize our line endings for us diff --git a/tfinstall/git_ref.go b/tfinstall/git_ref.go index 60c01783..71149bd4 100644 --- a/tfinstall/git_ref.go +++ b/tfinstall/git_ref.go @@ -5,7 +5,9 @@ import ( "fmt" "io/ioutil" "log" + "os" "os/exec" + "path/filepath" "runtime" "github.com/go-git/go-git/v5" @@ -72,7 +74,14 @@ func (opt *GitRefOption) ExecPath(ctx context.Context) (string, error) { binFile.Close() } - cmd := exec.CommandContext(ctx, "go", "build", "-mod", "vendor", "-o", binName) + goArgs := []string{"build", "-o", binName} + + vendorDir := filepath.Join(installDir, "vendor") + if fi, err := os.Stat(vendorDir); err == nil && fi.IsDir() { + goArgs = append(goArgs, "-mod", "vendor") + } + + cmd := exec.CommandContext(ctx, "go", goArgs...) cmd.Dir = installDir out, err := cmd.CombinedOutput() log.Print(string(out))