From 6ad1f7318226656c5a20d47061b922c88bce8ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Diemer?= <stephane.diemer@ubicast.eu> Date: Thu, 23 Feb 2017 09:15:09 +0100 Subject: [PATCH] Display tests duration (refs #20583). --- tester.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tester.py b/tester.py index 85cb40c3..b14a77fc 100755 --- a/tester.py +++ b/tester.py @@ -165,6 +165,7 @@ class Tester(): results = list() successes = 0 failures = 0 + total_duration = None for name, description, command in tests: log('\033[1;95m-- Test "%s" --\033[0;0m' % name) start_date = datetime.datetime.utcnow() @@ -186,14 +187,19 @@ class Tester(): failures += 1 log('Command exited with code %s.' % p.returncode) end_date = datetime.datetime.utcnow() - log('Test end: %s UTC (duration: %s).' % (end_date.strftime('%Y-%m-%d %H:%M:%S'), end_date - start_date)) - results.append((name, description, command, success)) + duration = end_date - start_date + if total_duration: + total_duration += duration + else: + total_duration = duration + log('Test end: %s UTC (duration: %s).' % (end_date.strftime('%Y-%m-%d %H:%M:%S'), duration)) + results.append((name, description, command, success, duration)) exit_code = 1 if failures > 0 else 0 # Display results log('\nTests results:') html_report = '<table border="1">' - html_report += '\n<tr><th>Test</th><th>Result</th><th>Description</th></tr>' - for name, description, command, success in results: + html_report += '\n<tr><th>Test</th><th>Result</th><th>Duration</th><th>Description</th></tr>' + for name, description, command, success, duration in results: if success is None: html_result = '<span style="color: blue;">not testable</span>' term_result = '\033[94mnot testable\033[0m' @@ -203,9 +209,9 @@ class Tester(): else: html_result = '<span style="color: red;">failure</span>' term_result = '\033[91mfailure\033[0m' - log(' %s: %s' % (name, term_result)) - html_report += '\n<tr><td>%s</td><td>%s</td><td>%s</td></tr>' % (name, html_result, description.replace('\n', '<br/>\n')) - log('') + log(' %s: %s (%s)' % (name, term_result, duration)) + html_report += '\n<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>' % (name, html_result, duration, description.replace('\n', '<br/>\n')) + log('Total tests duration: %s.\n' % total_duration) html_report += '\n</table>' # Store locally results now = datetime.datetime.utcnow() @@ -265,7 +271,6 @@ class Tester(): else: log('Too many consecutive tester failures: %s, no email will be sent.' % consecutive_failures) if send_email: - log('') recipients = utils.get_conf('EMAIL_ADMINS') if not recipients: log('No recipients defined for email sending. Set a value for EMAIL_ADMINS.') -- GitLab