From: Anna Zaks Date: Tue, 8 Nov 2011 22:41:22 +0000 (+0000) Subject: [analyzer] Testing: support for regenerate reference output X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=86f14abc027676513aa7590fc254d22f279543d7;p=clang [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144141 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/analyzer/SATestAdd.py b/utils/analyzer/SATestAdd.py index ea3ec21d64..ce64bc82f7 100755 --- a/utils/analyzer/SATestAdd.py +++ b/utils/analyzer/SATestAdd.py @@ -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.