From f433775818e56939a2172f015bb2aea0a36fa6cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Fritze?= Date: Tue, 15 Nov 2022 09:48:23 +0100 Subject: [PATCH] add a simpler test compile, skip iostream one on ci --- .github/workflows/Dockerfile | 2 +- test/test_executable.py | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Dockerfile b/.github/workflows/Dockerfile index 8487469..547ae88 100644 --- a/.github/workflows/Dockerfile +++ b/.github/workflows/Dockerfile @@ -2,7 +2,7 @@ ARG BASEOS=slim-bullseye FROM python:3.11-${BASEOS} ARG PLATFORM=manylinux - +ENV CI=1 COPY test /src/test COPY wheelhouse/clang*${PLATFORM}*.whl /tmp RUN python -m pip install pytest /tmp/*whl \ diff --git a/test/test_executable.py b/test/test_executable.py index 5c8c1cd..36f8317 100644 --- a/test/test_executable.py +++ b/test/test_executable.py @@ -10,7 +10,7 @@ def ensure_tidy_from_wheel(monkeypatch): """test the installed clang_tidy package, not the local one""" this_dir = Path(__file__).resolve().absolute().parent - for pd in (this_dir, this_dir / '..'): + for pd in (this_dir, this_dir / ".."): try: new_path = sys.path.remove(pd) monkeypatch.setattr(sys, "path", new_path) @@ -18,20 +18,35 @@ def ensure_tidy_from_wheel(monkeypatch): pass monkeypatch.delitem(sys.modules, "clang_tidy", raising=False) + def test_executable_file(): import clang_tidy + exe = clang_tidy._get_executable("clang-tidy") assert os.path.exists(exe) assert os.access(exe, os.X_OK) -def test_include_iostream(): +def _test_code(code: str): import clang_tidy + fd, compilation_unit = tempfile.mkstemp(suffix=".cpp") os.close(fd) with open(compilation_unit, "w") as ostr: - ostr.write("#include \n") + ostr.write(code) try: assert clang_tidy._run("clang-tidy", "--extra-arg=-v", compilation_unit) == 0 finally: os.remove(compilation_unit) + + +@pytest.mark.skipif( + os.environ.get("CI", None) and "linux" in sys.platform, + reason="https://github.com/ssciwr/clang-tidy-wheel/issues/30", +) +def test_include_iostream(): + _test_code("#include \n") + + +def test_main(): + _test_code("int main() { return 0;}\n")