aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2011-09-12 21:32:41 +0000
committerAnna Zaks <ganna@apple.com>2011-09-12 21:32:41 +0000
commit544055fa4663298bd2361e9cdfc684934d81e42f (patch)
treed48e8d89b4867b94131ce957bdcf7ce3a3758bca
parent22d70e0ca33363e8630e4c692aa93c20d99db9da (diff)
[analyzer] CmpRuns.cmpScanBuildResults() should be easy to call from other modules.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139543 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-xutils/analyzer/CmpRuns.py50
1 files changed, 32 insertions, 18 deletions
diff --git a/utils/analyzer/CmpRuns.py b/utils/analyzer/CmpRuns.py
index 739d584773..d20cd6aa64 100755
--- a/utils/analyzer/CmpRuns.py
+++ b/utils/analyzer/CmpRuns.py
@@ -44,6 +44,11 @@ class multidict:
#
+class CmpOptions:
+ def __init__(self, verboseLog=None, root=""):
+ self.root = root
+ self.verboseLog = verboseLog
+
class AnalysisReport:
def __init__(self, run, files):
self.run = run
@@ -170,23 +175,7 @@ def compareResults(A, B):
return res
-def main():
- from optparse import OptionParser
- parser = OptionParser("usage: %prog [options] [dir A] [dir B]")
- parser.add_option("", "--root", dest="root",
- help="Prefix to ignore on source files",
- action="store", type=str, default="")
- parser.add_option("", "--verbose-log", dest="verboseLog",
- help="Write additional information to LOG [default=None]",
- action="store", type=str, default=None,
- metavar="LOG")
- (opts, args) = parser.parse_args()
-
- if len(args) != 2:
- parser.error("invalid number of arguments")
-
- dirA,dirB = args
-
+def cmpScanBuildResults(dirA, dirB, opts):
# Load the run results.
resultsA = loadResults(dirA, opts)
resultsB = loadResults(dirB, opts)
@@ -198,21 +187,25 @@ def main():
auxLog = None
diff = compareResults(resultsA, resultsB)
+ foundDiffs = False
for res in diff:
a,b,confidence = res
if a is None:
print "ADDED: %r" % b.getReadableName()
+ foundDiffs = True
if auxLog:
print >>auxLog, ("('ADDED', %r, %r)" % (b.getReadableName(),
b.getReportData()))
elif b is None:
print "REMOVED: %r" % a.getReadableName()
+ foundDiffs = True
if auxLog:
print >>auxLog, ("('REMOVED', %r, %r)" % (a.getReadableName(),
a.getReportData()))
elif confidence:
print "CHANGED: %r to %r" % (a.getReadableName(),
b.getReadableName())
+ foundDiffs = True
if auxLog:
print >>auxLog, ("('CHANGED', %r, %r, %r, %r)"
% (a.getReadableName(),
@@ -224,7 +217,28 @@ def main():
print "TOTAL REPORTS: %r" % len(resultsB.diagnostics)
if auxLog:
- print >>auxLog, "('TOTAL', %r)" % len(resultsB.diagnostics)
+ print >>auxLog, "('TOTAL REPORTS', %r)" % len(resultsB.diagnostics)
+
+ return foundDiffs
+
+def main():
+ from optparse import OptionParser
+ parser = OptionParser("usage: %prog [options] [dir A] [dir B]")
+ parser.add_option("", "--root", dest="root",
+ help="Prefix to ignore on source files",
+ action="store", type=str, default="")
+ parser.add_option("", "--verbose-log", dest="verboseLog",
+ help="Write additional information to LOG [default=None]",
+ action="store", type=str, default=None,
+ metavar="LOG")
+ (opts, args) = parser.parse_args()
+
+ if len(args) != 2:
+ parser.error("invalid number of arguments")
+
+ dirA,dirB = args
+
+ cmpScanBuildResults(dirA, dirB, opts)
if __name__ == '__main__':
main()