diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0d5a0d5cd79b2130b9e66f931e6da37e8b6aaf0a..a90913262ecba73f1ad382904ca1aaf80d1ab9e2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -38,3 +38,4 @@ if (CAMPVIS_GROUP_SOURCE_FILES) DEFINE_SOURCE_GROUPS_FROM_SUBDIR(TestCampvisSources ${CampvisHome}/test "") DEFINE_SOURCE_GROUPS_FROM_SUBDIR(TestCampvisHeaders ${CampvisHome}/test "") ENDIF() + diff --git a/test/main.cpp b/test/main.cpp index f9f28561d755ca71c052c983b09582593351c03c..897169a9541411d01ab771cf2e69112eeaefa795 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -142,7 +142,10 @@ GTEST_API_ int main(int argc, char **argv) { app = new QApplication(argc, argv); - testing::InitGoogleTest(&argc, argv); + //testing::InitGoogleTest(&argc, argv); + int _argc = 2; + char *options[] = {"THIS DOESN'T HAVE ANY EFFECT", "--gtest_output=xml:visregtests/result.xml"}; + testing::InitGoogleTest(&_argc, options); int ret; diff --git a/test/visregtests/result.xml b/test/visregtests/result.xml new file mode 100644 index 0000000000000000000000000000000000000000..c6a10c6aff77961f4e79ffca48b64b367e15d15b --- /dev/null +++ b/test/visregtests/result.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ..\src\test\core\properties\stringpropertytest.cpp:74 +Value of: this->_strProp1.getValue() + Actual: "anotherValue2" +Expected: "anotherValue" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<![CDATA[MESSAGE]]> \ No newline at end of file diff --git a/test/visregtests/script.py b/test/visregtests/script.py index cf015c20ccc48dabf2bf415690aabe0b640711ae..9eba391a78d0786764d509a1e4132e2f2ed9401e 100644 --- a/test/visregtests/script.py +++ b/test/visregtests/script.py @@ -1,3 +1,4 @@ +import os.path # ================================================================================================ # # This file is part of the CAMPVis Software Framework. @@ -25,14 +26,25 @@ __author__="Mahmud" __date__ ="$Jul 10, 2014 1:58:04 AM$" -import numpy as np -import matplotlib -import matplotlib.pyplot as plt -import matplotlib.image as mpimg +# import numpy as np +# import matplotlib +# import matplotlib.pyplot as plt +# import matplotlib.image as mpimg import os -from skimage import data, img_as_float, io -from skimage.measure import structural_similarity as ssim +from skimage import io#, img_as_float, data +#from skimage.measure import structural_similarity as ssim +import xml.etree.ElementTree as et +import numpy as np + +from xml.etree import ElementTree +from xml.dom import minidom + +# Return a pretty-printed XML string for the Element +def prettify(elem): + rough_string = ElementTree.tostring(elem, 'utf-8') + reparsed = minidom.parseString(rough_string) + return reparsed.toprettyxml(indent=" ") refDir = 'reference/'; testDir = 'testruns/'; @@ -47,15 +59,27 @@ prevResDirs = os.listdir(resultDir); # Create a new directory to store result curRun = 0; for i in range(len(prevResDirs)) : - prevRunDirs[i] = int(prevRunDirs[i][4:]) - prevResDirs[i] = int(prevResDirs[i][4:]) + prevRunDirs[i] = int(prevRunDirs[i][0:]) + prevResDirs[i] = int(prevResDirs[i][0:]) if (prevRunDirs[i] == prevResDirs[i]) : curRun += 1; continue; break; +# List the test runs that are not computed yet newTestDirs = prevRunDirs[curRun:]; +# Find or create results.xml file created by test-campvis +xmlFile = "result.xml"; +if (os.path.isfile(xmlFile)) : + tree = et.parse(xmlFile); + root = tree.getroot(); +else : + root = et.Element("testsuites", {"tests":"0", "failures":"0", "disabled":"0", + "errors":"0", "timestamp":"2014-08-24T01:35:42", "time":"0", "name":"AllTests"}); + tree = et.ElementTree(root); + + for test in newTestDirs : curTestDir = testDir + str(prevRunDirs[curRun]) + "/"; resultSaveDir = resultDir + str(prevRunDirs[curRun]) + "/"; @@ -72,6 +96,11 @@ for test in newTestDirs : os.mkdir(resCaseDir) files = os.listdir(refCaseDir) + if (len(files) != 0) : + suite = et.SubElement(root, "testsuite", {"name":refCaseDir, "tests":"0", + "failures":"0", "disabled":"0", "errors":"0", "time":"0"}); + + i = 0; for file in files : refFilePath = refCaseDir + file; testFilePath = testCaseDir + file; @@ -80,7 +109,8 @@ for test in newTestDirs : if (not os.path.isfile(testFilePath)) : continue; - if (refFilePath[-4:] != ".jpg" and refFilePath[-4:] != ".png" and refFilePath[-4:] != ".tif") : + if (refFilePath[-4:] != ".jpg" and refFilePath[-4:] != ".png" + and refFilePath[-4:] != ".tif") : continue; ref = io.imread(refFilePath); @@ -99,5 +129,23 @@ for test in newTestDirs : #plt.tight_layout() #plt.show() + case = et.SubElement(suite, "tastcase", {"name":file, "status":"run", + "time":"0", "classname":refCaseDir}); + suite.set("tests", str(int(suite.get("tests"))+1)); + root.set("tests", str(int(root.get("tests"))+1)); + + + if (np.sum(test) != 0) :# + failure = et.SubElement(case, "failure", {"message":"", "type":""}); + failure.set("message", "Image difference is not 0"); + failure.text = ""; + + suite.set("failures", str(int(suite.get("failures")) + 1)); + root.set("failures", str(int(root.get("failures")) + 1)); + +tree.write(xmlFile); + print ""