Revision: 3989
Author: jussi.ao.malinen
Date: Mon Aug 30 05:53:20 2010
Log: generate links to log from errors/warnings only if the is a target (issue 628)
http://code.google.com/p/robotframework/source/detail?r=3989

Modified:
 /trunk/atest/robot/output/links_in_report_and_log.txt
 /trunk/atest/testdata/misc/multiple_suites/SUite7.html
 /trunk/src/robot/output/logger.py
 /trunk/src/robot/output/loggerhelper.py
 /trunk/src/robot/output/readers.py
 /trunk/src/robot/output/xmllogger.py
 /trunk/src/robot/serializing/logserializers.py

=======================================
--- /trunk/atest/robot/output/links_in_report_and_log.txt Sun Aug 29 22:42:08 2010 +++ /trunk/atest/robot/output/links_in_report_and_log.txt Mon Aug 30 05:53:20 2010
@@ -30,9 +30,12 @@
Should Contain ${LOG} <a class="name" name="suite_Multiple Suites.Subsuite1.Suite4" title="Multiple Suites.Subsuite1.Suite4">Suite4</a>

 Link From Log's "Test Execution Errors" Table To Log's Details
- ${match} ${group1} ${group2} = Should Match Regexp ${LOG} <td class="time"><a href="#msg_(\\d{8}) (\\d{2}:\\d{2}:\\d{2}.\\d{3})" onclick="set_element_visible\\('msg_\\d{8} \\d{2}:\\d{2}:\\d{2}.\\d{3}'\\)" title="Link to log when error occurred during execution.">\\d{8}&nbsp;\\d{2}:\\d{2}:\\d{2}.\\d{3}</a></td> + ${match} ${group1} ${group2} = Should Match Regexp ${LOG} <td class="time"><a href="#msg_(\\d{8}) (\\d{2}:\\d{2}:\\d{2}.\\d{3})" onclick="set_element_visible\\('msg_\\d{8} \\d{2}:\\d{2}:\\d{2}.\\d{3}'\\)" title="Link to details.">\\d{8}&nbsp;\\d{2}:\\d{2}:\\d{2}.\\d{3}</a></td>\n<td class="warn level">WARN</td>\n<td class="msg">warning</td> Should Contain ${LOG} <td class="time" id="msg_${group1} ${group2}">${group2}</td>

+No Link From Log's "Test Execution Errors" Table To Log's Details When There Is No Link Target + Should Match Regexp ${LOG} <td class="time">\\d{8}&nbsp;\\d{2}:\\d{2}:\\d{2}.\\d{3}</td>\n<td class="error level">ERROR</td>\n<td class="msg">Invalid syntax in file '.*SUite7.html' in table 'Setting': Importing test library 'NonExisting' failed:
+
 *** Keywords ***
 Create Report And Log And Read Those Content
Run Tests --report ${REPORT FILE NAME} --log ${LOG FILE NAME} misc${/}multiple_suites
=======================================
--- /trunk/atest/testdata/misc/multiple_suites/SUite7.html Tue May 25 04:11:36 2010 +++ /trunk/atest/testdata/misc/multiple_suites/SUite7.html Mon Aug 30 05:53:20 2010
@@ -73,8 +73,8 @@
 <th>Value</th>
 </tr>
 <tr>
-<td></td>
-<td></td>
+<td>Library</td>
+<td>Non Existing</td>
 <td></td>
 <td></td>
 <td></td>
=======================================
--- /trunk/src/robot/output/logger.py   Mon May 31 15:09:54 2010
+++ /trunk/src/robot/output/logger.py   Mon Aug 30 05:53:20 2010
@@ -100,6 +100,7 @@
         for logger in self._loggers:
             logger.log_message(msg)
         if msg.level == 'WARN':
+            msg.linkable = True
             self.message(msg)

     def output_file(self, name, path):
=======================================
--- /trunk/src/robot/output/loggerhelper.py     Mon May 31 15:09:54 2010
+++ /trunk/src/robot/output/loggerhelper.py     Mon Aug 30 05:53:20 2010
@@ -68,6 +68,7 @@
                                              timesep=':', millissep='.')
         self.level, self.html = self._get_level_and_html(level, html)
         self.message = self._process_message(message)
+        self.linkable = False

     def _get_level_and_html(self, level, html):
         level = level.upper()
=======================================
--- /trunk/src/robot/output/readers.py  Mon Aug 23 06:35:19 2010
+++ /trunk/src/robot/output/readers.py  Mon Aug 30 05:53:20 2010
@@ -297,6 +297,7 @@
         self.level = node.get_attr('level', 'INFO')
         self.message = node.text
         self.html = node.get_attr('html', 'no') == 'yes'
+        self.linkable = node.get_attr('linkable', 'no') == 'yes'

     def serialize(self, serializer):
         serializer.message(self)
=======================================
--- /trunk/src/robot/output/xmllogger.py        Mon May 31 05:21:54 2010
+++ /trunk/src/robot/output/xmllogger.py        Mon Aug 30 05:53:20 2010
@@ -73,6 +73,8 @@
     def _message(self, msg):
         html = msg.html and 'yes' or 'no'
attrs = { 'timestamp': msg.timestamp, 'level': msg.level, 'html': html }
+        if msg.linkable:
+            attrs['linkable'] = 'yes'
         self._writer.element('msg', msg.message, attrs)

     def start_keyword(self, kw):
=======================================
--- /trunk/src/robot/serializing/logserializers.py      Fri Aug 27 03:20:17 2010
+++ /trunk/src/robot/serializing/logserializers.py      Mon Aug 30 05:53:20 2010
@@ -282,11 +282,14 @@
     def message(self, msg):
         self._writer.start('tr')
         self._writer.start('td', {'class': 'time'}, newline=False)
-        self._writer.element('a', msg.timestamp.replace(' ', '&nbsp;'),
-                             {'href': "#msg_%s" % msg.timestamp,
- 'onclick': "set_element_visible('msg_%s')" % msg.timestamp, - 'title': 'Link to log when error occurred during execution.'},
-                              escape=False, newline=False)
+        if msg.linkable:
+            self._writer.element('a', msg.timestamp.replace(' ', '&nbsp;'),
+                                 {'href': "#msg_%s" % msg.timestamp,
+ 'onclick': "set_element_visible('msg_%s')" % msg.timestamp,
+                                  'title': 'Link to details.'},
+                                  escape=False, newline=False)
+        else:
+ self._writer.content(msg.timestamp.replace(' ', '&nbsp;'), escape=False)
         self._writer.end('td')
         self._writer.element('td', msg.level,
                              {'class': '%s level' % msg.level.lower()})

Reply via email to