Update ansible-test to properly skip unit tests.
Unit tests will no longer run on "remote only" Python versions (2.6) for tests which are not "remote" (modules and module_utils).
This commit is contained in:
parent
32fa4b15d1
commit
f944bd2358
5 changed files with 28 additions and 12 deletions
|
@ -60,6 +60,7 @@ from lib.util import (
|
|||
cmd_quote,
|
||||
ANSIBLE_ROOT,
|
||||
get_available_python_versions,
|
||||
is_subdir,
|
||||
)
|
||||
|
||||
from lib.util_common import (
|
||||
|
@ -134,6 +135,10 @@ from lib.data import (
|
|||
data_context,
|
||||
)
|
||||
|
||||
REMOTE_ONLY_PYTHON_VERSIONS = (
|
||||
'2.6',
|
||||
)
|
||||
|
||||
SUPPORTED_PYTHON_VERSIONS = (
|
||||
'2.6',
|
||||
'2.7',
|
||||
|
@ -1324,7 +1329,15 @@ def command_units(args):
|
|||
require = args.require + changes
|
||||
include = walk_internal_targets(walk_units_targets(), args.include, args.exclude, require)
|
||||
|
||||
if not include:
|
||||
paths = [target.path for target in include]
|
||||
remote_paths = [path for path in paths
|
||||
if is_subdir(path, data_context().content.unit_module_path)
|
||||
or is_subdir(path, data_context().content.unit_module_utils_path)]
|
||||
|
||||
if not paths:
|
||||
raise AllTargetsSkipped()
|
||||
|
||||
if args.python and args.python in REMOTE_ONLY_PYTHON_VERSIONS and not remote_paths:
|
||||
raise AllTargetsSkipped()
|
||||
|
||||
if args.delegate:
|
||||
|
@ -1379,7 +1392,15 @@ def command_units(args):
|
|||
if args.verbosity:
|
||||
cmd.append('-' + ('v' * args.verbosity))
|
||||
|
||||
cmd += [target.path for target in include]
|
||||
if version in REMOTE_ONLY_PYTHON_VERSIONS:
|
||||
test_paths = remote_paths
|
||||
else:
|
||||
test_paths = paths
|
||||
|
||||
if not test_paths:
|
||||
continue
|
||||
|
||||
cmd.extend(test_paths)
|
||||
|
||||
version_commands.append((version, cmd, env))
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ class ContentLayout(Layout):
|
|||
util_path=None, # type: t.Optional[str]
|
||||
unit_path=None, # type: t.Optional[str]
|
||||
unit_module_path=None, # type: t.Optional[str]
|
||||
unit_module_utils_path=None, # type: t.Optional[str]
|
||||
integration_path=None, # type: t.Optional[str]
|
||||
): # type: (...) -> None
|
||||
super(ContentLayout, self).__init__(root, paths)
|
||||
|
@ -91,6 +92,7 @@ class ContentLayout(Layout):
|
|||
self.util_path = util_path
|
||||
self.unit_path = unit_path
|
||||
self.unit_module_path = unit_module_path
|
||||
self.unit_module_utils_path = unit_module_utils_path
|
||||
self.integration_path = integration_path
|
||||
self.is_ansible = root == ANSIBLE_ROOT
|
||||
|
||||
|
|
|
@ -41,5 +41,6 @@ class AnsibleLayout(LayoutProvider):
|
|||
util_path='test/utils',
|
||||
unit_path='test/units',
|
||||
unit_module_path='test/units/modules',
|
||||
unit_module_utils_path='test/units/module_utils',
|
||||
integration_path='test/integration',
|
||||
)
|
||||
|
|
|
@ -55,6 +55,7 @@ class CollectionLayout(LayoutProvider):
|
|||
),
|
||||
util_path='test/util',
|
||||
unit_path='test/unit',
|
||||
unit_module_path='test/units/plugins/modules',
|
||||
unit_module_path='test/unit/plugins/modules',
|
||||
unit_module_utils_path='test/unit/plugins/module_utils',
|
||||
integration_path='test/integration',
|
||||
)
|
||||
|
|
|
@ -15,14 +15,5 @@ fi
|
|||
|
||||
ansible-test env --timeout "${timeout}" --color -v
|
||||
|
||||
if [[ "${version}" = "2.6" ]]; then
|
||||
# Python 2.6 is only supported for modules and module_utils.
|
||||
# Eventually this logic will move into ansible-test itself.
|
||||
targets=("test/units/(modules|module_utils)/")
|
||||
else
|
||||
targets=("test/units/")
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
ansible-test units --color -v --docker default --python "${version}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \
|
||||
"${targets[@]}" \
|
||||
|
|
Loading…
Reference in a new issue