Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions library/callback_plugins/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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)

Expand Down