Commit 416ace30 authored by Jérome Perrin's avatar Jérome Perrin

Display svn revision, number of test runs, failures and error on the subject line.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11089 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f3673f73
#!/usr/bin/python
import smtplib
import re
from datetime import date
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
......@@ -24,22 +25,49 @@ to_mail = [ 'erp5-report@nexedi.com'
test_msg = file("%s/Products/test_output" % (ZOPE_INSTANCE),'r').read()
test_msg = "Date : %s\n\n" % date.today().isoformat() + test_msg
#msg.set_payload(test_msg)
# minimal parsing
revision_re = re.compile('Revision: (?P<revision>\d+)')
ran_test_re = re.compile('Ran (?P<tests>\d+) tests')
errors_re = re.compile('FAILED \((failures=(?P<failures>\d+))*[, ]*'\
'(errors=(?P<errors>\d+))*\)')
svn_revision = "?"
test_runs = 0
errors = 0
failures = 0
for test_line in test_msg.splitlines():
revision = revision_re.match(test_line)
if revision:
svn_revision = revision.groupdict()['revision']
ran = ran_test_re.match(test_line)
if ran:
test_runs += int(ran.groupdict()['tests'])
errors_or_failures = errors_re.match(test_line)
if errors_or_failures:
failures += int(errors_or_failures.groupdict()['failures'] or 0)
errors += int(errors_or_failures.groupdict()['errors'] or 0)
subject = "ERP5 r%s: %s Tests, %s Errors, %s Failures" % (
svn_revision, test_runs, errors, failures)
msg = MIMEMultipart()
msg['Subject'] = subject
msg['From'] = from_mail
msg['To'] = COMMASPACE.join(to_mail)
#msg['content-type']=test_msg
# Guarantees the message ends in a newline
msg.preamble = subject
msg.epilogue = ''
file_content = file("%s/Products/test_full_output" % (ZOPE_INSTANCE),'r').read()
file_content = file("%s/Products/test_full_output" %
(ZOPE_INSTANCE),'r').read()
mime_text = MIMEText(test_msg)
mime_text.add_header('Content-Disposition', 'attachment', filename='test_output')
mime_text.add_header('Content-Disposition', 'attachment',
filename='test_output')
msg.attach(mime_text)
mime_text = MIMEText(file_content)
mime_text.add_header('Content-Disposition', 'attachment', filename='test_full_output')
mime_text.add_header('Content-Disposition', 'attachment',
filename='test_full_output')
msg.attach(mime_text)
# Send the email via our own SMTP server.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment