]> granicus.if.org Git - clang/commitdiff
[analyzer] [tests] Update CmpRuns to write to stdout correctly in multithreaded envir...
authorGeorge Karpenkov <ekarpenkov@apple.com>
Tue, 13 Feb 2018 23:36:01 +0000 (23:36 +0000)
committerGeorge Karpenkov <ekarpenkov@apple.com>
Tue, 13 Feb 2018 23:36:01 +0000 (23:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325070 91177308-0d34-0410-b5e6-96231b3b80d8

utils/analyzer/CmpRuns.py
utils/analyzer/SATestBuild.py

index 8ffc872bd86286b0ef055174ad75cf0c05687e93..918e9a9f79b72b0944f412424f14c6031c9e367c 100755 (executable)
@@ -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, opts, deleteEmpty=True):
     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)
 
index 7ec87e4a27e90fa3a1b39c46e4355970323b4a1c..51e5f4e75f18f0ea4a1079e35eff16c5669f6a6e 100755 (executable)
@@ -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)