From de007b681905d0ca584a507a9c2200bae4104aae Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 26 Mar 2019 14:09:54 -0300 Subject: [PATCH] validate:launcher: Put all logs inside the failure node Pleasing gitlab CI reporting system --- validate/launcher/reporters.py | 40 ++++++++++++++++------------------ 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/validate/launcher/reporters.py b/validate/launcher/reporters.py index e165da192c..7b6bd3b452 100644 --- a/validate/launcher/reporters.py +++ b/validate/launcher/reporters.py @@ -137,23 +137,25 @@ class XunitReporter(Reporter): self.report() return super(XunitReporter, self).final_report() - def _get_captured(self, test): - captured = "" + def _get_all_logs_data(self, test): if not self.options.redirect_logs: - value = test.get_log_content() - if value: - captured += '" + captured = "" + value = test.get_log_content() + if value: + captured += escape_cdata(value) + for extralog in test.extra_logfiles: + captured += "\n\n===== %s =====\n\n" % escape_cdata( + os.path.basename(extralog)) + value = test.get_extra_log_content(extralog) + captured += escape_cdata(value) return captured + def _get_captured(self, test): + return '' % self._get_all_logs_data(test) + def _quoteattr(self, attr): """Escape an XML attribute. Value can be unicode.""" attr = xml_safe(attr) @@ -172,8 +174,8 @@ class XunitReporter(Reporter): self.encoding, 'replace') self.stats['encoding'] = self.encoding - self.stats['total'] = (self.stats['timeout'] + self.stats['failures'] + - self.stats['passed'] + self.stats['skipped']) + self.stats['total'] = (self.stats['timeout'] + self.stats['failures'] + + self.stats['passed'] + self.stats['skipped']) xml_file.write('' '' - '%(stacktrace)s' - '%(systemout)s' % + '%(logs)s' + '' % {'name': self._quoteattr(test.get_classname() + '.' + test.get_name()), 'taken': test.time_taken, - 'stacktrace': stack_trace, + 'logs': self._get_all_logs_data(test), 'errtype': self._quoteattr(test.result), 'message': self._quoteattr(test.message), - 'systemout': self._get_captured(test), })) xml_file.close()