[cfe-commits] r149682 - /cfe/trunk/utils/analyzer/SATestBuild.py
Anna Zaks
ganna at apple.com
Thu Feb 2 22:35:23 PST 2012
Author: zaks
Date: Fri Feb 3 00:35:23 2012
New Revision: 149682
URL: http://llvm.org/viewvc/llvm-project?rev=149682&view=rev
Log:
[analyzer] Testing: add automated reference results reset.
Modified:
cfe/trunk/utils/analyzer/SATestBuild.py
Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=149682&r1=149681&r2=149682&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Fri Feb 3 00:35:23 2012
@@ -368,10 +368,36 @@
print "Diagnostic comparison complete (time: %.2f)." % (time.time()-TBegin)
return (NumDiffs > 0)
-def testProject(ID, InIsReferenceBuild, IsScanBuild , Dir=None):
- global IsReferenceBuild
- IsReferenceBuild = InIsReferenceBuild
+def updateSVN(Mode, ProjectsMap):
+ try:
+ ProjectsMap.seek(0)
+ for I in csv.reader(ProjectsMap):
+ ProjName = I[0]
+ Path = os.path.join(ProjName, getSBOutputDirName())
+
+ if Mode == "delete":
+ Command = "svn delete %s" % (Path,)
+ else:
+ Command = "svn add %s" % (Path,)
+ if Verbose == 1:
+ print " Executing: %s" % (Command,)
+ check_call(Command, shell=True)
+
+ if Mode == "delete":
+ CommitCommand = "svn commit -m \"[analyzer tests] Remove " \
+ "reference results.\""
+ else:
+ CommitCommand = "svn commit -m \"[analyzer tests] Add new " \
+ "reference results.\""
+ if Verbose == 1:
+ print " Executing: %s" % (CommitCommand,)
+ check_call(CommitCommand, shell=True)
+ except:
+ print "Error: SVN update failed."
+ sys.exit(-1)
+
+def testProject(ID, IsScanBuild, Dir=None):
print " \n\n--- Building project %s" % (ID,)
TBegin = time.time()
@@ -382,8 +408,9 @@
print " Build directory: %s." % (Dir,)
# Set the build results directory.
- SBOutputDir = os.path.join(Dir, getSBOutputDirName())
-
+ RelOutputDir = getSBOutputDirName()
+ SBOutputDir = os.path.join(Dir, RelOutputDir)
+
buildProject(Dir, SBOutputDir, IsScanBuild)
checkBuild(SBOutputDir)
@@ -394,19 +421,36 @@
print "Completed tests for project %s (time: %.2f)." % \
(ID, (time.time()-TBegin))
-def testAll(InIsReferenceBuild = False):
-
+def testAll(InIsReferenceBuild = False, UpdateSVN = False):
+ global IsReferenceBuild
+ IsReferenceBuild = InIsReferenceBuild
+
PMapFile = open(getProjectMapPath(), "rb")
- try:
- PMapReader = csv.reader(PMapFile)
- for I in PMapReader:
+ try:
+ # Validate the input.
+ for I in csv.reader(PMapFile):
if (len(I) != 2) :
print "Error: Rows in the ProjectMapFile should have 3 entries."
raise Exception()
if (not ((I[1] == "1") | (I[1] == "0"))):
print "Error: Second entry in the ProjectMapFile should be 0 or 1."
raise Exception()
- testProject(I[0], InIsReferenceBuild, int(I[1]))
+
+ # When we are regenerating the reference results, we might need to
+ # update svn. Remove reference results from SVN.
+ if UpdateSVN == True:
+ assert(InIsReferenceBuild == True);
+ updateSVN("delete", PMapFile);
+
+ # Test the projects.
+ PMapFile.seek(0)
+ for I in csv.reader(PMapFile):
+ testProject(I[0], int(I[1]))
+
+ # Add reference results to SVN.
+ if UpdateSVN == True:
+ updateSVN("add", PMapFile);
+
except:
print "Error occurred. Premature termination."
raise
@@ -414,4 +458,18 @@
PMapFile.close()
if __name__ == '__main__':
- testAll()
+ IsReference = False
+ UpdateSVN = False
+ if len(sys.argv) >= 2:
+ if sys.argv[1] == "-r":
+ IsReference = True
+ elif sys.argv[1] == "-rs":
+ IsReference = True
+ UpdateSVN = True
+ else:
+ print >> sys.stderr, 'Usage: ', sys.argv[0],\
+ '[-r|-rs]' \
+ 'Use -r to regenerate reference output' \
+ 'Use -rs to regenerate reference output and update svn'
+
+ testAll(IsReference, UpdateSVN)
More information about the cfe-commits
mailing list