Skip to content
Merged
Show file tree
Hide file tree
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
stderr comparer
  • Loading branch information
kyleconroy committed Dec 5, 2023
commit 31734199c96b13526809e0dd87c7d3c5c9288be3
13 changes: 12 additions & 1 deletion internal/endtoend/endtoend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ func lineEndings() cmp.Option {
})
}

func stderrTransformer() cmp.Option {
return cmp.Transformer("Stderr", func(in string) string {
s := strings.Replace(in, "\r\n", "\n", -1)
return strings.Replace(s, "\\", "/", -1)
})
}

func TestExamples(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down Expand Up @@ -188,7 +195,11 @@ 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()), lineEndings())
diff := cmp.Diff(
strings.TrimSpace(expected),
strings.TrimSpace(stderr.String()),
stderrTransformer(),
)
if diff != "" {
t.Fatalf("stderr differed (-want +got):\n%s", diff)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/endtoend/testdata/syntax_errors/mysql/stderr.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# package querytest
query/from.sql:2:38: syntax error near "from where id = ?;"
query/select.sql:2:34: syntax error near "select id;"
query/typo.sql:2:8: syntax error near "selectt id, first_name from users;"
query\from.sql:2:38: syntax error near "from where id = ?;"
query\select.sql:2:34: syntax error near "select id;"
query\typo.sql:2:8: syntax error near "selectt id, first_name from users;"