Skip to content

Commit 7d7fb82

Browse files
committed
test: test dry-run
1 parent 31edb3c commit 7d7fb82

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ venv
1212
result.txt
1313
testing/main.c
1414
*/*compile_commands.json
15+
16+
# Ignore clang-tools binaries
17+
clang-tidy-1*
18+
clang-tidy-2*
19+
clang-format-1*
20+
clang-format-2*

tests/test_clang_format.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,15 @@ def test_run_clang_format_invalid(args, expected_retval, tmp_path):
3939

4040
ret, _ = run_clang_format(args + [str(test_file)])
4141
assert ret == expected_retval
42+
43+
@pytest.mark.parametrize(
44+
('args', 'expected_retval'), (
45+
(['--style=Google',], 1),
46+
),
47+
)
48+
def test_run_clang_format_dry_run(args, expected_retval, tmp_path):
49+
# copy test file to tmp_path to prevent modifying repo data
50+
test_file = tmp_path / "main.c"
51+
ret, output = run_clang_format(['--dry-run', str(test_file)])
52+
assert ret == -1 # Dry run should not fail
53+
assert "No changes made" in output # Assuming clang-format outputs this for no changes

0 commit comments

Comments
 (0)