Skip to content

Commit

Permalink
add a simpler test compile, skip iostream one on ci
Browse files Browse the repository at this point in the history
  • Loading branch information
renefritze committed Nov 15, 2022
1 parent fa35524 commit f433775
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
21 changes: 18 additions & 3 deletions test/test_executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,43 @@
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)
except ValueError:
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 <iostream>\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 <iostream>\n")


def test_main():
_test_code("int main() { return 0;}\n")

0 comments on commit f433775

Please sign in to comment.