Allow junit reports task result overriding

Allows user to mention the expected junit result by
altering the task names and including the special
'EXPECTED FAILURE' or 'TOGGLE RESULT' keywords.

This behavior is the same as the upstream Ansible junit callback [1].

[1]: https://docs.ansible.com/ansible/2.5/plugins/callback/junit.html

Change-Id: I9b306b7ea42cfce7913d87d919d72d34bc2270ec
This commit is contained in:
Sorin Sbarnea 2018-05-31 10:56:42 +01:00
parent ab2189b556
commit dca186adcb
1 changed files with 16 additions and 3 deletions

View File

@ -87,7 +87,17 @@ class GenerateHtml(Command):
class GenerateJunit(Command):
""" Generate junit stream from ara data """
""" Generate junit stream from ara data
Tasks show up in the report as follows:
'ok': pass
'failed' with 'EXPECTED FAILURE' in the task name: pass
'failed' with 'TOGGLE RESULT' in the task name: pass
'ok' with 'TOGGLE RESULT' in the task name: failure
'failed' due to an exception: error
'failed' for other reasons: failure
'skipped': skipped"
"""
log = logging.getLogger(__name__)
def get_parser(self, prog_name):
@ -139,8 +149,11 @@ class GenerateJunit(Command):
stdout=result_str)
if result.status == 'skipped':
test_case.add_skipped_info(message=result.result)
elif (result.status in ('failed', 'unreachable') and
result.ignore_errors is False):
elif ((result.status in ('failed', 'unreachable') and
result.ignore_errors is False and
'EXPECTED FAILURE' not in task_name and
'TOGGLE RESULT' not in task_name) or
(result.status == 'ok' and 'TOGGLE RESULT' in task_name)):
test_case.add_failure_info(message=result.result)
test_cases.append(test_case)
test_suite = TestSuite('Ansible Tasks', test_cases)