report-xfstests.py: Read compressed results
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
parent
9bb097aae4
commit
ee6e9c3cf8
|
@ -46,7 +46,7 @@ class TestViewer(Gtk.Box):
|
||||||
def set_test_result(self, file):
|
def set_test_result(self, file):
|
||||||
current = self.stack.clear()
|
current = self.stack.clear()
|
||||||
self.viewer.clear()
|
self.viewer.clear()
|
||||||
if file and file.get_is_test_result():
|
if file and file.is_file():
|
||||||
results = testresults.TestResults(file.path)
|
results = testresults.TestResults(file.path)
|
||||||
self.stack.show_properties(results, current)
|
self.stack.show_properties(results, current)
|
||||||
self.viewer.show_results(results)
|
self.viewer.show_results(results)
|
||||||
|
|
|
@ -10,13 +10,14 @@ class Path(GObject.GObject):
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
GObject.GObject.__init__(self)
|
GObject.GObject.__init__(self)
|
||||||
self.path = path
|
self.path = path
|
||||||
|
self.is_file = self.path.is_file
|
||||||
|
|
||||||
def __lt__(self, rhs): return self.path < rhs.path
|
def __lt__(self, rhs): return self.path < rhs.path
|
||||||
def get_is_test_result(self):
|
def get_name(self):
|
||||||
return False not in [ f.is_file() for f in self.path.iterdir() ]
|
name = self.path.name
|
||||||
def get_name(self): return self.path.name
|
return name.split(".")[0] if self.is_file() else name
|
||||||
def get_model(self):
|
def get_model(self):
|
||||||
if not self.get_is_test_result():
|
if self.path.is_dir():
|
||||||
return DirectoryModel(self.path)
|
return DirectoryModel(self.path)
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ class DirectoryWindow(Gtk.ScrolledWindow):
|
||||||
expander = listitem.get_child()
|
expander = listitem.get_child()
|
||||||
expander.set_list_row(treerow)
|
expander.set_list_row(treerow)
|
||||||
expander.get_child().set_text(filepath.get_name())
|
expander.get_child().set_text(filepath.get_name())
|
||||||
listitem.set_selectable(filepath.get_is_test_result())
|
listitem.set_selectable(filepath.is_file())
|
||||||
|
|
||||||
def on_unbind(self, factory, listitem):
|
def on_unbind(self, factory, listitem):
|
||||||
expander = listitem.get_child()
|
expander = listitem.get_child()
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
import html
|
import html
|
||||||
|
import pathlib
|
||||||
|
import tarfile
|
||||||
import xml.etree.ElementTree
|
import xml.etree.ElementTree
|
||||||
|
|
||||||
class PassingTest:
|
class PassingTest:
|
||||||
|
@ -44,39 +46,43 @@ class TestCase(GObject.GObject):
|
||||||
|
|
||||||
|
|
||||||
class TestResults:
|
class TestResults:
|
||||||
def __init__(self, testdir):
|
def __init__(self, testtar):
|
||||||
self.versions = [ ]
|
self.versions = [ ]
|
||||||
self.tests = dict()
|
self.tests = dict()
|
||||||
self.properties = dict()
|
self.properties = dict()
|
||||||
self.skipped = set()
|
self.skipped = set()
|
||||||
|
|
||||||
for file in sorted(testdir.iterdir()):
|
with tarfile.open(testtar, "r:*") as tf:
|
||||||
self.versions.append(file.stem)
|
for member in [ m for m in tf.getmembers() if m.isfile() ]:
|
||||||
passed = 0
|
self.read_file(member.name, tf.extractfile(member))
|
||||||
|
self.versions.sort()
|
||||||
|
|
||||||
root = xml.etree.ElementTree.parse(file).getroot()
|
def read_file(self, name, file):
|
||||||
for prop in root.attrib.keys():
|
root = xml.etree.ElementTree.parse(file).getroot()
|
||||||
self.set_property(prop, file.stem, root.attrib[prop])
|
self.versions.append(pathlib.Path(name).stem)
|
||||||
|
passed = 0
|
||||||
|
|
||||||
for elm in root:
|
for prop in root.attrib.keys():
|
||||||
if elm.tag == "properties":
|
self.set_property(prop, root.attrib[prop])
|
||||||
for prop in elm:
|
|
||||||
self.set_property(prop.attrib["name"], file.stem,
|
|
||||||
prop.attrib["value"])
|
|
||||||
elif elm.tag == "testcase":
|
|
||||||
if len(elm) == 0:
|
|
||||||
result = PassingTest(elm)
|
|
||||||
passed += 1
|
|
||||||
elif elm[0].tag == "skipped":
|
|
||||||
result = SkippedTest(elm)
|
|
||||||
self.skipped.add(result.message)
|
|
||||||
elif elm[0].tag == "failure":
|
|
||||||
result = FailedTest(elm)
|
|
||||||
self.add_testcase(elm.attrib["name"], file.stem, result)
|
|
||||||
self.set_property("passed", file.stem, str(passed))
|
|
||||||
|
|
||||||
def set_property(self, name, vers, value):
|
for elm in root:
|
||||||
self.properties.setdefault(vers, dict())[name.upper()] = value
|
if elm.tag == "properties":
|
||||||
|
for prop in elm:
|
||||||
|
self.set_property(prop.attrib["name"], prop.attrib["value"])
|
||||||
|
elif elm.tag == "testcase":
|
||||||
|
if len(elm) == 0:
|
||||||
|
result = PassingTest(elm)
|
||||||
|
passed += 1
|
||||||
|
elif elm[0].tag == "skipped":
|
||||||
|
result = SkippedTest(elm)
|
||||||
|
self.skipped.add(result.message)
|
||||||
|
elif elm[0].tag == "failure":
|
||||||
|
result = FailedTest(elm)
|
||||||
|
self.add_testcase(elm.attrib["name"], result)
|
||||||
|
self.set_property("passed", str(passed))
|
||||||
|
|
||||||
def add_testcase(self, name, vers, result):
|
def set_property(self, name, value):
|
||||||
self.tests.setdefault(name, TestCase(name))[vers] = result
|
self.properties.setdefault(self.versions[-1], dict())[name.upper()] = value
|
||||||
|
|
||||||
|
def add_testcase(self, name, result):
|
||||||
|
self.tests.setdefault(name, TestCase(name))[self.versions[-1]] = result
|
||||||
|
|
Loading…
Reference in New Issue