mirror of https://github.com/tc39/test262.git
Support excluding harness files from the unused includes check
This commit is contained in:
parent
6ec99623c2
commit
3468e6aa77
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue