mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Handle non-target file deps for integration tests.
Some integration test targets have dependencies on files outside the `test/integration/targets/` directory tree. Changes to these dependencies can result in unexpected test failures since they do not trigger integration tests which depend on them.
This commit is contained in:
parent
3db6b9b416
commit
6a0452559b
7 changed files with 53 additions and 0 deletions
|
@ -1,2 +1,3 @@
|
|||
shippable/cloud/group1
|
||||
cloud/foreman
|
||||
needs/file/contrib/inventory/foreman.py
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
shippable/posix/group2
|
||||
destructive
|
||||
needs/target/setup_openssl
|
||||
needs/file/test/runner/requirements/constraints.txt
|
||||
|
|
1
test/integration/targets/setup_docker/aliases
Normal file
1
test/integration/targets/setup_docker/aliases
Normal file
|
@ -0,0 +1 @@
|
|||
needs/file/test/runner/requirements/constraints.txt
|
|
@ -1 +1,3 @@
|
|||
shippable/posix/group3
|
||||
needs/file/hacking/test-module
|
||||
needs/file/lib/ansible/modules/system/ping.py
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
destructive
|
||||
shippable/posix/group1
|
||||
needs/httptester
|
||||
needs/file/test/runner/requirements/constraints.txt
|
||||
|
|
|
@ -196,7 +196,49 @@ class PathMapper(object):
|
|||
self.powershell_module_utils_imports = {} # populated on first use to reduce overhead when not needed
|
||||
self.csharp_module_utils_imports = {} # populated on first use to reduce overhead when not needed
|
||||
|
||||
self.paths_to_dependent_targets = {}
|
||||
|
||||
for target in self.integration_targets:
|
||||
for path in target.needs_file:
|
||||
if path not in self.paths_to_dependent_targets:
|
||||
self.paths_to_dependent_targets[path] = set()
|
||||
|
||||
self.paths_to_dependent_targets[path].add(target)
|
||||
|
||||
def get_dependent_paths(self, path):
|
||||
"""
|
||||
:type path: str
|
||||
:rtype: list[str]
|
||||
"""
|
||||
unprocessed_paths = set(self.get_dependent_paths_non_recursive(path))
|
||||
paths = set()
|
||||
|
||||
while unprocessed_paths:
|
||||
queued_paths = list(unprocessed_paths)
|
||||
paths |= unprocessed_paths
|
||||
unprocessed_paths = set()
|
||||
|
||||
for queued_path in queued_paths:
|
||||
new_paths = self.get_dependent_paths_non_recursive(queued_path)
|
||||
|
||||
for new_path in new_paths:
|
||||
if new_path not in paths:
|
||||
unprocessed_paths.add(new_path)
|
||||
|
||||
return sorted(paths)
|
||||
|
||||
def get_dependent_paths_non_recursive(self, path):
|
||||
"""
|
||||
:type path: str
|
||||
:rtype: list[str]
|
||||
"""
|
||||
paths = self.get_dependent_paths_internal(path)
|
||||
paths += [t.path + '/' for t in self.paths_to_dependent_targets.get(path, set())]
|
||||
paths = sorted(set(paths))
|
||||
|
||||
return paths
|
||||
|
||||
def get_dependent_paths_internal(self, path):
|
||||
"""
|
||||
:type path: str
|
||||
:rtype: list[str]
|
||||
|
|
|
@ -626,6 +626,11 @@ class IntegrationTarget(CompletionTarget):
|
|||
if self.type not in ('script', 'role'):
|
||||
groups.append('hidden')
|
||||
|
||||
# Collect file paths before group expansion to avoid including the directories.
|
||||
# Ignore references to test targets, as those must be defined using `needs/target/*` or other target references.
|
||||
self.needs_file = tuple(sorted(set('/'.join(g.split('/')[2:]) for g in groups if
|
||||
g.startswith('needs/file/') and not g.startswith('needs/file/test/integration/targets/'))))
|
||||
|
||||
for group in itertools.islice(groups, 0, len(groups)):
|
||||
if '/' in group:
|
||||
parts = group.split('/')
|
||||
|
|
Loading…
Reference in a new issue