From f564497630d8d12023cd093904bf237ab1079a94 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 18 Jun 2022 12:44:43 -0400 Subject: fix(fmt): should fail `--check` on parse error (#14907) --- cli/tests/integration/fmt_tests.rs | 6 ++++++ cli/tests/testdata/fmt/fmt_check_parse_error.out | 6 ++++++ cli/tests/testdata/fmt/parse_error/parse_error.ts | 2 ++ 3 files changed, 14 insertions(+) create mode 100644 cli/tests/testdata/fmt/fmt_check_parse_error.out create mode 100644 cli/tests/testdata/fmt/parse_error/parse_error.ts (limited to 'cli/tests') diff --git a/cli/tests/integration/fmt_tests.rs b/cli/tests/integration/fmt_tests.rs index 18ad2ab29..3f4bc15cb 100644 --- a/cli/tests/integration/fmt_tests.rs +++ b/cli/tests/integration/fmt_tests.rs @@ -177,6 +177,12 @@ itest!(fmt_check_ignore { exit_code: 0, }); +itest!(fmt_check_parse_error { + args: "fmt --check fmt/parse_error/parse_error.ts", + output: "fmt/fmt_check_parse_error.out", + exit_code: 1, +}); + itest!(fmt_stdin { args: "fmt -", input: Some("const a = 1\n"), diff --git a/cli/tests/testdata/fmt/fmt_check_parse_error.out b/cli/tests/testdata/fmt/fmt_check_parse_error.out new file mode 100644 index 000000000..d9b918af7 --- /dev/null +++ b/cli/tests/testdata/fmt/fmt_check_parse_error.out @@ -0,0 +1,6 @@ +Error checking: [WILDCARD] + Line 2, column 7: Expected '{', got '' + + class Test + ~~~~ +error: Found 1 not formatted file in 1 file diff --git a/cli/tests/testdata/fmt/parse_error/parse_error.ts b/cli/tests/testdata/fmt/parse_error/parse_error.ts new file mode 100644 index 000000000..136d16508 --- /dev/null +++ b/cli/tests/testdata/fmt/parse_error/parse_error.ts @@ -0,0 +1,2 @@ +// a file that purposefully will cause an error +class Test -- cgit v1.2.3