From 0f5bf032e660e6f23a229087082771f6938ec605 Mon Sep 17 00:00:00 2001 From: Daniel Ruthardt Date: Sat, 1 Aug 2020 14:29:12 +0200 Subject: [PATCH] Honour the diagnostic tag on skipped tasks. --- library/callback_plugins/tap.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/library/callback_plugins/tap.py b/library/callback_plugins/tap.py index 5417282..91073be 100644 --- a/library/callback_plugins/tap.py +++ b/library/callback_plugins/tap.py @@ -93,10 +93,8 @@ def skip(cls, result): """ Render a skipped test. """ - description = cls._describe(result) - reason = result._result.get('skip_reason', result._result.get('skipped_reason', None)) - directive = '# SKIP {}'.format(reason) if reason else '# SKIP' - return cls._tap(cls.OK, description, directive=directive) + description = cls._describe(result, skipped=True) + return cls._tap(cls.OK, description) @classmethod def not_ok(cls, result): @@ -108,15 +106,21 @@ def not_ok(cls, result): return cls._tap(cls.NOT_OK, description, directive=directive) @staticmethod - def _describe(result): + def _describe(result, skipped=False): """ Construct a test line description based on the name of the Ansible module and task name. """ description = '{}'.format(result._task.action) + + if skipped: + reason = result._result.get('skip_reason', result._result.get('skipped_reason', None)) + directive = '# SKIP {}'.format(reason) if reason else '# SKIP' + if result._task.name: description = '{}: {}'.format(description, result._task.name) - return description + + return description if not skipped else '{} {}'.format(description, directive) @staticmethod def _tap(status, description, directive=None): @@ -149,6 +153,9 @@ def v2_runner_on_ok(self, result): self._display.display(self.ok(result)) def v2_runner_on_skipped(self, result): + if is_diagnostic(result._task): + self._display.display('# {}'.format(self._describe(result, skipped=True))) + return self._display.display(self.skip(result)) self.counter.update(TestResult.SKIPPED.value)