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.
This commit is contained in:
Matt Clay 2019-08-06 17:17:57 -07:00 committed by GitHub
parent 709a8c5026
commit 18867847f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 12 additions and 25 deletions

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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: