Skip to content

Commit 8a0b41a

Browse files
committed
test: add verbose output tests for compile_commands handling in run_clang_tidy
1 parent b6928ec commit 8a0b41a

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/test_clang_tidy.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,29 @@ def test_compile_commands_explicit_with_p_conflict(tmp_path, capsys):
201201
cmd = mock_run.call_args[0][0]
202202
assert cmd.count("-p") == 1
203203
assert "./other" in cmd
204+
205+
206+
def test_verbose_prints_compile_db_path(tmp_path, monkeypatch, capsys):
207+
monkeypatch.chdir(tmp_path)
208+
build_dir = tmp_path / "build"
209+
build_dir.mkdir()
210+
(build_dir / "compile_commands.json").write_text("[]")
211+
with (
212+
patch("cpp_linter_hooks.clang_tidy.subprocess.run", return_value=_MOCK_RUN),
213+
patch("cpp_linter_hooks.clang_tidy.resolve_install"),
214+
):
215+
run_clang_tidy(["--verbose", "dummy.cpp"])
216+
assert "build" in capsys.readouterr().err
217+
218+
219+
def test_no_verbose_no_extra_stderr(tmp_path, monkeypatch, capsys):
220+
monkeypatch.chdir(tmp_path)
221+
build_dir = tmp_path / "build"
222+
build_dir.mkdir()
223+
(build_dir / "compile_commands.json").write_text("[]")
224+
with (
225+
patch("cpp_linter_hooks.clang_tidy.subprocess.run", return_value=_MOCK_RUN),
226+
patch("cpp_linter_hooks.clang_tidy.resolve_install"),
227+
):
228+
run_clang_tidy(["dummy.cpp"])
229+
assert capsys.readouterr().err == ""

0 commit comments

Comments
 (0)