mirror of
https://github.com/deepseek-ai/DeepInfer.git
synced 2026-10-29 23:37:28 +08:00
Merge 0d927ca8a045baf525c13671e7c35fd7ed2cc148 into 553741557a57df44a46fb3ab72b6aafeaf945337
This commit is contained in:
commit
f709d0dae3
@ -68,6 +68,8 @@ if [ "${1:-}" = "--check" ]; then
|
||||
fi
|
||||
else
|
||||
echo "Formatting $FILE_COUNT files in csrc/..."
|
||||
echo "$FILES" | xargs "$CLANG_FORMAT_BIN" -i
|
||||
while IFS= read -r file; do
|
||||
"$CLANG_FORMAT_BIN" -i "$file"
|
||||
done <<< "$FILES"
|
||||
echo "Done."
|
||||
fi
|
||||
|
||||
36
tests/scripts/test_format_csrc.py
Normal file
36
tests/scripts/test_format_csrc.py
Normal file
@ -0,0 +1,36 @@
|
||||
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"
|
||||
Loading…
x
Reference in New Issue
Block a user