MCPcopy Create free account
hub / github.com/FastLED/FastLED / check_file

Method check_file

ci/tests/test_missing_pragma_once.py:25–41  ·  view source on GitHub ↗

Check if a header file has #pragma once directive or if a cpp file incorrectly has it.

(self, file_path: str)

Source from the content-addressed store, hash-verified

23
24class TestMissingPragmaOnce(unittest.TestCase):
25 def check_file(self, file_path: str) -> list[str]:
26 """Check if a header file has #pragma once directive or if a cpp file incorrectly has it."""
27 failings: list[str] = []
28
29 with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
30 content = f.read()
31
32 if file_path.endswith(".h"):
33 # For header files, check if #pragma once is missing
34 if "#pragma once" not in content:
35 failings.append(f"Missing #pragma once in {file_path}")
36 elif file_path.endswith(".cpp"):
37 # For cpp files, check if #pragma once is incorrectly present
38 if "#pragma once" in content:
39 failings.append(f"Incorrect #pragma once in cpp file: {file_path}")
40
41 return failings
42
43 def test_pragma_once_usage(self) -> None:
44 """

Callers

nothing calls this directly

Calls 2

readMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected