Skip to content

Commit 0ad4f29

Browse files
[analyzer] SATest: Weaken assumption about HTML files
Instead of assuming there is an HTML file for each diagnostics, consider the HTML files only when they exist, individually of each other. After generating the reference data, running python /scripts/SATest.py build --projects simbody was resulting in this error: File "/scripts/CmpRuns.py", line 250, in read_single_file assert len(d['HTMLDiagnostics_files']) == 1 KeyError: 'HTMLDiagnostics_files' Reviewed By: steakhal Differential Revision: https://reviews.llvm.org/D126197
1 parent e15fef4 commit 0ad4f29

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

clang/utils/analyzer/CmpRuns.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,20 @@ def read_single_file(self, path: str, delete_empty: bool):
242242
return
243243

244244
# Extract the HTML reports, if they exists.
245-
if 'HTMLDiagnostics_files' in data['diagnostics'][0]:
246-
htmlFiles = []
247-
for d in data['diagnostics']:
245+
htmlFiles = []
246+
for d in data['diagnostics']:
247+
if 'HTMLDiagnostics_files' in d:
248248
# FIXME: Why is this named files, when does it have multiple
249249
# files?
250250
assert len(d['HTMLDiagnostics_files']) == 1
251251
htmlFiles.append(d.pop('HTMLDiagnostics_files')[0])
252-
else:
253-
htmlFiles = [None] * len(data['diagnostics'])
252+
else:
253+
htmlFiles.append(None)
254254

255255
report = AnalysisReport(self, data.pop('files'))
256+
# Python 3.10 offers zip(..., strict=True). The following assertion
257+
# mimics it.
258+
assert len(data['diagnostics']) == len(htmlFiles)
256259
diagnostics = [AnalysisDiagnostic(d, report, h)
257260
for d, h in zip(data.pop('diagnostics'), htmlFiles)]
258261

0 commit comments

Comments
 (0)