diff --git a/Testing/script/regression.py b/Testing/script/regression.py index 35ed5e2739..c29cff73dd 100644 --- a/Testing/script/regression.py +++ b/Testing/script/regression.py @@ -130,6 +130,12 @@ 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." @@ -137,11 +143,70 @@ def copyTestToGold(inFile): cwd = wgetcwd() goldFile = os.path.join("./",goldDir,inFile,"standard.db") testFile = os.path.join("./",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)) 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 + testReport = None + 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 testReport is None: + markError("No test report exists", inFile) + return + # Compare the reports + goldFile = open(goldReport) + testFile = open(testReport) + # Search for