Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-2.14] ansible-test - Remove obsolete DirectoryTarget. #79975

Merged
merged 1 commit into from Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -240,8 +240,8 @@ def check_posix_targets(self, args: SanityConfig) -> list[SanityMessage]:
clouds = get_cloud_platforms(args, posix_targets)
cloud_targets = ['cloud/%s/' % cloud for cloud in clouds]

all_cloud_targets = tuple(filter_targets(posix_targets, ['cloud/'], directories=False, errors=False))
invalid_cloud_targets = tuple(filter_targets(all_cloud_targets, cloud_targets, include=False, directories=False, errors=False))
all_cloud_targets = tuple(filter_targets(posix_targets, ['cloud/'], errors=False))
invalid_cloud_targets = tuple(filter_targets(all_cloud_targets, cloud_targets, include=False, errors=False))

messages = []

Expand All @@ -254,13 +254,13 @@ def check_posix_targets(self, args: SanityConfig) -> list[SanityMessage]:
messages.append(SanityMessage('invalid alias `%s`' % alias, '%s/aliases' % target.path))

messages += self.check_ci_group(
targets=tuple(filter_targets(posix_targets, ['cloud/', '%s/generic/' % self.TEST_ALIAS_PREFIX], include=False, directories=False, errors=False)),
targets=tuple(filter_targets(posix_targets, ['cloud/', '%s/generic/' % self.TEST_ALIAS_PREFIX], include=False, errors=False)),
find=self.format_test_group_alias('linux').replace('linux', 'posix'),
find_incidental=['%s/posix/incidental/' % self.TEST_ALIAS_PREFIX],
)

messages += self.check_ci_group(
targets=tuple(filter_targets(posix_targets, ['%s/generic/' % self.TEST_ALIAS_PREFIX], directories=False, errors=False)),
targets=tuple(filter_targets(posix_targets, ['%s/generic/' % self.TEST_ALIAS_PREFIX], errors=False)),
find=self.format_test_group_alias('generic'),
)

Expand All @@ -273,7 +273,7 @@ def check_posix_targets(self, args: SanityConfig) -> list[SanityMessage]:
find_incidental = ['%s/%s/incidental/' % (self.TEST_ALIAS_PREFIX, cloud), '%s/cloud/incidental/' % self.TEST_ALIAS_PREFIX]

messages += self.check_ci_group(
targets=tuple(filter_targets(posix_targets, ['cloud/%s/' % cloud], directories=False, errors=False)),
targets=tuple(filter_targets(posix_targets, ['cloud/%s/' % cloud], errors=False)),
find=find,
find_incidental=find_incidental,
)
Expand Down Expand Up @@ -331,11 +331,11 @@ def check_ci_group(
) -> list[SanityMessage]:
"""Check the CI groups set in the provided targets and return a list of messages with any issues found."""
all_paths = set(target.path for target in targets)
supported_paths = set(target.path for target in filter_targets(targets, [find], directories=False, errors=False))
unsupported_paths = set(target.path for target in filter_targets(targets, [self.UNSUPPORTED], directories=False, errors=False))
supported_paths = set(target.path for target in filter_targets(targets, [find], errors=False))
unsupported_paths = set(target.path for target in filter_targets(targets, [self.UNSUPPORTED], errors=False))

if find_incidental:
incidental_paths = set(target.path for target in filter_targets(targets, find_incidental, directories=False, errors=False))
incidental_paths = set(target.path for target in filter_targets(targets, find_incidental, errors=False))
else:
incidental_paths = set()

Expand Down
24 changes: 5 additions & 19 deletions test/lib/ansible_test/_internal/target.py
Expand Up @@ -73,23 +73,22 @@ def walk_internal_targets(
"""Return a tuple of matching completion targets."""
targets = tuple(targets)

include_targets = sorted(filter_targets(targets, includes, directories=False), key=lambda include_target: include_target.name)
include_targets = sorted(filter_targets(targets, includes), key=lambda include_target: include_target.name)

if requires:
require_targets = set(filter_targets(targets, requires, directories=False))
require_targets = set(filter_targets(targets, requires))
include_targets = [require_target for require_target in include_targets if require_target in require_targets]

if excludes:
list(filter_targets(targets, excludes, include=False, directories=False))
list(filter_targets(targets, excludes, include=False))

internal_targets = set(filter_targets(include_targets, excludes, errors=False, include=False, directories=False))
internal_targets = set(filter_targets(include_targets, excludes, errors=False, include=False))
return tuple(sorted(internal_targets, key=lambda sort_target: sort_target.name))


def filter_targets(targets: c.Iterable[TCompletionTarget],
patterns: list[str],
include: bool = True,
directories: bool = True,
errors: bool = True,
) -> c.Iterable[TCompletionTarget]:
"""Iterate over the given targets and filter them based on the supplied arguments."""
Expand Down Expand Up @@ -130,10 +129,7 @@ def filter_targets(targets: c.Iterable[TCompletionTarget],
if match != include:
continue

if directories and matched_directories:
yield DirectoryTarget(to_text(sorted(matched_directories, key=len)[0]), target.modules)
else:
yield target
yield target

if errors:
if unmatched:
Expand Down Expand Up @@ -441,16 +437,6 @@ def __repr__(self):
return self.name


class DirectoryTarget(CompletionTarget):
"""Directory target."""
def __init__(self, path: str, modules: tuple[str, ...]) -> None:
super().__init__()

self.name = path
self.path = path
self.modules = modules


class TestTarget(CompletionTarget):
"""Generic test target."""
def __init__(
Expand Down