1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix bugs in ansible-test units command. (#24044)

* Handle old versions of coverage.
* Handle old versions of setuptools.
* Detect python version for docker/remote units.
* Add sanity override for test constraints.
This commit is contained in:
Matt Clay 2017-04-27 11:21:11 +08:00 committed by GitHub
parent 51e3390333
commit d662f6f0db
6 changed files with 20 additions and 1 deletions

View file

@ -16,6 +16,7 @@ from lib.executor import (
SubprocessError,
ShellConfig,
SanityConfig,
UnitsConfig,
create_shell_command,
)
@ -201,6 +202,10 @@ def delegate_docker(args, exclude, require):
docker_exec(args, test_id, ['mkdir', '/root/ansible'])
docker_exec(args, test_id, ['tar', 'oxzf', '/root/ansible.tgz', '-C', '/root/ansible'])
# docker images are only expected to have a single python version available
if isinstance(args, UnitsConfig) and not args.python:
cmd += ['--python', 'default']
try:
docker_exec(args, test_id, cmd, options=cmd_options)
finally:
@ -356,6 +361,10 @@ def delegate_remote(args, exclude, require):
if not args.allow_destructive:
cmd.append('--allow-destructive')
# remote instances are only expected to have a single python version available
if isinstance(args, UnitsConfig) and not args.python:
cmd += ['--python', 'default']
manage = ManagePosixCI(core_ci)
manage.setup()

View file

@ -477,6 +477,9 @@ class EnvironmentConfig(CommonConfig):
self.requirements = args.requirements # type: bool
if self.python == 'default':
self.python = '.'.join(str(i) for i in sys.version_info[:2])
self.python_version = self.python or '.'.join(str(i) for i in sys.version_info[:2])
self.delegate = self.tox or self.docker or self.remote

View file

@ -12,5 +12,6 @@ pytest-xdist
python-memcached
pyyaml
redis
setuptools > 0.6 # pytest-xdist installed via requirements does not work with very old setuptools (sanity_ok)
unittest2 ; python_version < '2.7'
netaddr

View file

@ -241,7 +241,7 @@ def parse_args():
units.add_argument('--python',
metavar='VERSION',
choices=SUPPORTED_PYTHON_VERSIONS,
choices=SUPPORTED_PYTHON_VERSIONS + ('default',),
help='python version: %s' % ', '.join(SUPPORTED_PYTHON_VERSIONS))
units.add_argument('--collect-only',

View file

@ -2,6 +2,7 @@
constraints=$(
grep '.' test/runner/requirements/*.txt \
| grep -v '(sanity_ok)$' \
| sed 's/ *;.*$//; s/ #.*$//' \
| grep -v '/constraints.txt:' \
| grep '[<>=]'

View file

@ -7,6 +7,11 @@ try:
except ImportError:
coverage = None
try:
test = coverage.Coverage
except AttributeError:
coverage = None
def pytest_configure():
if not coverage: