Files
sousa-gecko/tools/lint/test/test_header_guards.py
T
serge-sans-paille c42d675092 Bug 2009182 - Lint missing header guards r=ahal,linter-reviewers,Standard8
When a file with .h or .hpp extension does not provide a header guard,
fail and/or provide a fix with a standard naming scheme.

Actual linter + test + documentation.

Differential Revision: https://phabricator.services.mozilla.com/D278442
2026-01-15 13:41:22 +00:00

23 lines
454 B
Python

import mozunit
LINTER = "header-guards"
def test_lint_header_guards(lint, paths):
results = lint(paths("pragma_once.h"))
assert not results
results = lint(paths("ifndef.h"))
assert not results
results = lint(paths("ifnotdefined.h"))
assert not results
results = lint(paths("missing.h"))
assert len(results) == 1
assert "missing header guard" in results[0].message
if __name__ == "__main__":
mozunit.main()