Skip to content

Commit 1a5ee37

Browse files
committed
add fixture
1 parent df5c583 commit 1a5ee37

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

tests/test_clang_tidy.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@
55
from cpp_linter_hooks.clang_tidy import run_clang_tidy
66

77

8+
@pytest.fixture(scope='function')
9+
def generate_compilation_database():
10+
# Generate compilation database
11+
subprocess.run(['mkdir', '-p', 'build', '&&', 'cmake', '-Bbuild', 'testing/'], shell=True)
12+
13+
814
@pytest.mark.parametrize(
915
('args', 'expected_retval'), (
1016
(['--checks="boost-*"'], 1),
1117
(['--checks="boost-*"', '--version=16'], 1),
1218
),
1319
)
14-
def test_run_clang_tidy_valid(args, expected_retval, tmp_path):
15-
subprocess.run(['mkdir', '-p', 'build', '&&', 'cmake', '-Bbuild', 'testing/'], shell=True)
20+
def test_run_clang_tidy_valid(args, expected_retval, tmp_path, generate_compilation_database):
1621
# copy test file to tmp_path to prevent modifying repo data
22+
generate_compilation_database
1723
test_file = tmp_path / "main.c"
1824
test_file.write_bytes(Path("testing/main.c").read_bytes())
1925
ret, output = run_clang_tidy(args + [str(test_file)])

tests/test_util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_ensure_installed(tool, version, tmp_path, monkeypatch, caplog):
3333
# first run should install
3434
assert caplog.record_tuples[0][2] == f"Checking for {tool}, version {bin_version}"
3535
if run == 0:
36-
# FIXME
36+
# FIXME
3737
# assert caplog.record_tuples[1][2] == f"Installing {tool}, version {bin_version}"
3838
assert caplog.record_tuples[1][2] == f"{tool}, version {bin_version} is already installed"
3939
# second run should just confirm it's already installed

0 commit comments

Comments
 (0)