r325070 - [analyzer] [tests] Update CmpRuns to write to stdout correctly in multithreaded environment

George Karpenkov via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 13 15:36:01 PST 2018


Author: george.karpenkov
Date: Tue Feb 13 15:36:01 2018
New Revision: 325070

URL: http://llvm.org/viewvc/llvm-project?rev=325070&view=rev
Log:
[analyzer] [tests] Update CmpRuns to write to stdout correctly in multithreaded environment

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

Modified: cfe/trunk/utils/analyzer/CmpRuns.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=325070&r1=325069&r2=325070&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/CmpRuns.py (original)
+++ cfe/trunk/utils/analyzer/CmpRuns.py Tue Feb 13 15:36:01 2018
@@ -26,6 +26,7 @@ Usage:
 
 """
 
+import sys
 import os
 import plistlib
 from math import log
@@ -264,7 +265,8 @@ def compareResults(A, B, opts):
     return res
 
 
-def dumpScanBuildResultsDiff(dirA, dirB, opts, deleteEmpty=True):
+def dumpScanBuildResultsDiff(dirA, dirB, opts, deleteEmpty=True,
+                             Stdout=sys.stdout):
     # Load the run results.
     resultsA = loadResults(dirA, opts, opts.rootA, deleteEmpty)
     resultsB = loadResults(dirB, opts, opts.rootB, deleteEmpty)
@@ -282,30 +284,30 @@ def dumpScanBuildResultsDiff(dirA, dirB,
     for res in diff:
         a, b = res
         if a is None:
-            print "ADDED: %r" % b.getReadableName()
+            Stdout.write("ADDED: %r\n" % b.getReadableName())
             foundDiffs += 1
             totalAdded += 1
             if auxLog:
-                print >>auxLog, ("('ADDED', %r, %r)" % (b.getReadableName(),
-                                                        b.getReport()))
+                auxLog.write("('ADDED', %r, %r)\n" % (b.getReadableName(),
+                                                      b.getReport()))
         elif b is None:
-            print "REMOVED: %r" % a.getReadableName()
+            Stdout.write("REMOVED: %r\n" % a.getReadableName())
             foundDiffs += 1
             totalRemoved += 1
             if auxLog:
-                print >>auxLog, ("('REMOVED', %r, %r)" % (a.getReadableName(),
-                                                          a.getReport()))
+                auxLog.write("('REMOVED', %r, %r)\n" % (a.getReadableName(),
+                                                        a.getReport()))
         else:
             pass
 
     TotalReports = len(resultsB.diagnostics)
-    print "TOTAL REPORTS: %r" % TotalReports
-    print "TOTAL DIFFERENCES: %r" % foundDiffs
-    print "TOTAL ADDED: %r" % totalAdded
-    print "TOTAL REMOVED: %r" % totalRemoved
+    Stdout.write("TOTAL REPORTS: %r\n" % TotalReports)
+    Stdout.write("TOTAL ADDED: %r\n" % totalAdded)
+    Stdout.write("TOTAL REMOVED: %r\n" % totalRemoved)
     if auxLog:
-        print >>auxLog, "('TOTAL NEW REPORTS', %r)" % TotalReports
-        print >>auxLog, "('TOTAL DIFFERENCES', %r)" % foundDiffs
+        auxLog.write("('TOTAL NEW REPORTS', %r)\n" % TotalReports)
+        auxLog.write("('TOTAL DIFFERENCES', %r)\n" % foundDiffs)
+        auxLog.close()
 
     return foundDiffs, len(resultsA.diagnostics), len(resultsB.diagnostics)
 

Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=325070&r1=325069&r2=325070&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Tue Feb 13 15:36:01 2018
@@ -570,7 +570,9 @@ def runCmpResults(Dir, Strictness=0):
             ["--rootA", "", "--rootB", PatchedSourceDirPath])
         # Scan the results, delete empty plist files.
         NumDiffs, ReportsInRef, ReportsInNew = \
-            CmpRuns.dumpScanBuildResultsDiff(RefDir, NewDir, Opts, False)
+            CmpRuns.dumpScanBuildResultsDiff(RefDir, NewDir, Opts,
+                                             deleteEmpty=False,
+                                             Stdout=Local.stdout)
         if (NumDiffs > 0):
             Local.stdout.write("Warning: %s differences in diagnostics.\n"
                                % NumDiffs)




More information about the cfe-commits mailing list