Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Also update line endings for stderr
  • Loading branch information
kyleconroy committed Dec 5, 2023
commit 5bc92e7f693fa2164a48b3eac041db9f042ee3a9
14 changes: 9 additions & 5 deletions internal/endtoend/endtoend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ import (
"github.com/sqlc-dev/sqlc/internal/opts"
)

func lineEndings() cmp.Option {
return cmp.Transformer("LineEndings", func(in string) string {
// Replace Windows new lines with Unix newlines
return strings.Replace(in, "\r\n", "\n", -1)
})
}

func TestExamples(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down Expand Up @@ -181,7 +188,7 @@ func TestReplay(t *testing.T) {
t.Fatalf("sqlc %s failed: %s", args.Command, stderr.String())
}

diff := cmp.Diff(strings.TrimSpace(expected), strings.TrimSpace(stderr.String()))
diff := cmp.Diff(strings.TrimSpace(expected), strings.TrimSpace(stderr.String()), lineEndings())
if diff != "" {
t.Fatalf("stderr differed (-want +got):\n%s", diff)
}
Expand Down Expand Up @@ -236,10 +243,7 @@ func cmpDirectory(t *testing.T, dir string, actual map[string]string) {

opts := []cmp.Option{
cmpopts.EquateEmpty(),
cmp.Transformer("LineEndings", func(in string) string {
// Replace Windows new lines with Unix newlines
return strings.Replace(in, "\r\n", "\n", -1)
}),
lineEndings(),
}

if !cmp.Equal(expected, actual, opts...) {
Expand Down