Split up "code smell" sanity tests. (#60174)

* Relocate ansible-only sanity tests.

* Get "code smell" sanity tests from multiple dirs.

- `test/lib/ansible_test/_data/sanity/code-smell/` - General purpose tests used for both Ansible and Ansible Collections.
- `test/sanity/code-smell/` - Tests specific to Ansible, will not be used for Ansible Collections.
pull/59896/head
Matt Clay 5 years ago committed by GitHub
parent 709a8c5026
commit 18867847f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,6 +23,6 @@ include MANIFEST.in
include changelogs/CHANGELOG*.rst
include contrib/README.md
recursive-include contrib/inventory *
exclude test/lib/ansible_test/_data/sanity/code-smell/botmeta.*
exclude test/sanity/code-smell/botmeta.*
recursive-include hacking/build_library *.py
include hacking/build-ansible.py

@ -15,7 +15,7 @@ This test can error in the following ways:
added, this error should go away.
* A file has a _BUNDLED_METADATA variable but the file isn't specified in
:file:`test/lib/ansible_test/_data/sanity/code-smell/update-bundled.py`. This typically happens when a new bundled
:file:`test/sanity/code-smell/update-bundled.py`. This typically happens when a new bundled
library is added. Add the file to the `get_bundled_libs()` function in the `update-bundled.py`
test script to solve this error.

@ -1,9 +0,0 @@
azure-requirements.py
botmeta.py
changelog.py
configure-remoting-ps1.py
deprecated-config.py
docs-build.py
test-constraints.py
update-bundled.py
package-data.py

@ -209,21 +209,17 @@ def command_sanity(args):
raise ApplicationError(message)
def collect_code_smell_tests():
"""
:rtype: tuple[SanityFunc]
"""
skip_file = os.path.join(SANITY_ROOT, 'code-smell', 'skip.txt')
ansible_only_file = os.path.join(SANITY_ROOT, 'code-smell', 'ansible-only.txt')
skip_tests = read_lines_without_comments(skip_file, remove_blank_lines=True, optional=True)
if not data_context().content.is_ansible:
skip_tests += read_lines_without_comments(ansible_only_file, remove_blank_lines=True)
def collect_code_smell_tests(): # type: () -> t.Tuple[SanityFunc, ...]
"""Return a tuple of available code smell sanity tests."""
paths = glob.glob(os.path.join(SANITY_ROOT, 'code-smell', '*.py'))
paths = sorted(p for p in paths if os.access(p, os.X_OK) and os.path.isfile(p) and os.path.basename(p) not in skip_tests)
if data_context().content.is_ansible:
# include Ansible specific code-smell tests which are not configured to be skipped
ansible_code_smell_root = os.path.join(data_context().content.root, 'test', 'sanity', 'code-smell')
skip_tests = read_lines_without_comments(os.path.join(ansible_code_smell_root, 'skip.txt'), remove_blank_lines=True, optional=True)
paths.extend(path for path in glob.glob(os.path.join(ansible_code_smell_root, '*.py')) if os.path.basename(path) not in skip_tests)
paths = sorted(p for p in paths if os.access(p, os.X_OK) and os.path.isfile(p))
tests = tuple(SanityCodeSmellTest(p) for p in paths)
return tests

@ -132,7 +132,7 @@ def main():
for filename in files_with_bundled_metadata.difference(bundled_libs):
print('{0}: ERROR: File contains _BUNDLED_METADATA but needs to be added to'
' test/lib/ansible_test/_data/sanity/code-smell/update-bundled.py'.format(filename))
' test/sanity/code-smell/update-bundled.py'.format(filename))
for filename in bundled_libs:
try:
Loading…
Cancel
Save