CSIT-358 Improve robot output parser 94/2394/3
authorpmikus <pmikus@cisco.com>
Tue, 16 Aug 2016 07:08:49 +0000 (08:08 +0100)
committerMiroslav Miklus <mmiklus@cisco.com>
Fri, 26 Aug 2016 12:03:44 +0000 (12:03 +0000)
- Improve the output from robot parser script

Change-Id: Id81bb7891564d1466431e565f7ce19d1dbbf7caa
Signed-off-by: pmikus <pmikus@cisco.com>
resources/tools/robot_output_parser_publish.py

index f9eab8c..92038b5 100755 (executable)
@@ -18,6 +18,7 @@ robot framework output file (output.xml) and print in specified format (wiki,
 html) to stdout or, if specified by parameter, redirect to file."""
 
 import argparse
+import re
 import sys
 
 from robot.api import ExecutionResult, ResultVisitor
@@ -40,14 +41,20 @@ class ExecutionChecker(ResultVisitor):
         if self.start_suite(suite) is not False:
             if suite.tests:
                 if self.formatting == 'html':
-                    sys.stdout.write('<table border=1>'+'\n')
-                    sys.stdout.write('<tr><th width=32%>Name</th>'+\
-                                     '<th width=40%>Documentation</th>'+\
-                                     '<th width=24%>Message</th>'+\
-                                     '<th width=4%>Status</th><tr/>'+'\n')
+                    sys.stdout.write('<table width=100% border=1><tr>'+'\n')
+                    sys.stdout.write('<th width=32%>Name</th>'+'\n')
+                    sys.stdout.write('<th width=40%>Documentation</th>'+'\n')
+                    if "Perf" and "Long" in suite.longname:
+                        sys.stdout.write('<th width=24%>Message</th>'+'\n')
+                    sys.stdout.write('<th width=4%>Status</th><tr/>'+'\n')
+                    sys.stdout.write('</tr>')
                 elif self.formatting == 'wiki':
                     sys.stdout.write('{| class="wikitable"'+'\n')
-                    sys.stdout.write('!Name!!Documentation!!Message!!Status'+'\n')
+                    if "Perf" and "Long" in suite.longname:
+                        header = '!Name!!Documentation!!Message!!Status'
+                    else:
+                        header = '!Name!!Documentation!!Status'
+                    sys.stdout.write(header+'\n')
                 else:
                     pass
 
@@ -78,9 +85,15 @@ class ExecutionChecker(ResultVisitor):
             mark_l = '<h'+str(level)+'>'
             mark_r = '</h'+str(level)+'>'
             sys.stdout.write(mark_l+suite.name+mark_r+'\n')
+            sys.stdout.write('<p>'+re.sub(r"(\*)(.*?)(\*)", r"<b>\2</b>",\
+                suite.doc, 0, flags=re.MULTILINE).replace(\
+                '[', '<br>[')+'</p>\n')
+
         elif self.formatting == 'wiki':
             mark = "=" * (level+2)
             sys.stdout.write(mark+suite.name+mark+'\n')
+            sys.stdout.write(re.sub(r"(\*)(.*?)(\*)", r"\n*'''\2'''",\
+                suite.doc.replace('\n', ' '), 0, flags=re.MULTILINE)+'\n')
         else:
             pass
 
@@ -117,13 +130,15 @@ class ExecutionChecker(ResultVisitor):
             sys.stdout.write('<tr>'+'\n')
             sys.stdout.write('<td>'+test.name+'</td>'+'\n')
             sys.stdout.write('<td>'+test.doc+'</td>'+'\n')
-            sys.stdout.write('<td>'+test.message+'</td>'+'\n')
+            if any("PERFTEST_LONG" in tag for tag in test.tags):
+                sys.stdout.write('<td>'+test.message+'</td>'+'\n')
             sys.stdout.write('<td>'+test.status+'</td>'+'\n')
         elif self.formatting == 'wiki':
             sys.stdout.write('|-'+'\n')
             sys.stdout.write('|'+test.name+'\n')
             sys.stdout.write('|'+test.doc+'\n')
-            sys.stdout.write('|'+test.message+'\n')
+            if any("PERFTEST_LONG" in tag for tag in test.tags):
+                sys.stdout.write('|'+test.message+'\n')
             sys.stdout.write('|'+test.status+'\n')
         else:
             pass