Skip to content

Commit 1e2ca10

Browse files
committed
Add test for JSON output
1 parent 59296eb commit 1e2ca10

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

crates/ruff/tests/integration_test.rs

+29
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,35 @@ fn show_statistics() {
860860
"###);
861861
}
862862

863+
#[test]
864+
fn show_statistics_json() {
865+
let mut cmd = RuffCheck::default()
866+
.args([
867+
"--select",
868+
"F401",
869+
"--statistics",
870+
"--output-format",
871+
"json",
872+
])
873+
.build();
874+
assert_cmd_snapshot!(cmd
875+
.pass_stdin("import sys\nimport os\n\nprint(os.getuid())\n"), @r###"
876+
success: false
877+
exit_code: 1
878+
----- stdout -----
879+
[
880+
{
881+
"code": "F401",
882+
"name": "unused-import",
883+
"count": 1,
884+
"fixable": true
885+
}
886+
]
887+
888+
----- stderr -----
889+
"###);
890+
}
891+
863892
#[test]
864893
fn nursery_prefix() {
865894
// Should only detect RUF90X, but not the unstable test rules

0 commit comments

Comments
 (0)