aboutsummaryrefslogtreecommitdiff
path: root/utils/analyzer/CmpRuns.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils/analyzer/CmpRuns.py')
-rwxr-xr-xutils/analyzer/CmpRuns.py97
1 files changed, 51 insertions, 46 deletions
diff --git a/utils/analyzer/CmpRuns.py b/utils/analyzer/CmpRuns.py
index bca02124ee..30157bed3d 100755
--- a/utils/analyzer/CmpRuns.py
+++ b/utils/analyzer/CmpRuns.py
@@ -138,6 +138,46 @@ class AnalysisRun:
def getClangVersion(self):
return self.clang_version
+ def readSingleFile(self, p, deleteEmpty):
+ data = plistlib.readPlist(p)
+
+ # We want to retrieve the clang version even if there are no
+ # reports. Assume that all reports were created using the same
+ # clang version (this is always true and is more efficient).
+ if 'clang_version' in data:
+ if self.clang_version == None:
+ self.clang_version = data.pop('clang_version')
+ else:
+ data.pop('clang_version')
+
+ # Ignore/delete empty reports.
+ if not data['files']:
+ if deleteEmpty == True:
+ os.remove(p)
+ return
+
+ # Extract the HTML reports, if they exists.
+ if 'HTMLDiagnostics_files' in data['diagnostics'][0]:
+ htmlFiles = []
+ for d in data['diagnostics']:
+ # FIXME: Why is this named files, when does it have multiple
+ # files?
+ assert len(d['HTMLDiagnostics_files']) == 1
+ htmlFiles.append(d.pop('HTMLDiagnostics_files')[0])
+ else:
+ htmlFiles = [None] * len(data['diagnostics'])
+
+ report = AnalysisReport(self, data.pop('files'))
+ diagnostics = [AnalysisDiagnostic(d, report, h)
+ for d,h in zip(data.pop('diagnostics'),
+ htmlFiles)]
+
+ assert not data
+
+ report.diagnostics.extend(diagnostics)
+ self.reports.append(report)
+ self.diagnostics.extend(diagnostics)
+
# Backward compatibility API.
def loadResults(path, opts, root = "", deleteEmpty=True):
@@ -150,52 +190,17 @@ def loadResults(path, opts, root = "", deleteEmpty=True):
def loadResultsFromSingleRun(info, deleteEmpty=True):
path = info.path
run = AnalysisRun(info)
-
- for (dirpath, dirnames, filenames) in os.walk(path):
- for f in filenames:
- if (not f.endswith('plist')):
- continue
-
- p = os.path.join(dirpath, f)
- data = plistlib.readPlist(p)
-
- # We want to retrieve the clang version even if there are no
- # reports. Assume that all reports were created using the same
- # clang version (this is always true and is more efficient).
- if ('clang_version' in data) :
- if (run.clang_version == None) :
- run.clang_version = data.pop('clang_version')
- else:
- data.pop('clang_version')
-
- # Ignore/delete empty reports.
- if not data['files']:
- if deleteEmpty == True:
- os.remove(p)
- continue
-
- # Extract the HTML reports, if they exists.
- if 'HTMLDiagnostics_files' in data['diagnostics'][0]:
- htmlFiles = []
- for d in data['diagnostics']:
- # FIXME: Why is this named files, when does it have multiple
- # files?
- assert len(d['HTMLDiagnostics_files']) == 1
- htmlFiles.append(d.pop('HTMLDiagnostics_files')[0])
- else:
- htmlFiles = [None] * len(data['diagnostics'])
-
- report = AnalysisReport(run, data.pop('files'))
- diagnostics = [AnalysisDiagnostic(d, report, h)
- for d,h in zip(data.pop('diagnostics'),
- htmlFiles)]
-
- assert not data
-
- report.diagnostics.extend(diagnostics)
- run.reports.append(report)
- run.diagnostics.extend(diagnostics)
-
+
+ if os.path.isfile(path):
+ run.readSingleFile(path, deleteEmpty)
+ else:
+ for (dirpath, dirnames, filenames) in os.walk(path):
+ for f in filenames:
+ if (not f.endswith('plist')):
+ continue
+ p = os.path.join(dirpath, f)
+ run.readSingleFile(p, deleteEmpty)
+
return run
def cmpAnalysisDiagnostic(d) :