2017-08-19 02:21:11 +02:00
|
|
|
"""Sanity test for documentation of sanity tests."""
|
2019-07-12 08:46:20 +02:00
|
|
|
from __future__ import (absolute_import, division, print_function)
|
|
|
|
__metaclass__ = type
|
2017-08-19 02:21:11 +02:00
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
from lib.sanity import (
|
|
|
|
SanitySingleVersion,
|
|
|
|
SanityMessage,
|
|
|
|
SanityFailure,
|
|
|
|
SanitySuccess,
|
|
|
|
sanity_get_tests,
|
|
|
|
)
|
|
|
|
|
|
|
|
from lib.config import (
|
|
|
|
SanityConfig,
|
|
|
|
)
|
|
|
|
|
2019-07-23 04:24:48 +02:00
|
|
|
from lib.data import (
|
|
|
|
data_context,
|
|
|
|
)
|
|
|
|
|
2017-08-19 02:21:11 +02:00
|
|
|
|
|
|
|
class SanityDocsTest(SanitySingleVersion):
|
|
|
|
"""Sanity test for documentation of sanity tests."""
|
2019-07-23 04:24:48 +02:00
|
|
|
ansible_only = True
|
|
|
|
|
2017-08-19 02:21:11 +02:00
|
|
|
# noinspection PyUnusedLocal
|
|
|
|
def test(self, args, targets): # pylint: disable=locally-disabled, unused-argument
|
|
|
|
"""
|
|
|
|
:type args: SanityConfig
|
|
|
|
:type targets: SanityTargets
|
2018-04-04 03:53:53 +02:00
|
|
|
:rtype: TestResult
|
2017-08-19 02:21:11 +02:00
|
|
|
"""
|
2019-07-23 04:24:48 +02:00
|
|
|
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')
|
2017-08-19 02:21:11 +02:00
|
|
|
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)
|