mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
7 years ago
|
"""Sanity test for documentation of sanity tests."""
|
||
5 years ago
|
from __future__ import (absolute_import, division, print_function)
|
||
|
__metaclass__ = type
|
||
7 years ago
|
|
||
|
import os
|
||
|
|
||
5 years ago
|
from ..sanity import (
|
||
5 years ago
|
SanityVersionNeutral,
|
||
7 years ago
|
SanityMessage,
|
||
|
SanityFailure,
|
||
|
SanitySuccess,
|
||
|
sanity_get_tests,
|
||
|
)
|
||
|
|
||
5 years ago
|
from ..config import (
|
||
7 years ago
|
SanityConfig,
|
||
|
)
|
||
|
|
||
5 years ago
|
from ..data import (
|
||
5 years ago
|
data_context,
|
||
|
)
|
||
|
|
||
7 years ago
|
|
||
5 years ago
|
class SanityDocsTest(SanityVersionNeutral):
|
||
7 years ago
|
"""Sanity test for documentation of sanity tests."""
|
||
5 years ago
|
ansible_only = True
|
||
|
|
||
5 years ago
|
@property
|
||
|
def can_ignore(self): # type: () -> bool
|
||
|
"""True if the test supports ignore entries."""
|
||
|
return False
|
||
|
|
||
|
@property
|
||
5 years ago
|
def no_targets(self): # type: () -> bool
|
||
|
"""True if the test does not use test targets. Mutually exclusive with all_targets."""
|
||
|
return True
|
||
5 years ago
|
|
||
7 years ago
|
# noinspection PyUnusedLocal
|
||
|
def test(self, args, targets): # pylint: disable=locally-disabled, unused-argument
|
||
|
"""
|
||
|
:type args: SanityConfig
|
||
|
:type targets: SanityTargets
|
||
7 years ago
|
:rtype: TestResult
|
||
7 years ago
|
"""
|
||
5 years ago
|
sanity_dir = 'docs/docsite/rst/dev_guide/testing/sanity'
|
||
|
sanity_docs = set(part[0] for part in (os.path.splitext(os.path.basename(path)) for path in data_context().content.get_files(sanity_dir))
|
||
|
if part[1] == '.rst')
|
||
7 years ago
|
sanity_tests = set(sanity_test.name for sanity_test in sanity_get_tests())
|
||
|
|
||
|
missing = sanity_tests - sanity_docs
|
||
|
|
||
|
results = []
|
||
|
|
||
|
results += [SanityMessage(
|
||
|
message='missing docs for ansible-test sanity --test %s' % r,
|
||
|
path=os.path.join(sanity_dir, '%s.rst' % r),
|
||
|
) for r in sorted(missing)]
|
||
|
|
||
|
if results:
|
||
|
return SanityFailure(self.name, messages=results)
|
||
|
|
||
|
return SanitySuccess(self.name)
|