From f4871dad2245a48e2215b7b3987136f8b5399b6e Mon Sep 17 00:00:00 2001 From: dhurd Date: Fri, 6 Jul 2012 09:30:25 -0400 Subject: [PATCH 1/5] Updates regression.py Regression test now includes testing and rebuilding for a "golden report". Script cross-refrences generated .html report with the golden .html report /gold/[image name]/report.html --- Testing/script/regression.py | 84 +++++++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 7 deletions(-) diff --git a/Testing/script/regression.py b/Testing/script/regression.py index c8f5a55e61..7c7fc3308a 100644 --- a/Testing/script/regression.py +++ b/Testing/script/regression.py @@ -74,8 +74,9 @@ def testCompareToGold(inFile): name = imageName(inFile) cwd = wgetcwd() - goldFile = os.path.join(cwd,goldDir,name,"standard.db") - testFile = os.path.join(cwd,outDir,name,"AutopsyTestCase","autopsy.db") + + goldFile = os.path.join("./",goldDir,name,"standard.db") + testFile = os.path.join("./",outDir,name,"AutopsyTestCase","autopsy.db") if os.path.isfile(goldFile) == False: markError("No gold standard exists", inFile) return @@ -129,18 +130,84 @@ def testCompareToGold(inFile): else: print("Object counts match!") +def clearGoldDir(inFile): + cwd = wgetcwd() + if os.path.exists(os.path.join(cwd,goldDir,inFile)): + shutil.rmtree(os.path.join(cwd,goldDir,inFile)) + os.makedirs(os.path.join(cwd,goldDir,inFile)) + def copyTestToGold(inFile): print "------------------------------------------------" print "Recreating gold standard from results." inFile = imageName(inFile) cwd = wgetcwd() - goldFile = os.path.join(cwd,goldDir,inFile,"standard.db") - testFile = os.path.join(cwd,outDir,inFile,"AutopsyTestCase","autopsy.db") - if os.path.exists(os.path.join(cwd,goldDir,inFile)): - shutil.rmtree(os.path.join(cwd,goldDir,inFile)) - os.makedirs(os.path.join(cwd,goldDir,inFile)) + goldFile = os.path.join("./",goldDir,inFile,"standard.db") + testFile = os.path.join("./",outDir,inFile,"AutopsyTestCase","autopsy.db") shutil.copy(testFile, goldFile) +def copyReportToGold(inFile): + print "------------------------------------------------" + print "Recreating gold report from results." + inFile = imageName(inFile) + cwd = wgetcwd() + goldReport = os.path.join("./",goldDir,inFile,"report.html") + testReportPath = os.path.join("./",outDir,inFile,"AutopsyTestCase","Reports") + # Because Java adds a timestamp to the report file, one can't call it + # directly, so one must get a list of files in the dir, which are only + # reports, then filter for the .html report + for files in os.listdir(testReportPath): + if files.endswith(".html"): # Get the HTML one + testReport = os.path.join("./",outDir,inFile,"AutopsyTestCase","Reports",files) + shutil.copy(testReport, goldReport) + +def testCompareReports(inFile): + print "------------------------------------------------" + print "Comparing report to golden report." + + name = imageName(inFile) + goldReport = os.path.join("./",goldDir,name,"report.html") + testReportPath = os.path.join("./",outDir,name,"AutopsyTestCase","Reports") + # Because Java adds a timestamp to the report file, one can't call it + # directly, so one must get a list of files in the dir, which are only + # reports, then filter for the .html report + for files in os.listdir(testReportPath): + if files.endswith(".html"): # Get the HTML one + testReport = os.path.join("./",outDir,name,"AutopsyTestCase","Reports",files) + if os.path.isfile(goldReport) == False: + markError("No gold report exists", inFile) + return + if os.path.isfile(testReport) == False: + markError("No report exists", inFile) + return + # Compare the reports + goldFile = open(goldReport) + testFile = open(testReport) + # Search for