Skip to content

Commit

Permalink
Support excluding harness files from the unused includes check
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Nov 13, 2024
1 parent 8751847 commit 0a24b28
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/lint/lib/checks/includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ def _load(include_name):
with open(os.path.join('harness', include_name), 'r') as f:
source = f.read()

parsed = parse(source)
if not parsed:
raise Exception(f"Failed to parse {include_name}")
CheckIncludes._cache[include_name] = {
'name': include_name,
'source': CheckIncludes._remove_frontmatter(source),
'defines': parse(source)['defines']
'defines': parsed['defines'],
'allow_unused': parsed.get('allow_unused', False),
}

return CheckIncludes._cache.get(include_name)
Expand Down Expand Up @@ -57,6 +61,9 @@ def run(self, name, meta, source):
without_frontmatter = self._remove_frontmatter(source)

for harness_file in harness_files:
if harness_file['allow_unused']:
continue

if self._has_reference(without_frontmatter, harness_file['defines']):
continue

Expand Down

0 comments on commit 0a24b28

Please sign in to comment.