]> granicus.if.org Git - clang/commitdiff
[analyzer] Testing: support for regenerate reference output
authorAnna Zaks <ganna@apple.com>
Tue, 8 Nov 2011 22:41:22 +0000 (22:41 +0000)
committerAnna Zaks <ganna@apple.com>
Tue, 8 Nov 2011 22:41:22 +0000 (22:41 +0000)
Change the flow of the SATestAdd so that it could be used for regenerating
the reference output without exiting with an error.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144141 91177308-0d34-0410-b5e6-96231b3b80d8

utils/analyzer/SATestAdd.py

index ea3ec21d642cd1cf8657cbc9aad397415d7f84b1..ce64bc82f756fdd4bbd5e8b6904dfaacc8fc18a6 100755 (executable)
@@ -22,6 +22,13 @@ import os
 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 @@ def addNewProject(ID, IsScanBuild) :
         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.