From dca186adcb2e3197cbb3dfa993b4810e15fbc2e3 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 31 May 2018 10:56:42 +0100 Subject: [PATCH] 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 --- ara/cli/generate.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ara/cli/generate.py b/ara/cli/generate.py index 57fe1976..61cb3de9 100644 --- a/ara/cli/generate.py +++ b/ara/cli/generate.py @@ -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)