Fix ansible-test python and pip executable search.

This commit is contained in:
Matt Clay 2018-03-14 11:35:59 -07:00
parent dd37857884
commit a8487feb70
14 changed files with 81 additions and 75 deletions

View file

@ -221,7 +221,11 @@ class SanityCodeSmellTest(SanityTest):
:type targets: SanityTargets
:rtype: SanityResult
"""
cmd = [self.path]
if self.path.endswith('.py'):
cmd = [args.python_executable, self.path]
else:
cmd = [self.path]
env = ansible_environment(args, color=False)
pattern = None

View file

@ -16,6 +16,7 @@ from lib.util import (
SubprocessError,
run_command,
display,
find_python,
)
from lib.config import (
@ -50,7 +51,7 @@ class CompileTest(SanityMultipleVersion):
if not paths:
return SanitySkipped(self.name, python_version=python_version)
cmd = ['python%s' % python_version, 'test/sanity/compile/compile.py']
cmd = [find_python(python_version), 'test/sanity/compile/compile.py']
data = '\n'.join(paths)

View file

@ -18,6 +18,7 @@ from lib.util import (
intercept_command,
remove_tree,
display,
find_python,
)
from lib.ansible_util import (
@ -66,7 +67,7 @@ class ImportTest(SanityMultipleVersion):
remove_tree(virtual_environment_path)
cmd = ['virtualenv', virtual_environment_path, '--python', 'python%s' % python_version, '--no-setuptools', '--no-wheel']
cmd = ['virtualenv', virtual_environment_path, '--python', find_python(python_version), '--no-setuptools', '--no-wheel']
if not args.coverage:
cmd.append('--no-pip')
@ -84,8 +85,8 @@ class ImportTest(SanityMultipleVersion):
# make sure coverage is available in the virtual environment if needed
if args.coverage:
run_command(args, generate_pip_install('pip', 'sanity.import', packages=['setuptools']), env=env)
run_command(args, generate_pip_install('pip', 'sanity.import', packages=['coverage']), env=env)
run_command(args, generate_pip_install(['pip'], 'sanity.import', packages=['setuptools']), env=env)
run_command(args, generate_pip_install(['pip'], 'sanity.import', packages=['coverage']), env=env)
run_command(args, ['pip', 'uninstall', '--disable-pip-version-check', '-y', 'setuptools'], env=env)
run_command(args, ['pip', 'uninstall', '--disable-pip-version-check', '-y', 'pip'], env=env)

View file

@ -15,7 +15,6 @@ from lib.util import (
SubprocessError,
display,
run_command,
find_executable,
)
from lib.config import (
@ -56,8 +55,8 @@ class Pep8Test(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)
cmd = [
'python%s' % args.python_version,
find_executable('pycodestyle'),
args.python_executable,
'-m', 'pycodestyle',
'--max-line-length', '160',
'--config', '/dev/null',
'--ignore', ','.join(sorted(current_ignore)),

View file

@ -252,8 +252,8 @@ class PylintTest(SanitySingleVersion):
load_plugins = set(self.plugin_names) - disable_plugins
cmd = [
'python%s' % args.python_version,
find_executable('pylint'),
args.python_executable,
'-m', 'pylint',
'--jobs', '0',
'--reports', 'n',
'--max-line-length', '160',

View file

@ -15,6 +15,7 @@ from lib.util import (
SubprocessError,
run_command,
parse_to_dict,
display,
find_executable,
)
@ -22,6 +23,10 @@ from lib.config import (
SanityConfig,
)
UNSUPPORTED_PYTHON_VERSIONS = (
'2.6',
)
class RstcheckTest(SanitySingleVersion):
"""Sanity test using rstcheck."""
@ -31,6 +36,10 @@ class RstcheckTest(SanitySingleVersion):
:type targets: SanityTargets
:rtype: SanityResult
"""
if args.python_version in UNSUPPORTED_PYTHON_VERSIONS:
display.warning('Skipping rstcheck on unsupported Python version %s.' % args.python_version)
return SanitySkipped(self.name)
with open('test/sanity/rstcheck/ignore-substitutions.txt', 'r') as ignore_fd:
ignore_substitutions = sorted(set(ignore_fd.read().splitlines()))
@ -40,8 +49,8 @@ class RstcheckTest(SanitySingleVersion):
return SanitySkipped(self.name)
cmd = [
'python%s' % args.python_version,
find_executable('rstcheck'),
args.python_executable,
'-m', 'rstcheck',
'--report', 'warning',
'--ignore-substitutions', ','.join(ignore_substitutions),
] + paths

View file

@ -57,7 +57,7 @@ class ValidateModulesTest(SanitySingleVersion):
return SanitySkipped(self.name)
cmd = [
'python%s' % args.python_version,
args.python_executable,
'test/sanity/validate-modules/validate-modules',
'--format', 'json',
'--arg-spec',

View file

@ -65,7 +65,7 @@ class YamllintTest(SanitySingleVersion):
:rtype: list[SanityMessage]
"""
cmd = [
'python%s' % args.python_version,
args.python_executable,
'test/sanity/yamllint/yamllinter.py',
]