diff --git a/tools/lint/lib/checks/includes.py b/tools/lint/lib/checks/includes.py index 5ec38b5ce8..7c92d814ef 100644 --- a/tools/lint/lib/checks/includes.py +++ b/tools/lint/lib/checks/includes.py @@ -22,10 +22,14 @@ class CheckIncludes(Check): 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) @@ -57,6 +61,9 @@ class CheckIncludes(Check): 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