More verbose modes for report --how display
v    ... result + name
vv   ... result + name + path to logs
vvv  ... result + name + path to logs + content of out.log
+import os
+
import tmt
class ReportDisplay(tmt.steps.report.ReportPlugin):
@@ -11,6 +13,25 @@ class ReportDisplay(tmt.steps.report.ReportPlugin):
# Supported methods
_methods = [tmt.steps.Method(name='display', doc=__doc__, order=50)]
+ def details(self, result, verbosity):
+ """ Print resuts' details based on the verbose mode """
+ # -v prints just result + name
+ # -vv prints path to logs
+ # -vvv prints also content of out.log
+ self.verbose(result.show(), shift=1)
+ if verbosity == 1:
+ return
+ # -vv and more follows
+ for log_file in result.log:
+ log_name = os.path.basename(log_file)
+ real_log_path = os.path.join(self.step.plan.execute.workdir, log_file)
+ # path to logs (-vv and more)
+ self.verbose(log_name, real_log_path, color='yellow', shift=2)
+ # out.log for (-vvv and more)
+ if verbosity > 2 and log_name in ['out.log']:
+ with open(real_log_path) as f:
+ self.verbose(f.read(), shift=2)
+
def go(self):
""" Discover available tests """
super().go()
@@ -18,4 +39,4 @@ class ReportDisplay(tmt.steps.report.ReportPlugin):
if not self.opt('verbose'):
return
for result in self.step.plan.execute.results():
- self.verbose(result.show(), shift=1)
+ self.details(result, self.opt('verbose'))
