import xml.etree.ElementTree as ET
import glob
+
class Group:
def __init__(self, name):
self.name = name
self.fail = []
self.fail_text = {}
self.fail_status = {}
- self.n_status = [0,0,0,0,0]
+ self.n_status = [0, 0, 0, 0, 0]
+
class Revision:
def __init__(self):
self.groups = {}
self.number = -1
- self.name = ''
+ self.name = ""
self.n_tests = 0
self.n_fail = 0
+
def parse_revision(dirname):
rev = Revision()
- if len(glob.glob(dirname+'/Update.xml'))>0:
- #new format
- tree = ET.parse(dirname+'/Update.xml')
- rev.name = tree.getroot().find('BuildName').text
- rev.number = tree.getroot().find('Revision').text
- elif len(glob.glob(dirname+'/Notes.xml'))>0:
- #old format
- tree = ET.parse(dirname+'/Notes.xml')
- rev.name = tree.getroot().attrib['BuildName']
- number = rev.name.split('-')[-1]
+ if len(glob.glob(dirname + "/Update.xml")) > 0:
+ # new format
+ tree = ET.parse(dirname + "/Update.xml")
+ rev.name = tree.getroot().find("BuildName").text
+ rev.number = tree.getroot().find("Revision").text
+ elif len(glob.glob(dirname + "/Notes.xml")) > 0:
+ # old format
+ tree = ET.parse(dirname + "/Notes.xml")
+ rev.name = tree.getroot().attrib["BuildName"]
+ number = rev.name.split("-")[-1]
rev.number = number[1:]
else:
return None
- print dirname, "BUILD: ", rev.name
+ print(dirname, "BUILD: ", rev.name)
- #now Test.xml:
- tree = ET.parse(dirname+'/Test.xml')
+ # now Test.xml:
+ tree = ET.parse(dirname + "/Test.xml")
root = tree.getroot()
- testing = root.find('Testing')
+ testing = root.find("Testing")
for test in testing.findall("Test"):
- fail=False
- if test.attrib['Status']=="failed":
- fail=True
- name = test.find('Name').text
- group = name.split('/')[0]
+ fail = False
+ if test.attrib["Status"] == "failed":
+ fail = True
+ name = test.find("Name").text
+ group = name.split("/")[0]
status = 4
if fail:
- text = test.find('Results').find('Measurement').find('Value').text
+ text = test.find("Results").find("Measurement").find("Value").text
if text is None:
- text=""
- failtext = text.encode('utf-8')
- failtextlines = failtext.replace('"','').split('\n')
- failstatustxt = failtextlines[0].split(' ')[-1]
- for i in range(0,len(failtextlines)):
+ text = ""
+ failtext = text.encode("utf-8")
+ failtextlines = failtext.replace('"', "").split("\n")
+ failstatustxt = failtextlines[0].split(" ")[-1]
+ for i in range(0, len(failtextlines)):
failtextlines[i] = failtextlines[i][0:80]
- if failtextlines[i].startswith('FAILED: '):
- failtextlines[i]='FAILED: ...'
- failtext = '\n'.join(failtextlines[4:min(25,len(failtext))])
- statuslist=['CONFIGURE','BUILD','RUN','DIFF']
+ if failtextlines[i].startswith("FAILED: "):
+ failtextlines[i] = "FAILED: ..."
+ failtext = "\n".join(failtextlines[4 : min(25, len(failtext))])
+ statuslist = ["CONFIGURE", "BUILD", "RUN", "DIFF"]
if failstatustxt in statuslist:
status = statuslist.index(failstatustxt)
else:
- print "unknown status '%s' in test %s "% (failstatustxt,name)
- status=0
+ print("unknown status '%s' in test %s " % (failstatustxt, name))
+ status = 0
if not group in rev.groups:
- rev.groups[group]= Group(group)
+ rev.groups[group] = Group(group)
rev.groups[group].n_tests += 1
rev.n_tests += 1
rev.groups[group].n_fail += 1
rev.n_fail += 1
rev.groups[group].fail.append(name)
- rev.groups[group].fail_text[name]=failtext
- rev.groups[group].fail_status[name]=status
+ rev.groups[group].fail_text[name] = failtext
+ rev.groups[group].fail_status[name] = status
for g in sorted(rev.groups):
g = rev.groups[g]
- #print g.name, g.n_tests, g.n_fail, g.fail
+ # print (g.name, g.n_tests, g.n_fail, g.fail)
return rev
+# from xml.dom import minidom
-#from xml.dom import minidom
-
-
-n=glob.glob("*/Build.xml")
+n = glob.glob("*/Build.xml")
n.sort(reverse=True)
-numberofrevisions=10
-n = n[0:min(10,len(n))]
+numberofrevisions = 10
+n = n[0 : min(10, len(n))]
revs = []
allgroups = set()
for f in n:
- dirname = f.replace('/Build.xml','')
+ dirname = f.replace("/Build.xml", "")
rev = parse_revision(dirname)
- if rev!=None:
+ if rev != None:
revs.append(rev)
for gr in rev.groups:
allgroups.add(gr)
allgroups = sorted(allgroups)
-f = open('tests.html', 'w')
-f.write('<html><head></head>')
-f.write("""<style type="text/css">
+f = open("tests.html", "w")
+f.write("<html><head></head>")
+f.write(
+ """<style type="text/css">
table {
border-collapse:collapse;
}
.onerow {background: #FFE}
.otherrow {background: #EEE}
-</style>""")
-f.write("""<script>
+</style>"""
+)
+f.write(
+ """<script>
function toggle_id(obj)
{
var e = document.getElementById(obj);
e.style.display = '';
}
</script>
-<body>""")
-f.write('<table>')
+<body>"""
+)
+f.write("<table>")
f.write('<colgroup span="1" class="colgroup""/>')
for rev in revs:
f.write('<colgroup span="5" class="colgroup"/>')
-f.write('\n')
+f.write("\n")
-f.write('<thead><tr>')
+f.write("<thead><tr>")
f.write('<th style="width:250px"> </th>')
for rev in revs:
- f.write('<th colspan="5"><a href="http://www.dealii.org/websvn/revision.php?repname=deal.II+Repository&rev=%s">r%s</th>'%(rev.number,rev.number))
-f.write('</tr></thead>\n')
-
-f.write('<tbody><tr>')
-f.write('<td>ALL</td>')
+ f.write(
+ '<th colspan="5"><a href="http://www.dealii.org/websvn/revision.php?repname=deal.II+Repository&rev=%s">r%s</th>'
+ % (rev.number, rev.number)
+ )
+f.write("</tr></thead>\n")
+
+f.write("<tbody><tr>")
+f.write("<td>ALL</td>")
for rev in revs:
- if (rev.n_fail>0):
- f.write('<td colspan="5" class="groupALL"><span class="fail">' + str(rev.n_fail) + '</span> / ' + str(rev.n_tests) + '</td>')
+ if rev.n_fail > 0:
+ f.write(
+ '<td colspan="5" class="groupALL"><span class="fail">'
+ + str(rev.n_fail)
+ + "</span> / "
+ + str(rev.n_tests)
+ + "</td>"
+ )
else:
- f.write('<td colspan="5" class="groupALL">' + str(rev.n_fail) + ' / ' + str(rev.n_tests) + '</td>')
-f.write('</tr></tbody>\n')
-
-#second header
+ f.write(
+ '<td colspan="5" class="groupALL">'
+ + str(rev.n_fail)
+ + " / "
+ + str(rev.n_tests)
+ + "</td>"
+ )
+f.write("</tr></tbody>\n")
+
+# second header
f.write('<tbody><tr style="border-bottom: 2px solid">')
-f.write('<td></td>')
+f.write("<td></td>")
for rev in revs:
- for c in range(0,5):
+ for c in range(0, 5):
- titles=['Configure','Build','Run','Diff','Pass']
- caption=['C','B','R','D','P']
- f.write('<td title="%s" class="test%d">%s</td>'%(titles[c],c,caption[c]))
-f.write('</tr></tbody>\n')
+ titles = ["Configure", "Build", "Run", "Diff", "Pass"]
+ caption = ["C", "B", "R", "D", "P"]
+ f.write('<td title="%s" class="test%d">%s</td>' % (titles[c], c, caption[c]))
+f.write("</tr></tbody>\n")
-counter=0
+counter = 0
for group in allgroups:
- counter+=1
- if counter % 2==0:
+ counter += 1
+ if counter % 2 == 0:
f.write('<tbody class="onerow"><tr>')
else:
f.write('<tbody class="otherrow"><tr>')
failing |= set(rev.groups[group].fail)
failing = sorted(failing)
- if (len(failing)>0):
- f.write('<td><a href="#" onclick="toggle_id(\'group:%s\');return false">%s</a></td>'%(group,group))
+ if len(failing) > 0:
+ f.write(
+ '<td><a href="#" onclick="toggle_id(\'group:%s\');return false">%s</a></td>'
+ % (group, group)
+ )
else:
- f.write('<td>' + group + '</td>')
+ f.write("<td>" + group + "</td>")
for rev in revs:
if group not in rev.groups:
- for c in range(0,5):
- f.write('<td></td>')
+ for c in range(0, 5):
+ f.write("<td></td>")
else:
gr = rev.groups[group]
- for c in range(0,5):
- if gr.n_status[c]==0:
- f.write('<td></td>')
+ for c in range(0, 5):
+ if gr.n_status[c] == 0:
+ f.write("<td></td>")
else:
- f.write('<td class="test%d">%d</td>'%(c,gr.n_status[c]))
-
- f.write('</tr></tbody>\n')
+ f.write('<td class="test%d">%d</td>' % (c, gr.n_status[c]))
+ f.write("</tr></tbody>\n")
- #failing tests in group:
- if len(failing)>0:
- f.write('<tbody class="togglebody" style="display:none" id="group:%s">'%group)
+ # failing tests in group:
+ if len(failing) > 0:
+ f.write('<tbody class="togglebody" style="display:none" id="group:%s">' % group)
for fail in failing:
- f.write('<tr>')
- name = fail[len(group):] # cut off group name
- f.write('<td> ' + name + '</td>')
+ f.write("<tr>")
+ name = fail[len(group) :] # cut off group name
+ f.write("<td> " + name + "</td>")
for rev in revs:
if group in rev.groups and fail in rev.groups[group].fail:
- status=rev.groups[group].fail_status[fail]
- text=rev.groups[group].fail_text[fail]
- for c in range(0,5):
- if c==status:
- f.write('<td class="test%d" title="%s">X</td>'%(c,text))
+ status = rev.groups[group].fail_status[fail]
+ text = rev.groups[group].fail_text[fail]
+ for c in range(0, 5):
+ if c == status:
+ f.write('<td class="test%d" title="%s">X</td>' % (c, text))
else:
- f.write('<td></td>')
+ f.write("<td></td>")
else:
f.write('<td colspan="5"></td>')
- f.write('</tr>\n')
- f.write('</tbody>\n')
+ f.write("</tr>\n")
+ f.write("</tbody>\n")
- f.write('\n\n')
+ f.write("\n\n")
-f.write('</table>')
+f.write("</table>")
-f.write('</body></html>')
+f.write("</body></html>")