mirror of
https://github.com/deepseek-ai/DeepInfer.git
synced 2026-10-30 07:47:10 +08:00
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import shutil
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.ci
|
|
@pytest.mark.ci_npu
|
|
def test_format_csrc_with_spaces(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
formatter = shutil.which("clang-format")
|
|
if formatter is None:
|
|
pytest.skip("clang-format is required (see requirements-dev.txt)")
|
|
monkeypatch.setenv("CLANG_FORMAT", formatter)
|
|
|
|
repo = Path(__file__).resolve().parents[2]
|
|
checkout = tmp_path / "checkout with spaces"
|
|
(checkout / "scripts").mkdir(parents=True)
|
|
(checkout / "csrc").mkdir()
|
|
script = checkout / "scripts/format_csrc.sh"
|
|
shutil.copyfile(repo / "scripts/format_csrc.sh", script)
|
|
shutil.copyfile(repo / ".clang-format", checkout / ".clang-format")
|
|
source = checkout / "csrc/source with spaces.cpp"
|
|
source.write_text("int value=1;\n")
|
|
|
|
for args in ([], ["--check"]):
|
|
subprocess.run(
|
|
["bash", str(script), *args],
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=15,
|
|
)
|
|
assert source.read_text() == "int value = 1;\n"
|