From f593bdd3397a7b371ea619c836694d4c02bd6abd Mon Sep 17 00:00:00 2001 From: Arian Rezazadeh Date: Wed, 8 Jan 2025 00:10:13 +0330 Subject: [PATCH] test: add test for not parsable patterns --- .../.grit/patterns/not_parsable.grit | 10 ++++++++++ crates/cli_bin/tests/format.rs | 1 + 2 files changed, 11 insertions(+) create mode 100644 crates/cli_bin/fixtures/unformatted_patterns/.grit/patterns/not_parsable.grit diff --git a/crates/cli_bin/fixtures/unformatted_patterns/.grit/patterns/not_parsable.grit b/crates/cli_bin/fixtures/unformatted_patterns/.grit/patterns/not_parsable.grit new file mode 100644 index 000000000..44f204705 --- /dev/null +++ b/crates/cli_bin/fixtures/unformatted_patterns/.grit/patterns/not_parsable.grit @@ -0,0 +1,10 @@ +language json + +pattern some_pattern($target_dep, $target_version) { + or { + `$key: $value` where { + $key <: `"$target_dep"`, + no_meta_variable => `"$target_version"` + }, + } +} diff --git a/crates/cli_bin/tests/format.rs b/crates/cli_bin/tests/format.rs index 0a5109272..67081ad4a 100644 --- a/crates/cli_bin/tests/format.rs +++ b/crates/cli_bin/tests/format.rs @@ -23,6 +23,7 @@ fn format_patterns_with_rewrite() -> Result<()> { output.status.success(), "Command didn't finish successfully" ); + assert_eq!(output.stderr, b"couldn't format '.grit/patterns/not_parsable.grit': biome couldn't parse: Expected a predicate here.\n"); let yaml_file_content = std::fs::read_to_string(grit_dir.join(".grit/grit.yaml"))?; let test_move_import_file_content =