[cfe-commits] r144141 - /cfe/trunk/utils/analyzer/SATestAdd.py

Anna Zaks ganna at apple.com
Tue Nov 8 14:41:22 PST 2011


Author: zaks
Date: Tue Nov  8 16:41:22 2011
New Revision: 144141

URL: http://llvm.org/viewvc/llvm-project?rev=144141&view=rev
Log:
[analyzer] Testing: support for regenerate reference output

Change the flow of the SATestAdd so that it could be used for regenerating
the reference output without exiting with an error.

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

Modified: cfe/trunk/utils/analyzer/SATestAdd.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestAdd.py?rev=144141&r1=144140&r2=144141&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/SATestAdd.py (original)
+++ cfe/trunk/utils/analyzer/SATestAdd.py Tue Nov  8 16:41:22 2011
@@ -22,6 +22,13 @@
 import csv
 import sys
 
+def isExistingProject(PMapFile, projectID) :
+    PMapReader = csv.reader(PMapFile)
+    for I in PMapReader:
+        if projectID == I[0]:
+            return True
+    return False    
+
 # Add a new project for testing: build it and add to the Project Map file.
 # Params:
 #   Dir is the directory where the sources are.
@@ -44,20 +51,16 @@
         print "Warning: Creating the Project Map file!!"
         PMapFile = open(ProjectMapPath, "w+b")
     try:
-        PMapReader = csv.reader(PMapFile)
-        for I in PMapReader:
-            IID = I[0]
-            if ID == IID:
-                print >> sys.stderr, 'Warning: Project with ID \'', ID, \
-                        '\' already exists.'
-                sys.exit(-1)
-
-        PMapWriter = csv.writer(PMapFile)
-        PMapWriter.writerow( (ID, int(IsScanBuild)) );
+        if (isExistingProject(PMapFile, ID)) :        
+            print >> sys.stdout, 'Warning: Project with ID \'', ID, \
+                                 '\' already exists.'
+            print >> sys.stdout, "Reference output has been regenerated."
+        else:                     
+            PMapWriter = csv.writer(PMapFile)
+            PMapWriter.writerow( (ID, int(IsScanBuild)) );
+            print "The project map is updated: ", ProjectMapPath
     finally:
         PMapFile.close()
-        
-    print "The project map is updated: ", ProjectMapPath
             
 
 # TODO: Add an option not to build. 





More information about the cfe-commits mailing list