summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2018-10-13 23:58:50 -0700
committerMatt Clay <matt@mystile.com>2018-11-05 14:49:13 -0800
commit6320bf10416be72539a0146dc07c328c50e202f5 (patch)
tree1036445996d60f0c8d372801386aff3fae30bb2b
parente4ae98f83e2b77a2f815ca320e94e0e2279f62f5 (diff)
downloadansible-6320bf10416be72539a0146dc07c328c50e202f5.tar.gz
Split pylint runs into more contexts.
(cherry picked from commit ad940b86e4e8a3abba86bf8a935f4e364f8e0821) See: https://github.com/ansible/ansible/pull/47036/
-rw-r--r--test/runner/lib/sanity/pylint.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/test/runner/lib/sanity/pylint.py b/test/runner/lib/sanity/pylint.py
index 9657ddb33e..02f9b7544c 100644
--- a/test/runner/lib/sanity/pylint.py
+++ b/test/runner/lib/sanity/pylint.py
@@ -108,7 +108,10 @@ class PylintTest(SanitySingleVersion):
paths = sorted(i.path for i in targets.include if (os.path.splitext(i.path)[1] == '.py' or i.path.startswith('bin/')) and i.path not in skip_paths_set)
- contexts = {}
+ module_paths = [p.split(os.path.sep) for p in paths if p.startswith('lib/ansible/modules/')]
+ module_dirs = sorted(set([p[3] for p in module_paths if len(p) > 4]))
+
+ contexts = []
remaining_paths = set(paths)
def add_context(available_paths, context_name, context_filter):
@@ -118,7 +121,7 @@ class PylintTest(SanitySingleVersion):
:type context_filter: (str) -> bool
"""
filtered_paths = set(p for p in available_paths if context_filter(p))
- contexts[context_name] = sorted(filtered_paths)
+ contexts.append((context_name, sorted(filtered_paths)))
available_paths -= filtered_paths
def filter_path(path_filter=None):
@@ -139,6 +142,10 @@ class PylintTest(SanitySingleVersion):
add_context(remaining_paths, 'units', filter_path('test/units/'))
add_context(remaining_paths, 'test', filter_path('test/'))
add_context(remaining_paths, 'hacking', filter_path('hacking/'))
+
+ for module_dir in module_dirs:
+ add_context(remaining_paths, 'modules/%s' % module_dir, filter_path('lib/ansible/modules/%s/' % module_dir))
+
add_context(remaining_paths, 'modules', filter_path('lib/ansible/modules/'))
add_context(remaining_paths, 'module_utils', filter_path('lib/ansible/module_utils/'))
add_context(remaining_paths, 'ansible', lambda p: True)
@@ -148,9 +155,7 @@ class PylintTest(SanitySingleVersion):
test_start = datetime.datetime.utcnow()
- for context in sorted(contexts):
- context_paths = contexts[context]
-
+ for context, context_paths in sorted(contexts):
if not context_paths:
continue
@@ -249,7 +254,7 @@ class PylintTest(SanitySingleVersion):
:type paths: list[str]
:rtype: list[dict[str, str]]
"""
- rcfile = 'test/sanity/pylint/config/%s' % context
+ rcfile = 'test/sanity/pylint/config/%s' % context.split('/')[0]
if not os.path.exists(rcfile):
rcfile = 'test/sanity/pylint/config/default'
@@ -280,6 +285,8 @@ class PylintTest(SanitySingleVersion):
env['PYTHONPATH'] += '%s%s' % (os.path.pathsep, self.plugin_dir)
if paths:
+ display.info('Checking %d file(s) in context "%s" with config: %s' % (len(paths), context, rcfile), verbosity=1)
+
try:
stdout, stderr = run_command(args, cmd, env=env, capture=True)
status = 0