Commit 73906e79 authored by Jérome Perrin's avatar Jérome Perrin

sys.exit with the number of failures as return code

if both --stdout and --email_to_address are passed, both print and send an
email


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17013 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d078e422
...@@ -20,7 +20,8 @@ Options: ...@@ -20,7 +20,8 @@ Options:
--email_to_address=STRING send results to this address by email (defaults to --email_to_address=STRING send results to this address by email (defaults to
erp5-report@erp5.org) erp5-report@erp5.org)
-s, --stdout prints the results on stdout instead of sending -s, --stdout prints the results on stdout instead of sending
results by email results by email (unless email_to_address is also
passed explictly)
""" """
...@@ -28,7 +29,8 @@ Options: ...@@ -28,7 +29,8 @@ Options:
host = 'localhost' host = 'localhost'
port = 8080 port = 8080
portal_name = 'erp5_portal' portal_name = 'erp5_portal'
send_mail = 1 send_mail = 0
stdout = 0
email_to_address = 'erp5-report@erp5.org' email_to_address = 'erp5-report@erp5.org'
tests_framework_home = os.path.dirname(os.path.abspath(__file__)) tests_framework_home = os.path.dirname(os.path.abspath(__file__))
...@@ -56,6 +58,7 @@ def usage(stream, msg=None): ...@@ -56,6 +58,7 @@ def usage(stream, msg=None):
def parseArgs(): def parseArgs():
global send_mail global send_mail
global stdout
global email_to_address global email_to_address
try: try:
opts, args = getopt.getopt(sys.argv[1:], opts, args = getopt.getopt(sys.argv[1:],
...@@ -67,13 +70,15 @@ def parseArgs(): ...@@ -67,13 +70,15 @@ def parseArgs():
for opt, arg in opts: for opt, arg in opts:
if opt in ("-s", "--stdout"): if opt in ("-s", "--stdout"):
send_mail = 0 stdout = 1
elif opt == '--email_to_address': elif opt == '--email_to_address':
email_to_address = arg email_to_address = arg
send_mail = 1
elif opt in ('-h', '--help'): elif opt in ('-h', '--help'):
usage(sys.stdout) usage(sys.stdout)
sys.exit() sys.exit()
if not stdout:
send_mail = 1
def main(): def main():
setPreference() setPreference()
...@@ -200,14 +205,14 @@ Following tests failed: ...@@ -200,14 +205,14 @@ Following tests failed:
attachments=[file_content], attachments=[file_content],
from_mail='nobody@svn.erp5.org', from_mail='nobody@svn.erp5.org',
to_mail=[email_to_address]) to_mail=[email_to_address])
else: if stdout:
print '-' * 79 print '-' * 79
print subject print subject
print '-' * 79 print '-' * 79
print summary print summary
print '-' * 79 print '-' * 79
print file_content print file_content
return status return failures
if __name__ == "__main__": if __name__ == "__main__":
parseArgs() parseArgs()
......
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