-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from hashicorp/go112
A number of go112 compilation fixes
- Loading branch information
Showing
6 changed files
with
75 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// +build go1.13 | ||
|
||
package tfexec | ||
|
||
import ( | ||
"os/exec" | ||
) | ||
|
||
// cmdString handles go 1.12 as stringer was only added to exec.Cmd in 1.13 | ||
func cmdString(c *exec.Cmd) string { | ||
return c.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// +build !go1.13 | ||
|
||
package tfexec | ||
|
||
import ( | ||
"os/exec" | ||
"strings" | ||
) | ||
|
||
// cmdString handles go 1.12 as stringer was only added to exec.Cmd in 1.13 | ||
func cmdString(c *exec.Cmd) string { | ||
b := new(strings.Builder) | ||
b.WriteString(c.Path) | ||
for _, a := range c.Args[1:] { | ||
b.WriteByte(' ') | ||
b.WriteString(a) | ||
} | ||
return b.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// This file contains tests that only compile/work in Go 1.13 and forward | ||
// +build go1.13 | ||
|
||
package tfexec | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
) | ||
|
||
// test that a suitable error is returned if NewTerraform is called without a valid | ||
// executable path | ||
func TestNoTerraformBinary(t *testing.T) { | ||
td := testTempDir(t) | ||
defer os.RemoveAll(td) | ||
|
||
_, err := NewTerraform(td, "") | ||
if err == nil { | ||
t.Fatal("expected NewTerraform to error, but it did not") | ||
} | ||
|
||
var e *ErrNoSuitableBinary | ||
if !errors.As(err, &e) { | ||
t.Fatal("expected error to be ErrNoSuitableBinary") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters