diff --git a/README.md b/README.md index 6bfd7e3..0d73bbe 100644 --- a/README.md +++ b/README.md @@ -41,3 +41,8 @@ This repository extends the great work of several other projects: * The CI build process is controlled by [cibuildwheel](https://github.com/pypa/cibuildwheel) which makes building wheels across a number of platforms a pleasant experience (!) We are grateful for the generous provisioning with CI resources that GitHub currently offers to Open Source projects. + +## Troubleshooting + +To see which clang-tidy binary the package is using +you can set `CLANG_TIDY_WHEEL_VERBOSE` to `1` in your environment. diff --git a/clang_tidy/__init__.py b/clang_tidy/__init__.py index d5d33eb..c4dac31 100644 --- a/clang_tidy/__init__.py +++ b/clang_tidy/__init__.py @@ -3,6 +3,7 @@ from pathlib import Path import functools import pkg_resources +import os @functools.lru_cache(maxsize=None) @@ -11,7 +12,8 @@ def _get_executable(name:str) -> Path: for s in ("", ".exe", ".bin", ".dmg")] for exe in possibles: if exe.exists(): - print(f'Resource filename: {exe} ') + if os.environ.get("CLANG_TIDY_WHEEL_VERBOSE", None): + print(f'Found binary: {exe} ') return exe raise FileNotFoundError(f"No executable found for {name} at\n{possibles}") diff --git a/test/test_executable.py b/test/test_executable.py index 36f8317..abdbd93 100644 --- a/test/test_executable.py +++ b/test/test_executable.py @@ -19,12 +19,14 @@ def ensure_tidy_from_wheel(monkeypatch): monkeypatch.delitem(sys.modules, "clang_tidy", raising=False) -def test_executable_file(): +def test_executable_file(capsys): import clang_tidy + clang_tidy._get_executable.cache_clear() exe = clang_tidy._get_executable("clang-tidy") assert os.path.exists(exe) assert os.access(exe, os.X_OK) + assert capsys.readouterr().out == "" def _test_code(code: str): @@ -40,6 +42,15 @@ def _test_code(code: str): os.remove(compilation_unit) +def test_verbose_output(capsys, monkeypatch): + import clang_tidy + monkeypatch.setenv("CLANG_TIDY_WHEEL_VERBOSE", "1") + # need to clear cache to make sure the function is run again + clang_tidy._get_executable.cache_clear() + clang_tidy._get_executable("clang-tidy") + assert capsys.readouterr().out + + @pytest.mark.skipif( os.environ.get("CI", None) and "linux" in sys.platform, reason="https://github.com/ssciwr/clang-tidy-wheel/issues/30",