diff options
-rw-r--r-- | docs/docsite/rst/dev_guide/testing/sanity/package-data.rst | 5 | ||||
-rw-r--r-- | setup.py | 1 | ||||
-rw-r--r-- | test/sanity/code-smell/ansible-only.txt | 1 | ||||
-rw-r--r-- | test/sanity/code-smell/package-data.json | 5 | ||||
-rwxr-xr-x | test/sanity/code-smell/package-data.py | 48 | ||||
-rwxr-xr-x | test/utils/shippable/sanity.sh | 2 |
6 files changed, 61 insertions, 1 deletions
diff --git a/docs/docsite/rst/dev_guide/testing/sanity/package-data.rst b/docs/docsite/rst/dev_guide/testing/sanity/package-data.rst new file mode 100644 index 0000000000..361dacbeb9 --- /dev/null +++ b/docs/docsite/rst/dev_guide/testing/sanity/package-data.rst @@ -0,0 +1,5 @@ +Sanity Tests ยป package-data +=========================== + +Verifies that the combination of ``MANIFEST.in`` and ``package_data`` from ``setup.py`` +properly installs data files from within ``lib/ansible`` @@ -271,6 +271,7 @@ static_setup_params = dict( 'galaxy/data/*/*/.*', 'galaxy/data/*/*/*.*', 'galaxy/data/*/tests/inventory', + 'galaxy/data/*/role/tests/inventory', 'config/base.yml', 'config/module_defaults.yml', ], diff --git a/test/sanity/code-smell/ansible-only.txt b/test/sanity/code-smell/ansible-only.txt index d713d89f39..14c45f0799 100644 --- a/test/sanity/code-smell/ansible-only.txt +++ b/test/sanity/code-smell/ansible-only.txt @@ -6,3 +6,4 @@ deprecated-config.py docs-build.py test-constraints.py update-bundled.py +package-data.py diff --git a/test/sanity/code-smell/package-data.json b/test/sanity/code-smell/package-data.json new file mode 100644 index 0000000000..db6ca35c2a --- /dev/null +++ b/test/sanity/code-smell/package-data.json @@ -0,0 +1,5 @@ +{ + "disabled": true, + "always": true, + "output": "path-message" +} diff --git a/test/sanity/code-smell/package-data.py b/test/sanity/code-smell/package-data.py new file mode 100755 index 0000000000..e17059329e --- /dev/null +++ b/test/sanity/code-smell/package-data.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import fnmatch +import os +import re +import tempfile +import subprocess + + +def main(): + ignore_files = frozenset(( + '*/.git_keep', + '*/galaxy/data/default/role/*/main.yml.j2', + '*/galaxy/data/default/role/*/test.yml.j2', + '*/galaxy/data/default/collection/plugins/README.md.j2', + )) + + non_py_files = [] + for root, _dummy, files in os.walk('lib/ansible/'): + for filename in files: + path = os.path.join(root, filename) + if os.path.splitext(path)[1] not in ('.py', '.pyc', '.pyo'): + add = True + for ignore in ignore_files: + if fnmatch.fnmatch(path, ignore): + add = False + if add: + non_py_files.append(os.path.relpath(path, 'lib/ansible')) + + with tempfile.TemporaryDirectory() as tmp_dir: + stdout, _dummy = subprocess.Popen( + ['python', 'setup.py', 'install', '--root=%s' % tmp_dir], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True, + ).communicate() + match = re.search('^creating (%s/.*?/(?:site|dist)-packages/ansible)$' % tmp_dir, stdout, flags=re.M) + + for filename in non_py_files: + path = os.path.join(match.group(1), filename) + if not os.path.exists(path): + print('%s: File not installed' % os.path.join('lib', 'ansible', filename)) + + +if __name__ == '__main__': + main() diff --git a/test/utils/shippable/sanity.sh b/test/utils/shippable/sanity.sh index 734d39c991..09d859b363 100755 --- a/test/utils/shippable/sanity.sh +++ b/test/utils/shippable/sanity.sh @@ -17,7 +17,7 @@ fi case "${group}" in 1) options=(--skip-test pylint --skip-test ansible-doc --skip-test docs-build) ;; - 2) options=(--test ansible-doc --test docs-build) ;; + 2) options=(--test ansible-doc --test docs-build --test package-data) ;; 3) options=(--test pylint --exclude test/units/ --exclude lib/ansible/module_utils/ --exclude lib/ansible/modules/network/) ;; 4) options=(--test pylint test/units/ lib/ansible/module_utils/ lib/ansible/modules/network/) ;; esac |