Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing tests #89

Merged
merged 2 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions tfexec/internal/e2etest/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion tfinstall/git_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
"runtime"

"github.com/go-git/go-git/v5"
Expand Down Expand Up @@ -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))
Expand Down