Sanity test fixes for future collections support.
This commit is contained in:
parent
9e1b19e364
commit
520af5cb47
4 changed files with 26 additions and 26 deletions
|
@ -17,6 +17,7 @@ from lib.util import (
|
|||
load_plugins,
|
||||
parse_to_list_of_dict,
|
||||
ABC,
|
||||
INSTALL_ROOT,
|
||||
is_binary_file,
|
||||
read_lines_without_comments,
|
||||
)
|
||||
|
@ -138,9 +139,9 @@ def collect_code_smell_tests():
|
|||
:rtype: tuple[SanityCodeSmellTest]
|
||||
"""
|
||||
skip_file = 'test/sanity/code-smell/skip.txt'
|
||||
skip_tests = read_lines_without_comments(skip_file, remove_blank_lines=True)
|
||||
skip_tests = read_lines_without_comments(skip_file, remove_blank_lines=True, optional=True)
|
||||
|
||||
paths = glob.glob('test/sanity/code-smell/*')
|
||||
paths = glob.glob(os.path.join(INSTALL_ROOT, 'test/sanity/code-smell/*'))
|
||||
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)
|
||||
|
||||
tests = tuple(SanityCodeSmellTest(p) for p in paths)
|
||||
|
|
|
@ -18,6 +18,7 @@ from lib.util import (
|
|||
find_python,
|
||||
read_lines_without_comments,
|
||||
parse_to_list_of_dict,
|
||||
INSTALL_ROOT,
|
||||
)
|
||||
|
||||
from lib.config import (
|
||||
|
@ -50,7 +51,7 @@ class CompileTest(SanityMultipleVersion):
|
|||
if not paths:
|
||||
return SanitySkipped(self.name, python_version=python_version)
|
||||
|
||||
cmd = [find_python(python_version), 'test/sanity/compile/compile.py']
|
||||
cmd = [find_python(python_version), os.path.join(INSTALL_ROOT, 'test/sanity/compile/compile.py')]
|
||||
|
||||
data = '\n'.join(paths)
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ import json
|
|||
import os
|
||||
import datetime
|
||||
|
||||
import lib.types as t
|
||||
|
||||
from lib.sanity import (
|
||||
SanitySingleVersion,
|
||||
SanityMessage,
|
||||
|
@ -21,6 +23,7 @@ from lib.util import (
|
|||
display,
|
||||
read_lines_without_comments,
|
||||
ConfigParser,
|
||||
INSTALL_ROOT,
|
||||
)
|
||||
|
||||
from lib.executor import (
|
||||
|
@ -51,12 +54,6 @@ UNSUPPORTED_PYTHON_VERSIONS = (
|
|||
|
||||
class PylintTest(SanitySingleVersion):
|
||||
"""Sanity test using pylint."""
|
||||
def __init__(self):
|
||||
super(PylintTest, self).__init__()
|
||||
|
||||
self.plugin_dir = 'test/sanity/pylint/plugins'
|
||||
self.plugin_names = sorted(p[0] for p in [os.path.splitext(p) for p in os.listdir(self.plugin_dir)] if p[1] == '.py' and p[0] != '__init__')
|
||||
|
||||
def test(self, args, targets):
|
||||
"""
|
||||
:type args: SanityConfig
|
||||
|
@ -67,14 +64,18 @@ class PylintTest(SanitySingleVersion):
|
|||
display.warning('Skipping pylint on unsupported Python version %s.' % args.python_version)
|
||||
return SanitySkipped(self.name)
|
||||
|
||||
skip_paths = read_lines_without_comments(PYLINT_SKIP_PATH)
|
||||
plugin_dir = os.path.join(INSTALL_ROOT, 'test/sanity/pylint/plugins')
|
||||
plugin_names = sorted(p[0] for p in [
|
||||
os.path.splitext(p) for p in os.listdir(plugin_dir)] if p[1] == '.py' and p[0] != '__init__')
|
||||
|
||||
skip_paths = read_lines_without_comments(PYLINT_SKIP_PATH, optional=True)
|
||||
|
||||
invalid_ignores = []
|
||||
|
||||
supported_versions = set(SUPPORTED_PYTHON_VERSIONS) - set(UNSUPPORTED_PYTHON_VERSIONS)
|
||||
supported_versions = set([v.split('.')[0] for v in supported_versions]) | supported_versions
|
||||
|
||||
ignore_entries = read_lines_without_comments(PYLINT_IGNORE_PATH)
|
||||
ignore_entries = read_lines_without_comments(PYLINT_IGNORE_PATH, optional=True)
|
||||
ignore = collections.defaultdict(dict)
|
||||
line = 0
|
||||
|
||||
|
@ -172,7 +173,7 @@ class PylintTest(SanitySingleVersion):
|
|||
continue
|
||||
|
||||
context_start = datetime.datetime.utcnow()
|
||||
messages += self.pylint(args, context, context_paths)
|
||||
messages += self.pylint(args, context, context_paths, plugin_dir, plugin_names)
|
||||
context_end = datetime.datetime.utcnow()
|
||||
|
||||
context_times.append('%s: %d (%s)' % (context, len(context_paths), context_end - context_start))
|
||||
|
@ -259,17 +260,13 @@ class PylintTest(SanitySingleVersion):
|
|||
|
||||
return SanitySuccess(self.name)
|
||||
|
||||
def pylint(self, args, context, paths):
|
||||
"""
|
||||
:type args: SanityConfig
|
||||
:type context: str
|
||||
:type paths: list[str]
|
||||
:rtype: list[dict[str, str]]
|
||||
"""
|
||||
rcfile = 'test/sanity/pylint/config/%s' % context.split('/')[0]
|
||||
@staticmethod
|
||||
def pylint(args, context, paths, plugin_dir, plugin_names): # type: (SanityConfig, str, t.List[str], str, t.List[str]) -> t.List[t.Dict[str, str]]
|
||||
"""Run pylint using the config specified by the context on the specified paths."""
|
||||
rcfile = os.path.join(INSTALL_ROOT, 'test/sanity/pylint/config/%s' % context.split('/')[0])
|
||||
|
||||
if not os.path.exists(rcfile):
|
||||
rcfile = 'test/sanity/pylint/config/default'
|
||||
rcfile = os.path.join(INSTALL_ROOT, 'test/sanity/pylint/config/default')
|
||||
|
||||
parser = ConfigParser()
|
||||
parser.read(rcfile)
|
||||
|
@ -280,7 +277,7 @@ class PylintTest(SanitySingleVersion):
|
|||
config = dict()
|
||||
|
||||
disable_plugins = set(i.strip() for i in config.get('disable-plugins', '').split(',') if i)
|
||||
load_plugins = set(self.plugin_names) - disable_plugins
|
||||
load_plugins = set(plugin_names) - disable_plugins
|
||||
|
||||
cmd = [
|
||||
args.python_executable,
|
||||
|
@ -294,7 +291,7 @@ class PylintTest(SanitySingleVersion):
|
|||
] + paths
|
||||
|
||||
env = ansible_environment(args)
|
||||
env['PYTHONPATH'] += '%s%s' % (os.path.pathsep, self.plugin_dir)
|
||||
env['PYTHONPATH'] += '%s%s' % (os.path.pathsep, plugin_dir)
|
||||
|
||||
if paths:
|
||||
display.info('Checking %d file(s) in context "%s" with config: %s' % (len(paths), context, rcfile), verbosity=1)
|
||||
|
|
|
@ -18,6 +18,7 @@ from lib.util import (
|
|||
display,
|
||||
run_command,
|
||||
read_lines_without_comments,
|
||||
INSTALL_ROOT,
|
||||
)
|
||||
|
||||
from lib.ansible_util import (
|
||||
|
@ -54,7 +55,7 @@ class ValidateModulesTest(SanitySingleVersion):
|
|||
display.warning('Skipping validate-modules on unsupported Python version %s.' % args.python_version)
|
||||
return SanitySkipped(self.name)
|
||||
|
||||
skip_paths = read_lines_without_comments(VALIDATE_SKIP_PATH)
|
||||
skip_paths = read_lines_without_comments(VALIDATE_SKIP_PATH, optional=True)
|
||||
skip_paths_set = set(skip_paths)
|
||||
|
||||
env = ansible_environment(args, color=False)
|
||||
|
@ -66,14 +67,14 @@ class ValidateModulesTest(SanitySingleVersion):
|
|||
|
||||
cmd = [
|
||||
args.python_executable,
|
||||
'test/sanity/validate-modules/validate-modules',
|
||||
os.path.join(INSTALL_ROOT, 'test/sanity/validate-modules/validate-modules'),
|
||||
'--format', 'json',
|
||||
'--arg-spec',
|
||||
] + paths
|
||||
|
||||
invalid_ignores = []
|
||||
|
||||
ignore_entries = read_lines_without_comments(VALIDATE_IGNORE_PATH)
|
||||
ignore_entries = read_lines_without_comments(VALIDATE_IGNORE_PATH, optional=True)
|
||||
ignore = collections.defaultdict(dict)
|
||||
line = 0
|
||||
|
||||
|
|
Loading…
Reference in a new issue