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

Added email if fail in tester args (refs #20227).

parent 8699399d
No related branches found
No related tags found
No related merge requests found
......@@ -35,11 +35,13 @@ sys.stderr = sys.stdout
class Tester():
USAGE = '''%s [-e] [-b] [-d] [-h]
USAGE = '''%s [-e] [-f] [-b] [-d] [-h]
-e: send email with report.
-f: send email with report only if at least one test failed.
-b: run only basic tests (exclude mediaserver tests).
-d: debug mode (can be started with non root users).
-h: show this message.''' % __file__
VALID_ARGS = ['-e', '-f', '-b', '-d', '-h']
def __init__(self, *args):
log('\033[96m-------------------------------\033[0m')
......@@ -50,6 +52,11 @@ class Tester():
if '-h' in args:
log('USAGE: ' + self.USAGE)
sys.exit(0)
for arg in args:
if arg not in self.VALID_ARGS:
log('Invalid argument given: "%s".\n' % arg)
log('USAGE: ' + self.USAGE)
sys.exit(1)
# Check current dir
root_dir = utils.get_dir(__file__)
if root_dir != '':
......@@ -71,11 +78,12 @@ class Tester():
sys.exit(1)
# Check for email value
email = '-e' in args
email_if_fail = '-f' in args
basic_only = '-b' in args
tests = self.discover_tests(basic_only)
if not tests:
sys.exit(1)
exit_code = self.run_tests(tests, email)
exit_code = self.run_tests(tests, email, email_if_fail)
sys.exit(exit_code)
def get_file_description(self, path):
......@@ -150,7 +158,7 @@ class Tester():
tests.append(('%s (%s)' % (name, user), description, [test_path, user]))
return tests
def run_tests(self, tests, email=False):
def run_tests(self, tests, email=False, email_if_fail=False):
results = list()
exit_code = 0
# Run all tests
......@@ -194,7 +202,7 @@ class Tester():
html_report += '\n<tr><td>%s</td><td>%s</td><td>%s</td></tr>' % (name, html_result, description.replace('\n', '<br/>\n'))
html_report += '\n</table>'
# Send email
if email:
if email or email_if_fail and exit_code != 0:
log('')
hostname = subprocess.check_output(['hostname'])
if not hostname:
......
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