html: add fail,error tables in html 73/238873/1
authorYeongjong Lee <yj34.lee@samsung.com>
Mon, 20 Jul 2020 04:06:27 +0000 (13:06 +0900)
committerChun <jykeon@samsung.com>
Mon, 20 Jul 2020 04:29:19 +0000 (04:29 +0000)
We can now check failure,error test cases at the top of html file.

Change-Id: I21cf8024062efc6fbc8700e6ef1394d402d762b0
(cherry picked from commit b719783db75d637ffdcc8df050160c07ee0cee20)

TC/target_generation_html_report.py

index 2354e1ab7beea35408301b44e4c2c673d6f1bcda..cd90092043d1919f0df63ab8ddd0952bce0f239c 100755 (executable)
@@ -24,6 +24,37 @@ def xml_tag_to_html_table(root):
        r.append(table)
        return r
 
+def xml_fail_tag_to_html_table(root):
+       if len(root.xpath('//*[@result="failure"]'))==0:
+               return [];
+
+       table = E.TABLE({'border':'1'},  E.TR(E.TH('Function line'), E.TH('Test case'),
+                                       E.TH("Result"), E.TH("Message"), E.TH("Duration"), bgcolor= "#d3d3d3"))
+       r = []
+       r += [E.P("Fail : " + str(len(root.xpath('//*[@result="failure"]'))), style="font-weight: bold; font-size: 120%")]
+       for i in root.xpath('//*[@result="failure"]'):
+          table.append(E.TR(E.TD(i.find('fn').text), E.TD(i.find('id').text), E.TD(i.attrib['result']),
+                         E.TD(i.find('message').text), E.TD(i.find('duration').text), bgcolor = table_in_color(i.attrib['result'])))
+
+       r.append(table)
+       return r
+
+def xml_error_tag_to_html_table(root):
+       if len(root.xpath('//*[@result="error"]'))==0:
+               return [];
+
+       table = E.TABLE({'border':'1'},  E.TR(E.TH('Function line'), E.TH('Test case'),
+                                       E.TH("Result"), E.TH("Message"), E.TH("Duration"), bgcolor= "#d3d3d3"))
+       r = []
+       r += [E.P("Error : " + str(len(root.xpath('//*[@result="error"]'))), style="font-weight: bold; font-size: 120%")]
+       for i in root.xpath('//*[@result="error"]'):
+          table.append(E.TR(E.TD(i.find('fn').text), E.TD(i.find('id').text), E.TD(i.attrib['result']),
+                                                       E.TD(i.find('message').text), E.TD(i.find('duration').text), bgcolor = table_in_color(i.attrib['result'])))
+
+       r.append(table)
+       return r
+
+
 with open(sys.argv[1],'r') as f: e = fromstring(f.read())
 
 html = E.HTML(
@@ -51,6 +82,13 @@ html = E.HTML(
                )
        )
 
+
+for i in xml_fail_tag_to_html_table(e):
+       html.body.append(i)
+
+for i in xml_error_tag_to_html_table(e):
+       html.body.append(i)
+
 for i in e.xpath('//suite'):
        for j in xml_tag_to_html_table(i):
                html.body.append(j)