Skip to content

Commit

Permalink
deps: Remove github.com/andybalholm/crlf (#289)
Browse files Browse the repository at this point in the history
Replaced via trivial `strings` handling as the strings are not large.
  • Loading branch information
bflad authored Apr 13, 2022
1 parent facff44 commit 0cf3a0c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/hashicorp/terraform-exec
go 1.17

require (
github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f
github.com/google/go-cmp v0.5.7
github.com/hashicorp/go-version v1.4.0
github.com/hashicorp/hc-install v0.3.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C6
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk=
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f h1:NNJE6p4LchkmNfNskDUaSbrwxZzr7t2/lj2aS+q4oF0=
github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f/go.mod h1:k8feO4+kXDxro6ErPXBRTJ/ro2mf0SsFG8s7doP9kJE=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
Expand Down
28 changes: 18 additions & 10 deletions tfexec/internal/e2etest/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"encoding/json"
"errors"
"io/ioutil"
"os"
"runtime"
"strings"
"testing"

"github.com/andybalholm/crlf"
"github.com/google/go-cmp/cmp"
"github.com/hashicorp/go-version"
tfjson "github.com/hashicorp/terraform-json"
Expand Down Expand Up @@ -588,8 +588,7 @@ func TestShowPlanFileRaw012_linux(t *testing.T) {
t.Skip("plan file created in 0.12 on Linux is not compatible with other systems")
}

// crlf will standardize our line endings for us
f, err := crlf.Open("testdata/non_default_planfile_012/human_readable_output.txt")
f, err := os.Open("testdata/non_default_planfile_012/human_readable_output.txt")
if err != nil {
t.Fatal(err)
}
Expand All @@ -609,16 +608,15 @@ func TestShowPlanFileRaw012_linux(t *testing.T) {
t.Fatal(err)
}

if diff := cmp.Diff(strings.TrimSpace(actual), strings.TrimSpace(string(expected))); diff != "" {
if diff := cmp.Diff(normalizePlanOutput(actual), normalizePlanOutput(string(expected))); diff != "" {
t.Fatalf("unexpected difference: %s", diff)
}
})
}

func TestShowPlanFileRaw013(t *testing.T) {
runTestVersions(t, []string{testutil.Latest013}, "non_default_planfile_013", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
// crlf will standardize our line endings for us
f, err := crlf.Open("testdata/non_default_planfile_013/human_readable_output.txt")
f, err := os.Open("testdata/non_default_planfile_013/human_readable_output.txt")
if err != nil {
t.Fatal(err)
}
Expand All @@ -638,16 +636,15 @@ func TestShowPlanFileRaw013(t *testing.T) {
t.Fatal(err)
}

if diff := cmp.Diff(strings.TrimSpace(actual), strings.TrimSpace(string(expected))); diff != "" {
if diff := cmp.Diff(normalizePlanOutput(actual), normalizePlanOutput(string(expected))); diff != "" {
t.Fatalf("unexpected difference: %s", diff)
}
})
}

func TestShowPlanFileRaw014(t *testing.T) {
runTestVersions(t, []string{testutil.Latest014}, "non_default_planfile_014", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
// crlf will standardize our line endings for us
f, err := crlf.Open("testdata/non_default_planfile_013/human_readable_output.txt")
f, err := os.Open("testdata/non_default_planfile_013/human_readable_output.txt")
if err != nil {
t.Fatal(err)
}
Expand All @@ -666,7 +663,7 @@ func TestShowPlanFileRaw014(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if diff := cmp.Diff(strings.TrimSpace(actual), strings.TrimSpace(string(expected))); diff != "" {
if diff := cmp.Diff(normalizePlanOutput(actual), normalizePlanOutput(string(expected))); diff != "" {
t.Fatalf("unexpected difference: %s", diff)
}
})
Expand Down Expand Up @@ -739,3 +736,14 @@ func TestShowBigInt(t *testing.T) {
}
})
}

// Since our plan strings are not large, prefer simple cross-platform
// normalization handling over pulling in a dependency.
func normalizePlanOutput(str string) string {
// Ignore any extra newlines at the beginning or end of output
str = strings.TrimSpace(str)
// Normalize CRLF to LF for cross-platform testing
str = strings.Replace(str, "\r\n", "\n", -1)

return str
}

0 comments on commit 0cf3a0c

Please sign in to comment.