From: heister Date: Thu, 26 Sep 2013 14:49:46 +0000 (+0000) Subject: first version of parsing scripts X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42880474c4dd7475ff8d429b55b125b0b94225f5;p=dealii-svn.git first version of parsing scripts git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@30955 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/scripts/makereport.py b/tests/scripts/makereport.py new file mode 100644 index 0000000000..75ac4e3cbe --- /dev/null +++ b/tests/scripts/makereport.py @@ -0,0 +1,60 @@ +import xml.etree.ElementTree as ET +import glob +import sys +from datetime import datetime +import subprocess + +class Group: + def __init__(self, name): + self.name = name + self.n_tests = 0 + self.n_fail = 0 + self.fail = [] + self.fail_text = {} + +class Revision: + def __init__(self): + self.groups = {} + self.number = -1 + self.name = '' + self.n_tests = 0 + self.n_fail = 0 + + + +if len(sys.argv)==2: + dirname=sys.argv[1].replace('/','') +else: + n=glob.glob("*/Notes.xml") + n.sort(reverse=True) + dirname = n[0].replace('/Notes.xml','') + + tree = ET.parse(dirname+'/Notes.xml') + name = tree.getroot().attrib['BuildName'] + number = name.split('-')[-1] + date = datetime.strptime(dirname,"%Y%m%d-%H%M") + + print "Revision: %s"%number[1:] + print "Date: %s"%(date.strftime("%Y %j %F %U-%w")) + #print "Id: %s"%name + id = subprocess.check_output(["id","-un"])+'@'+subprocess.check_output(["hostname"]) + id=id.replace('\n','') + print "Id: %s"%id + + #now Test.xml: + tree = ET.parse(dirname+'/Test.xml') + root = tree.getroot() + testing = root.find('Testing') + + for test in testing.findall("Test"): + status = test.attrib['Status'] + fail=False + if status=="failed": fail=True + name = test.find('Name').text + + if fail: + print "%s 3 %s"%(date,name) + else: + print "%s + %s"%(date,name) + + diff --git a/tests/scripts/parse.py b/tests/scripts/parse.py new file mode 100644 index 0000000000..0ca7f9aef4 --- /dev/null +++ b/tests/scripts/parse.py @@ -0,0 +1,180 @@ +import xml.etree.ElementTree as ET +import glob + +class Group: + def __init__(self, name): + self.name = name + self.n_tests = 0 + self.n_fail = 0 + self.fail = [] + self.fail_text = {} + +class Revision: + def __init__(self): + self.groups = {} + self.number = -1 + self.name = '' + self.n_tests = 0 + self.n_fail = 0 + +def parse_revision(dirname): + rev = Revision() + #first Notes.xml: + tree = ET.parse(dirname+'/Notes.xml') + rev.name = tree.getroot().attrib['BuildName'] + rev.number = rev.name.split('-')[-1] + + print dirname, "BUILD: ", rev.name + + #now Test.xml: + tree = ET.parse(dirname+'/Test.xml') + root = tree.getroot() + testing = root.find('Testing') + + for test in testing.findall("Test"): + status = test.attrib['Status'] + fail=False + if status=="failed": fail=True + name = test.find('Name').text + group = name.split('/')[0] + + if not group in rev.groups: + rev.groups[group]= Group(group) + + rev.groups[group].n_tests += 1 + rev.n_tests += 1 + if fail: + rev.groups[group].n_fail += 1 + rev.n_fail += 1 + rev.groups[group].fail.append(name) + failtext = test.find('Results').find('Measurement').find('Value').text.encode('utf-8') + failtext = failtext.replace('"','').split('\n') + failtext = '\n'.join(failtext[4:min(20,len(failtext))]) + rev.groups[group].fail_text[name]=failtext + + for g in sorted(rev.groups): + g = rev.groups[g] + #print g.name, g.n_tests, g.n_fail, g.fail + + return rev + + + + +#from xml.dom import minidom + + +n=glob.glob("*/Notes.xml") +n.sort(reverse=True) +n = n[0:min(10,len(n))] + +revs = [] + +allgroups = set() + +for f in n: + dirname = f.replace('/Notes.xml','') + rev = parse_revision(dirname) + revs.append(rev) + + for gr in rev.groups: + allgroups.add(gr) + +revs.sort(key=lambda x: x.number, reverse=True) + +allgroups = sorted(allgroups) + +f = open('tests.html', 'w') +f.write('') +f.write("""""") +f.write(""" +""") +f.write('') + +f.write('') +f.write('') + +for rev in revs: + f.write('') +f.write('\n') + +f.write('') +f.write('') +for rev in revs: + if (rev.n_fail>0): + f.write('') + else: + f.write('') +f.write('\n') + + +for group in allgroups: + f.write('') + + failing = set() + for rev in revs: + if group in rev.groups: + failing |= set(rev.groups[group].fail) + failing = sorted(failing) + + if (len(failing)>0): + f.write(''%(group,group)) + else: + f.write('') + + for rev in revs: + if group not in rev.groups: + f.write('') + else: + gr = rev.groups[group] + if (gr.n_fail>0): + f.write('') + else: + f.write('') + + f.write('\n') + + + #failing tests in group: + if len(failing)>0: + f.write(''%group) + for fail in failing: + f.write('') + name = fail[len(group):] # cut off group name + f.write('') + for rev in revs: + if group in rev.groups and fail in rev.groups[group].fail: + f.write(''%rev.groups[group].fail_text[fail]) + else: + f.write('') + + f.write('\n') + f.write('\n') + + f.write('\n\n') + + +f.write('
 '+rev.number+'
ALL' + str(rev.n_fail) + ' / ' + str(rev.n_tests) + '' + str(rev.n_fail) + ' / ' + str(rev.n_tests) + '
%s' + group + '-' + str(gr.n_fail) + ' / ' + str(gr.n_tests) + '' + str(gr.n_fail) + ' / ' + str(gr.n_tests) + '
') + + +f.write('') + +