Fix plugin paths for ansible-test pylint test. (#65526)
* Fix plugin paths for ansible-test pylint test.
This commit is contained in:
parent
4d3ebd65db
commit
fb69d68821
3 changed files with 11 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- ansible-test now properly recognizes modules and module_utils in collections when using the ``blacklist`` plugin for the ``pylint`` sanity test
|
|
@ -3,11 +3,16 @@ from __future__ import (absolute_import, division, print_function)
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
import astroid
|
import astroid
|
||||||
|
|
||||||
from pylint.checkers import BaseChecker
|
from pylint.checkers import BaseChecker
|
||||||
from pylint.interfaces import IAstroidChecker
|
from pylint.interfaces import IAstroidChecker
|
||||||
|
|
||||||
|
ANSIBLE_TEST_MODULES_PATH = os.environ['ANSIBLE_TEST_MODULES_PATH']
|
||||||
|
ANSIBLE_TEST_MODULE_UTILS_PATH = os.environ['ANSIBLE_TEST_MODULE_UTILS_PATH']
|
||||||
|
|
||||||
|
|
||||||
class BlacklistEntry:
|
class BlacklistEntry:
|
||||||
"""Defines a import blacklist entry."""
|
"""Defines a import blacklist entry."""
|
||||||
|
@ -50,7 +55,7 @@ def is_module_path(path):
|
||||||
:type path: str
|
:type path: str
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
"""
|
"""
|
||||||
return '/lib/ansible/modules/' in path or '/lib/ansible/module_utils/' in path
|
return path.startswith(ANSIBLE_TEST_MODULES_PATH) or path.startswith(ANSIBLE_TEST_MODULE_UTILS_PATH)
|
||||||
|
|
||||||
|
|
||||||
class AnsibleBlacklistChecker(BaseChecker):
|
class AnsibleBlacklistChecker(BaseChecker):
|
||||||
|
|
|
@ -224,6 +224,9 @@ class PylintTest(SanitySingleVersion):
|
||||||
env = ansible_environment(args)
|
env = ansible_environment(args)
|
||||||
env['PYTHONPATH'] += os.path.pathsep + os.path.pathsep.join(append_python_path)
|
env['PYTHONPATH'] += os.path.pathsep + os.path.pathsep.join(append_python_path)
|
||||||
|
|
||||||
|
# expose plugin paths for use in custom plugins
|
||||||
|
env.update(dict(('ANSIBLE_TEST_%s_PATH' % k.upper(), os.path.abspath(v) + os.path.sep) for k, v in data_context().content.plugin_paths.items()))
|
||||||
|
|
||||||
if paths:
|
if paths:
|
||||||
display.info('Checking %d file(s) in context "%s" with config: %s' % (len(paths), context, rcfile), verbosity=1)
|
display.info('Checking %d file(s) in context "%s" with config: %s' % (len(paths), context, rcfile), verbosity=1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue