Skip to content
Snippets Groups Projects
Commit 89543d76 authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Indicate number of failures in email subject (refs #21150).

parent 61318828
No related branches found
No related tags found
No related merge requests found
......@@ -250,7 +250,6 @@ class Tester():
# Prepare report
report_rows.append((name, criticality, status, str(duration), description))
report_rows_length = [max(len(strip_colors(t)), report_rows_length[i]) for i, t in enumerate(report_rows[-1])]
exit_code = 1 if failures > 0 else 0
# Display results
# results as text
log('\nTests results:')
......@@ -296,7 +295,7 @@ class Tester():
with open(history_file, 'a') as fo:
if add_header:
fo.write('Date | Result | Succeeded | Failed | Not testable\n')
fo.write('%s | %s | %s | %s | %s\n' % (now.strftime('%Y-%m-%d %H:%M:%S'), 'OK' if exit_code == 0 else 'KO', successes, failures, len(tests) - successes - failures))
fo.write('%s | %s | %s | %s | %s\n' % (now.strftime('%Y-%m-%d %H:%M:%S'), 'KO' if failures > 0 else 'OK', successes, failures, len(tests) - successes - failures))
# Search for old logs to remove
names = os.listdir(log_dir)
names.sort()
......@@ -325,7 +324,7 @@ class Tester():
if hostname:
if email:
send_email = True
elif email_if_fail and exit_code != 0:
elif email_if_fail and failures > 0:
# if they were too many consecutive failures, do not send the email
with open(history_file, 'r') as fo:
history_content = fo.read()
......@@ -338,7 +337,10 @@ class Tester():
consecutive_failures += 1
else:
break
if consecutive_failures < self.NO_MAIL_FAILURES_COUNT:
if consecutive_failures == self.NO_MAIL_FAILURES_COUNT:
log('Maximum consecutive tester failures reached (%s).\nNo more emails will be sent.' % consecutive_failures)
send_email = True
elif consecutive_failures < self.NO_MAIL_FAILURES_COUNT:
log('Consecutive tester failures: %s.' % consecutive_failures)
send_email = True
else:
......@@ -382,7 +384,7 @@ Content-transfer-encoding: utf-8
boundary=boundary,
hostname=hostname,
recipients=recipients,
status='OK' if exit_code == 0 else 'KO',
status=('KO (%s tests failed)' % failures) if failures > 0 else 'OK',
date=now.strftime('%Y-%m-%d %H:%M:%S'),
report=html_report,
log_name=log_name,
......@@ -397,6 +399,7 @@ Content-transfer-encoding: utf-8
return 1
else:
log('Email sent to: %s' % recipients)
exit_code = 1 if failures > 0 else 0
return exit_code
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment