[cfe-commits] r139543 - /cfe/trunk/utils/analyzer/CmpRuns.py

Anna Zaks ganna at apple.com
Mon Sep 12 14:32:41 PDT 2011


Author: zaks
Date: Mon Sep 12 16:32:41 2011
New Revision: 139543

URL: http://llvm.org/viewvc/llvm-project?rev=139543&view=rev
Log:
[analyzer] CmpRuns.cmpScanBuildResults() should be easy to call from other modules.

Modified:
    cfe/trunk/utils/analyzer/CmpRuns.py

Modified: cfe/trunk/utils/analyzer/CmpRuns.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=139543&r1=139542&r2=139543&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/CmpRuns.py (original)
+++ cfe/trunk/utils/analyzer/CmpRuns.py Mon Sep 12 16:32:41 2011
@@ -44,6 +44,11 @@
     
 #
 
+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 @@
 
     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 @@
         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 @@
 
     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()





More information about the cfe-commits mailing list