2016-11-30 06:21:53 +01:00
|
|
|
"""Classify changes in Ansible code."""
|
2019-07-12 08:46:20 +02:00
|
|
|
from __future__ import (absolute_import, division, print_function)
|
|
|
|
__metaclass__ = type
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2018-04-13 01:15:28 +02:00
|
|
|
import collections
|
2016-11-30 06:21:53 +01:00
|
|
|
import os
|
2018-04-10 21:00:14 +02:00
|
|
|
import re
|
2017-02-14 03:49:36 +01:00
|
|
|
import time
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
from . import types as t
|
|
|
|
|
2019-08-06 23:43:29 +02:00
|
|
|
from .target import (
|
2016-11-30 06:21:53 +01:00
|
|
|
walk_module_targets,
|
|
|
|
walk_integration_targets,
|
|
|
|
walk_units_targets,
|
|
|
|
walk_compile_targets,
|
2016-12-06 16:53:59 +01:00
|
|
|
walk_sanity_targets,
|
2017-01-18 01:24:05 +01:00
|
|
|
load_integration_prefixes,
|
2017-07-11 00:41:32 +02:00
|
|
|
analyze_integration_target_dependencies,
|
2016-11-30 06:21:53 +01:00
|
|
|
)
|
|
|
|
|
2019-08-06 23:43:29 +02:00
|
|
|
from .util import (
|
2016-11-30 06:21:53 +01:00
|
|
|
display,
|
2019-07-23 04:24:48 +02:00
|
|
|
is_subdir,
|
2016-11-30 06:21:53 +01:00
|
|
|
)
|
|
|
|
|
2019-08-06 23:43:29 +02:00
|
|
|
from .import_analysis import (
|
2017-02-14 03:49:36 +01:00
|
|
|
get_python_module_utils_imports,
|
2019-07-23 04:24:48 +02:00
|
|
|
get_python_module_utils_name,
|
2017-02-14 03:49:36 +01:00
|
|
|
)
|
|
|
|
|
2019-08-06 23:43:29 +02:00
|
|
|
from .csharp_import_analysis import (
|
2018-10-03 00:55:53 +02:00
|
|
|
get_csharp_module_utils_imports,
|
2019-07-23 04:24:48 +02:00
|
|
|
get_csharp_module_utils_name,
|
2018-10-03 00:55:53 +02:00
|
|
|
)
|
|
|
|
|
2019-08-06 23:43:29 +02:00
|
|
|
from .powershell_import_analysis import (
|
2017-10-17 20:26:32 +02:00
|
|
|
get_powershell_module_utils_imports,
|
2019-07-23 04:24:48 +02:00
|
|
|
get_powershell_module_utils_name,
|
2017-10-17 20:26:32 +02:00
|
|
|
)
|
|
|
|
|
2019-08-06 23:43:29 +02:00
|
|
|
from .config import (
|
2017-07-15 01:51:32 +02:00
|
|
|
TestConfig,
|
|
|
|
IntegrationConfig,
|
|
|
|
)
|
|
|
|
|
2019-08-06 23:43:29 +02:00
|
|
|
from .metadata import (
|
2018-04-13 01:15:28 +02:00
|
|
|
ChangeDescription,
|
|
|
|
)
|
|
|
|
|
2019-08-06 23:43:29 +02:00
|
|
|
from .data import (
|
2019-07-23 04:24:48 +02:00
|
|
|
data_context,
|
|
|
|
)
|
|
|
|
|
2018-04-13 01:15:28 +02:00
|
|
|
FOCUSED_TARGET = '__focused__'
|
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2017-07-15 01:51:32 +02:00
|
|
|
def categorize_changes(args, paths, verbose_command=None):
|
2016-11-30 06:21:53 +01:00
|
|
|
"""
|
2017-07-15 01:51:32 +02:00
|
|
|
:type args: TestConfig
|
2016-11-30 06:21:53 +01:00
|
|
|
:type paths: list[str]
|
|
|
|
:type verbose_command: str
|
2018-04-13 01:15:28 +02:00
|
|
|
:rtype: ChangeDescription
|
2016-11-30 06:21:53 +01:00
|
|
|
"""
|
2017-07-15 01:51:32 +02:00
|
|
|
mapper = PathMapper(args)
|
2016-11-30 06:21:53 +01:00
|
|
|
|
|
|
|
commands = {
|
|
|
|
'sanity': set(),
|
|
|
|
'units': set(),
|
|
|
|
'integration': set(),
|
|
|
|
'windows-integration': set(),
|
|
|
|
'network-integration': set(),
|
|
|
|
}
|
|
|
|
|
2018-04-13 01:15:28 +02:00
|
|
|
focused_commands = collections.defaultdict(set)
|
|
|
|
|
|
|
|
deleted_paths = set()
|
|
|
|
original_paths = set()
|
2017-02-14 03:49:36 +01:00
|
|
|
additional_paths = set()
|
2018-04-13 01:15:28 +02:00
|
|
|
no_integration_paths = set()
|
2017-02-14 03:49:36 +01:00
|
|
|
|
|
|
|
for path in paths:
|
2017-06-26 20:48:46 +02:00
|
|
|
if not os.path.exists(path):
|
2018-04-13 01:15:28 +02:00
|
|
|
deleted_paths.add(path)
|
2017-06-26 20:48:46 +02:00
|
|
|
continue
|
|
|
|
|
2018-04-13 01:15:28 +02:00
|
|
|
original_paths.add(path)
|
|
|
|
|
2017-02-14 03:49:36 +01:00
|
|
|
dependent_paths = mapper.get_dependent_paths(path)
|
|
|
|
|
|
|
|
if not dependent_paths:
|
|
|
|
continue
|
|
|
|
|
2019-03-08 07:50:10 +01:00
|
|
|
display.info('Expanded "%s" to %d dependent file(s):' % (path, len(dependent_paths)), verbosity=2)
|
2017-02-14 03:49:36 +01:00
|
|
|
|
|
|
|
for dependent_path in dependent_paths:
|
2019-03-08 07:50:10 +01:00
|
|
|
display.info(dependent_path, verbosity=2)
|
2017-02-14 03:49:36 +01:00
|
|
|
additional_paths.add(dependent_path)
|
|
|
|
|
|
|
|
additional_paths -= set(paths) # don't count changed paths as additional paths
|
|
|
|
|
|
|
|
if additional_paths:
|
|
|
|
display.info('Expanded %d changed file(s) into %d additional dependent file(s).' % (len(paths), len(additional_paths)))
|
|
|
|
paths = sorted(set(paths) | additional_paths)
|
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
display.info('Mapping %d changed file(s) to tests.' % len(paths))
|
|
|
|
|
2019-03-08 07:50:10 +01:00
|
|
|
none_count = 0
|
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
for path in paths:
|
|
|
|
tests = mapper.classify(path)
|
|
|
|
|
|
|
|
if tests is None:
|
2018-04-13 01:15:28 +02:00
|
|
|
focused_target = False
|
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
display.info('%s -> all' % path, verbosity=1)
|
2017-07-15 01:51:32 +02:00
|
|
|
tests = all_tests(args) # not categorized, run all tests
|
2016-11-30 06:21:53 +01:00
|
|
|
display.warning('Path not categorized: %s' % path)
|
|
|
|
else:
|
2018-04-13 01:15:28 +02:00
|
|
|
focused_target = tests.pop(FOCUSED_TARGET, False) and path in original_paths
|
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
tests = dict((key, value) for key, value in tests.items() if value)
|
|
|
|
|
2018-04-13 01:15:28 +02:00
|
|
|
if focused_target and not any('integration' in command for command in tests):
|
|
|
|
no_integration_paths.add(path) # path triggers no integration tests
|
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
if verbose_command:
|
|
|
|
result = '%s: %s' % (verbose_command, tests.get(verbose_command) or 'none')
|
|
|
|
|
|
|
|
# identify targeted integration tests (those which only target a single integration command)
|
|
|
|
if 'integration' in verbose_command and tests.get(verbose_command):
|
2017-05-03 17:19:44 +02:00
|
|
|
if not any('integration' in command for command in tests if command != verbose_command):
|
2018-04-13 01:15:28 +02:00
|
|
|
if focused_target:
|
|
|
|
result += ' (focused)'
|
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
result += ' (targeted)'
|
|
|
|
else:
|
|
|
|
result = '%s' % tests
|
|
|
|
|
2019-03-08 07:50:10 +01:00
|
|
|
if not tests.get(verbose_command):
|
|
|
|
# minimize excessive output from potentially thousands of files which do not trigger tests
|
|
|
|
none_count += 1
|
|
|
|
verbosity = 2
|
|
|
|
else:
|
|
|
|
verbosity = 1
|
|
|
|
|
|
|
|
if args.verbosity >= verbosity:
|
|
|
|
display.info('%s -> %s' % (path, result), verbosity=1)
|
2016-11-30 06:21:53 +01:00
|
|
|
|
|
|
|
for command, target in tests.items():
|
|
|
|
commands[command].add(target)
|
|
|
|
|
2018-04-13 01:15:28 +02:00
|
|
|
if focused_target:
|
|
|
|
focused_commands[command].add(target)
|
|
|
|
|
2019-03-08 07:50:10 +01:00
|
|
|
if none_count > 0 and args.verbosity < 2:
|
|
|
|
display.notice('Omitted %d file(s) that triggered no tests.' % none_count)
|
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
for command in commands:
|
2017-09-06 00:32:26 +02:00
|
|
|
commands[command].discard('none')
|
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
if any(target == 'all' for target in commands[command]):
|
2016-11-30 06:21:53 +01:00
|
|
|
commands[command] = set(['all'])
|
|
|
|
|
2017-05-03 17:19:44 +02:00
|
|
|
commands = dict((c, sorted(commands[c])) for c in commands if commands[c])
|
2018-04-13 01:15:28 +02:00
|
|
|
focused_commands = dict((c, sorted(focused_commands[c])) for c in focused_commands)
|
|
|
|
|
|
|
|
for command in commands:
|
|
|
|
if commands[command] == ['all']:
|
|
|
|
commands[command] = [] # changes require testing all targets, do not filter targets
|
|
|
|
|
|
|
|
changes = ChangeDescription()
|
|
|
|
changes.command = verbose_command
|
|
|
|
changes.changed_paths = sorted(original_paths)
|
|
|
|
changes.deleted_paths = sorted(deleted_paths)
|
|
|
|
changes.regular_command_targets = commands
|
|
|
|
changes.focused_command_targets = focused_commands
|
|
|
|
changes.no_integration_paths = sorted(no_integration_paths)
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2018-04-13 01:15:28 +02:00
|
|
|
return changes
|
2016-11-30 06:21:53 +01:00
|
|
|
|
|
|
|
|
2019-07-12 22:17:20 +02:00
|
|
|
class PathMapper:
|
2016-11-30 06:21:53 +01:00
|
|
|
"""Map file paths to test commands and targets."""
|
2017-07-15 01:51:32 +02:00
|
|
|
def __init__(self, args):
|
|
|
|
"""
|
|
|
|
:type args: TestConfig
|
|
|
|
"""
|
|
|
|
self.args = args
|
|
|
|
self.integration_all_target = get_integration_all_target(self.args)
|
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
self.integration_targets = list(walk_integration_targets())
|
|
|
|
self.module_targets = list(walk_module_targets())
|
|
|
|
self.compile_targets = list(walk_compile_targets())
|
|
|
|
self.units_targets = list(walk_units_targets())
|
2016-12-06 16:53:59 +01:00
|
|
|
self.sanity_targets = list(walk_sanity_targets())
|
2019-08-29 00:13:00 +02:00
|
|
|
self.powershell_targets = [target for target in self.sanity_targets if os.path.splitext(target.path)[1] in ('.ps1', '.psm1')]
|
|
|
|
self.csharp_targets = [target for target in self.sanity_targets if os.path.splitext(target.path)[1] == '.cs']
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
self.units_modules = set(target.module for target in self.units_targets if target.module)
|
|
|
|
self.units_paths = set(a for target in self.units_targets for a in target.aliases)
|
|
|
|
self.sanity_paths = set(target.path for target in self.sanity_targets)
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
self.module_names_by_path = dict((target.path, target.module) for target in self.module_targets)
|
|
|
|
self.integration_targets_by_name = dict((target.name, target) for target in self.integration_targets)
|
|
|
|
self.integration_targets_by_alias = dict((a, target) for target in self.integration_targets for a in target.aliases)
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
self.posix_integration_by_module = dict((m, target.name) for target in self.integration_targets
|
|
|
|
if 'posix/' in target.aliases for m in target.modules)
|
|
|
|
self.windows_integration_by_module = dict((m, target.name) for target in self.integration_targets
|
|
|
|
if 'windows/' in target.aliases for m in target.modules)
|
|
|
|
self.network_integration_by_module = dict((m, target.name) for target in self.integration_targets
|
|
|
|
if 'network/' in target.aliases for m in target.modules)
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2017-01-18 01:24:05 +01:00
|
|
|
self.prefixes = load_integration_prefixes()
|
2017-07-11 00:41:32 +02:00
|
|
|
self.integration_dependencies = analyze_integration_target_dependencies(self.integration_targets)
|
2017-01-18 01:24:05 +01:00
|
|
|
|
2017-02-14 03:49:36 +01:00
|
|
|
self.python_module_utils_imports = {} # populated on first use to reduce overhead when not needed
|
2017-10-17 20:26:32 +02:00
|
|
|
self.powershell_module_utils_imports = {} # populated on first use to reduce overhead when not needed
|
2018-10-03 00:55:53 +02:00
|
|
|
self.csharp_module_utils_imports = {} # populated on first use to reduce overhead when not needed
|
2017-02-14 03:49:36 +01:00
|
|
|
|
2019-01-12 09:18:17 +01:00
|
|
|
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)
|
|
|
|
|
2017-02-14 03:49:36 +01:00
|
|
|
def get_dependent_paths(self, path):
|
2019-01-12 09:18:17 +01:00
|
|
|
"""
|
|
|
|
: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)
|
2019-08-29 00:13:00 +02:00
|
|
|
paths += [target.path + '/' for target in self.paths_to_dependent_targets.get(path, set())]
|
2019-01-12 09:18:17 +01:00
|
|
|
paths = sorted(set(paths))
|
|
|
|
|
|
|
|
return paths
|
|
|
|
|
|
|
|
def get_dependent_paths_internal(self, path):
|
2017-02-14 03:49:36 +01:00
|
|
|
"""
|
|
|
|
:type path: str
|
|
|
|
:rtype: list[str]
|
|
|
|
"""
|
2017-03-23 02:07:53 +01:00
|
|
|
ext = os.path.splitext(os.path.split(path)[1])[1]
|
2017-02-14 03:49:36 +01:00
|
|
|
|
2019-07-23 04:24:48 +02:00
|
|
|
if is_subdir(path, data_context().content.module_utils_path):
|
2017-02-14 03:49:36 +01:00
|
|
|
if ext == '.py':
|
2017-03-23 02:07:53 +01:00
|
|
|
return self.get_python_module_utils_usage(path)
|
2017-02-14 03:49:36 +01:00
|
|
|
|
2017-10-17 20:26:32 +02:00
|
|
|
if ext == '.psm1':
|
|
|
|
return self.get_powershell_module_utils_usage(path)
|
|
|
|
|
2018-10-03 00:55:53 +02:00
|
|
|
if ext == '.cs':
|
|
|
|
return self.get_csharp_module_utils_usage(path)
|
|
|
|
|
2019-08-28 08:40:06 +02:00
|
|
|
if is_subdir(path, data_context().content.integration_targets_path):
|
2017-07-11 00:41:32 +02:00
|
|
|
return self.get_integration_target_usage(path)
|
|
|
|
|
2017-02-14 03:49:36 +01:00
|
|
|
return []
|
|
|
|
|
2017-03-23 02:07:53 +01:00
|
|
|
def get_python_module_utils_usage(self, path):
|
2017-02-14 03:49:36 +01:00
|
|
|
"""
|
2017-03-23 02:07:53 +01:00
|
|
|
:type path: str
|
2017-02-14 03:49:36 +01:00
|
|
|
:rtype: list[str]
|
|
|
|
"""
|
2017-03-23 02:07:53 +01:00
|
|
|
if path == 'lib/ansible/module_utils/__init__.py':
|
|
|
|
return []
|
|
|
|
|
2017-02-14 03:49:36 +01:00
|
|
|
if not self.python_module_utils_imports:
|
|
|
|
display.info('Analyzing python module_utils imports...')
|
|
|
|
before = time.time()
|
|
|
|
self.python_module_utils_imports = get_python_module_utils_imports(self.compile_targets)
|
|
|
|
after = time.time()
|
|
|
|
display.info('Processed %d python module_utils in %d second(s).' % (len(self.python_module_utils_imports), after - before))
|
|
|
|
|
2019-07-23 04:24:48 +02:00
|
|
|
name = get_python_module_utils_name(path)
|
2017-03-23 02:07:53 +01:00
|
|
|
|
|
|
|
return sorted(self.python_module_utils_imports[name])
|
2017-02-14 03:49:36 +01:00
|
|
|
|
2017-10-17 20:26:32 +02:00
|
|
|
def get_powershell_module_utils_usage(self, path):
|
|
|
|
"""
|
|
|
|
:type path: str
|
|
|
|
:rtype: list[str]
|
|
|
|
"""
|
|
|
|
if not self.powershell_module_utils_imports:
|
|
|
|
display.info('Analyzing powershell module_utils imports...')
|
|
|
|
before = time.time()
|
|
|
|
self.powershell_module_utils_imports = get_powershell_module_utils_imports(self.powershell_targets)
|
|
|
|
after = time.time()
|
|
|
|
display.info('Processed %d powershell module_utils in %d second(s).' % (len(self.powershell_module_utils_imports), after - before))
|
|
|
|
|
2019-07-23 04:24:48 +02:00
|
|
|
name = get_powershell_module_utils_name(path)
|
2017-10-17 20:26:32 +02:00
|
|
|
|
|
|
|
return sorted(self.powershell_module_utils_imports[name])
|
|
|
|
|
2018-10-03 00:55:53 +02:00
|
|
|
def get_csharp_module_utils_usage(self, path):
|
|
|
|
"""
|
|
|
|
:type path: str
|
|
|
|
:rtype: list[str]
|
|
|
|
"""
|
|
|
|
if not self.csharp_module_utils_imports:
|
|
|
|
display.info('Analyzing C# module_utils imports...')
|
|
|
|
before = time.time()
|
|
|
|
self.csharp_module_utils_imports = get_csharp_module_utils_imports(self.powershell_targets, self.csharp_targets)
|
|
|
|
after = time.time()
|
|
|
|
display.info('Processed %d C# module_utils in %d second(s).' % (len(self.csharp_module_utils_imports), after - before))
|
|
|
|
|
2019-07-23 04:24:48 +02:00
|
|
|
name = get_csharp_module_utils_name(path)
|
2018-10-03 00:55:53 +02:00
|
|
|
|
|
|
|
return sorted(self.csharp_module_utils_imports[name])
|
|
|
|
|
2017-07-11 00:41:32 +02:00
|
|
|
def get_integration_target_usage(self, path):
|
|
|
|
"""
|
|
|
|
:type path: str
|
|
|
|
:rtype: list[str]
|
|
|
|
"""
|
|
|
|
target_name = path.split('/')[3]
|
2019-08-28 08:40:06 +02:00
|
|
|
dependents = [os.path.join(data_context().content.integration_targets_path, target) + os.path.sep
|
|
|
|
for target in sorted(self.integration_dependencies.get(target_name, set()))]
|
2017-07-11 00:41:32 +02:00
|
|
|
|
|
|
|
return dependents
|
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
def classify(self, path):
|
|
|
|
"""
|
|
|
|
:type path: str
|
|
|
|
:rtype: dict[str, str] | None
|
|
|
|
"""
|
|
|
|
result = self._classify(path)
|
|
|
|
|
|
|
|
# run all tests when no result given
|
|
|
|
if result is None:
|
|
|
|
return None
|
|
|
|
|
|
|
|
# run sanity on path unless result specified otherwise
|
2016-12-06 16:53:59 +01:00
|
|
|
if path in self.sanity_paths and 'sanity' not in result:
|
2016-11-30 06:21:53 +01:00
|
|
|
result['sanity'] = path
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
def _classify(self, path): # type: (str) -> t.Optional[t.Dict[str, str]]
|
|
|
|
"""Return the classification for the given path."""
|
|
|
|
if data_context().content.is_ansible:
|
|
|
|
return self._classify_ansible(path)
|
|
|
|
|
|
|
|
if data_context().content.collection:
|
|
|
|
return self._classify_collection(path)
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
def _classify_common(self, path): # type: (str) -> t.Optional[t.Dict[str, str]]
|
|
|
|
"""Return the classification for the given path using rules common to all layouts."""
|
2017-08-30 19:40:14 +02:00
|
|
|
dirname = os.path.dirname(path)
|
2016-11-30 06:21:53 +01:00
|
|
|
filename = os.path.basename(path)
|
|
|
|
name, ext = os.path.splitext(filename)
|
|
|
|
|
|
|
|
minimal = {}
|
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
if is_subdir(path, '.github'):
|
2016-11-30 06:21:53 +01:00
|
|
|
return minimal
|
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
if is_subdir(path, data_context().content.integration_targets_path):
|
|
|
|
if not os.path.exists(path):
|
|
|
|
return minimal
|
|
|
|
|
|
|
|
target = self.integration_targets_by_name.get(path.split('/')[3])
|
|
|
|
|
|
|
|
if not target:
|
|
|
|
display.warning('Unexpected non-target found: %s' % path)
|
|
|
|
return minimal
|
|
|
|
|
|
|
|
if 'hidden/' in target.aliases:
|
|
|
|
return minimal # already expanded using get_dependent_paths
|
2016-11-30 06:21:53 +01:00
|
|
|
|
|
|
|
return {
|
2019-08-29 00:13:00 +02:00
|
|
|
'integration': target.name if 'posix/' in target.aliases else None,
|
|
|
|
'windows-integration': target.name if 'windows/' in target.aliases else None,
|
|
|
|
'network-integration': target.name if 'network/' in target.aliases else None,
|
|
|
|
FOCUSED_TARGET: True,
|
2016-11-30 06:21:53 +01:00
|
|
|
}
|
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
if is_subdir(path, data_context().content.integration_path):
|
|
|
|
if dirname == data_context().content.integration_path:
|
|
|
|
for command in (
|
|
|
|
'integration',
|
|
|
|
'windows-integration',
|
|
|
|
'network-integration',
|
|
|
|
):
|
|
|
|
if name == command and ext == '.cfg':
|
|
|
|
return {
|
|
|
|
command: self.integration_all_target,
|
|
|
|
}
|
2018-04-26 00:06:56 +02:00
|
|
|
|
2019-09-12 11:00:33 +02:00
|
|
|
if name == command + '.requirements' and ext == '.txt':
|
|
|
|
return {
|
|
|
|
command: self.integration_all_target,
|
|
|
|
}
|
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
return {
|
|
|
|
'integration': self.integration_all_target,
|
|
|
|
'windows-integration': self.integration_all_target,
|
|
|
|
'network-integration': self.integration_all_target,
|
|
|
|
}
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
if is_subdir(path, data_context().content.sanity_path):
|
|
|
|
return {
|
|
|
|
'sanity': 'all', # test infrastructure, run all sanity checks
|
|
|
|
}
|
|
|
|
|
|
|
|
if is_subdir(path, data_context().content.unit_path):
|
|
|
|
if path in self.units_paths:
|
2017-01-08 08:42:33 +01:00
|
|
|
return {
|
2019-08-29 00:13:00 +02:00
|
|
|
'units': path,
|
2017-01-08 08:42:33 +01:00
|
|
|
}
|
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
# changes to files which are not unit tests should trigger tests from the nearest parent directory
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
test_path = os.path.dirname(path)
|
2018-11-14 06:51:39 +01:00
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
while test_path:
|
|
|
|
if test_path + '/' in self.units_paths:
|
|
|
|
return {
|
|
|
|
'units': test_path + '/',
|
|
|
|
}
|
2018-11-14 06:51:39 +01:00
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
test_path = os.path.dirname(test_path)
|
2018-11-14 06:51:39 +01:00
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
if is_subdir(path, data_context().content.module_path):
|
2017-08-23 20:09:50 +02:00
|
|
|
module_name = self.module_names_by_path.get(path)
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2017-08-23 20:09:50 +02:00
|
|
|
if module_name:
|
2016-11-30 06:21:53 +01:00
|
|
|
return {
|
2017-08-23 20:09:50 +02:00
|
|
|
'units': module_name if module_name in self.units_modules else None,
|
|
|
|
'integration': self.posix_integration_by_module.get(module_name) if ext == '.py' else None,
|
2018-10-03 00:55:53 +02:00
|
|
|
'windows-integration': self.windows_integration_by_module.get(module_name) if ext in ['.cs', '.ps1'] else None,
|
2017-08-23 20:09:50 +02:00
|
|
|
'network-integration': self.network_integration_by_module.get(module_name),
|
2018-04-13 01:15:28 +02:00
|
|
|
FOCUSED_TARGET: True,
|
2016-11-30 06:21:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return minimal
|
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
if is_subdir(path, data_context().content.module_utils_path):
|
2018-10-03 00:55:53 +02:00
|
|
|
if ext == '.cs':
|
|
|
|
return minimal # already expanded using get_dependent_paths
|
|
|
|
|
2017-10-17 20:26:32 +02:00
|
|
|
if ext == '.psm1':
|
|
|
|
return minimal # already expanded using get_dependent_paths
|
2016-11-30 06:21:53 +01:00
|
|
|
|
|
|
|
if ext == '.py':
|
2017-02-14 03:49:36 +01:00
|
|
|
return minimal # already expanded using get_dependent_paths
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
if is_subdir(path, data_context().content.plugin_paths['action']):
|
2018-04-10 21:00:14 +02:00
|
|
|
if ext == '.py':
|
|
|
|
if name.startswith('net_'):
|
|
|
|
network_target = 'network/.*_%s' % name[4:]
|
|
|
|
|
|
|
|
if any(re.search(r'^%s$' % network_target, alias) for alias in self.integration_targets_by_alias):
|
|
|
|
return {
|
|
|
|
'network-integration': network_target,
|
|
|
|
'units': 'all',
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
'network-integration': self.integration_all_target,
|
|
|
|
'units': 'all',
|
|
|
|
}
|
|
|
|
|
|
|
|
if self.prefixes.get(name) == 'network':
|
|
|
|
network_platform = name
|
|
|
|
elif name.endswith('_config') and self.prefixes.get(name[:-7]) == 'network':
|
|
|
|
network_platform = name[:-7]
|
|
|
|
elif name.endswith('_template') and self.prefixes.get(name[:-9]) == 'network':
|
|
|
|
network_platform = name[:-9]
|
|
|
|
else:
|
|
|
|
network_platform = None
|
|
|
|
|
|
|
|
if network_platform:
|
|
|
|
network_target = 'network/%s/' % network_platform
|
|
|
|
|
|
|
|
if network_target in self.integration_targets_by_alias:
|
|
|
|
return {
|
|
|
|
'network-integration': network_target,
|
|
|
|
'units': 'all',
|
|
|
|
}
|
|
|
|
|
|
|
|
display.warning('Integration tests for "%s" not found.' % network_target, unique=True)
|
|
|
|
|
|
|
|
return {
|
|
|
|
'units': 'all',
|
|
|
|
}
|
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
if is_subdir(path, data_context().content.plugin_paths['connection']):
|
2016-11-30 06:21:53 +01:00
|
|
|
if name == '__init__':
|
|
|
|
return {
|
2017-07-15 01:51:32 +02:00
|
|
|
'integration': self.integration_all_target,
|
|
|
|
'windows-integration': self.integration_all_target,
|
|
|
|
'network-integration': self.integration_all_target,
|
2016-11-30 06:21:53 +01:00
|
|
|
'units': 'test/units/plugins/connection/',
|
|
|
|
}
|
|
|
|
|
2016-12-05 23:49:24 +01:00
|
|
|
units_path = 'test/units/plugins/connection/test_%s.py' % name
|
|
|
|
|
|
|
|
if units_path not in self.units_paths:
|
|
|
|
units_path = None
|
|
|
|
|
|
|
|
integration_name = 'connection_%s' % name
|
|
|
|
|
|
|
|
if integration_name not in self.integration_targets_by_name:
|
|
|
|
integration_name = None
|
|
|
|
|
2019-03-08 01:38:02 +01:00
|
|
|
windows_integration_name = 'connection_windows_%s' % name
|
|
|
|
|
|
|
|
if windows_integration_name not in self.integration_targets_by_name:
|
|
|
|
windows_integration_name = None
|
|
|
|
|
2016-12-05 23:49:24 +01:00
|
|
|
# entire integration test commands depend on these connection plugins
|
|
|
|
|
2018-08-22 01:43:13 +02:00
|
|
|
if name in ['winrm', 'psrp']:
|
2016-11-30 06:21:53 +01:00
|
|
|
return {
|
2017-07-15 01:51:32 +02:00
|
|
|
'windows-integration': self.integration_all_target,
|
2016-12-05 23:49:24 +01:00
|
|
|
'units': units_path,
|
2016-11-30 06:21:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if name == 'local':
|
|
|
|
return {
|
2017-07-15 01:51:32 +02:00
|
|
|
'integration': self.integration_all_target,
|
|
|
|
'network-integration': self.integration_all_target,
|
2016-12-05 23:49:24 +01:00
|
|
|
'units': units_path,
|
2016-11-30 06:21:53 +01:00
|
|
|
}
|
|
|
|
|
2016-12-05 23:49:24 +01:00
|
|
|
if name == 'network_cli':
|
2016-11-30 06:21:53 +01:00
|
|
|
return {
|
2017-07-15 01:51:32 +02:00
|
|
|
'network-integration': self.integration_all_target,
|
2016-12-05 23:49:24 +01:00
|
|
|
'units': units_path,
|
2016-11-30 06:21:53 +01:00
|
|
|
}
|
|
|
|
|
2019-02-26 22:34:55 +01:00
|
|
|
if name == 'paramiko_ssh':
|
|
|
|
return {
|
|
|
|
'integration': integration_name,
|
|
|
|
'network-integration': self.integration_all_target,
|
|
|
|
'units': units_path,
|
|
|
|
}
|
|
|
|
|
2016-12-05 23:49:24 +01:00
|
|
|
# other connection plugins have isolated integration and unit tests
|
|
|
|
|
|
|
|
return {
|
|
|
|
'integration': integration_name,
|
2019-03-08 01:38:02 +01:00
|
|
|
'windows-integration': windows_integration_name,
|
2016-12-05 23:49:24 +01:00
|
|
|
'units': units_path,
|
|
|
|
}
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
if is_subdir(path, data_context().content.plugin_paths['doc_fragments']):
|
|
|
|
return {
|
|
|
|
'sanity': 'all',
|
|
|
|
}
|
|
|
|
|
|
|
|
if is_subdir(path, data_context().content.plugin_paths['inventory']):
|
2018-08-13 21:26:37 +02:00
|
|
|
if name == '__init__':
|
|
|
|
return all_tests(self.args) # broad impact, run all tests
|
|
|
|
|
|
|
|
# These inventory plugins are enabled by default (see INVENTORY_ENABLED).
|
|
|
|
# Without dedicated integration tests for these we must rely on the incidental coverage from other tests.
|
|
|
|
test_all = [
|
|
|
|
'host_list',
|
|
|
|
'script',
|
|
|
|
'yaml',
|
|
|
|
'ini',
|
|
|
|
'auto',
|
|
|
|
]
|
|
|
|
|
|
|
|
if name in test_all:
|
|
|
|
posix_integration_fallback = get_integration_all_target(self.args)
|
|
|
|
else:
|
|
|
|
posix_integration_fallback = None
|
|
|
|
|
|
|
|
target = self.integration_targets_by_name.get('inventory_%s' % name)
|
|
|
|
units_path = 'test/units/plugins/inventory/test_%s.py' % name
|
|
|
|
|
|
|
|
if units_path not in self.units_paths:
|
|
|
|
units_path = None
|
|
|
|
|
|
|
|
return {
|
|
|
|
'integration': target.name if target and 'posix/' in target.aliases else posix_integration_fallback,
|
|
|
|
'windows-integration': target.name if target and 'windows/' in target.aliases else None,
|
|
|
|
'network-integration': target.name if target and 'network/' in target.aliases else None,
|
|
|
|
'units': units_path,
|
|
|
|
FOCUSED_TARGET: target is not None,
|
|
|
|
}
|
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
if (is_subdir(path, data_context().content.plugin_paths['terminal']) or
|
|
|
|
is_subdir(path, data_context().content.plugin_paths['cliconf']) or
|
|
|
|
is_subdir(path, data_context().content.plugin_paths['netconf'])):
|
2017-01-18 20:52:16 +01:00
|
|
|
if ext == '.py':
|
|
|
|
if name in self.prefixes and self.prefixes[name] == 'network':
|
|
|
|
network_target = 'network/%s/' % name
|
|
|
|
|
|
|
|
if network_target in self.integration_targets_by_alias:
|
|
|
|
return {
|
|
|
|
'network-integration': network_target,
|
|
|
|
'units': 'all',
|
|
|
|
}
|
|
|
|
|
2018-04-10 21:00:14 +02:00
|
|
|
display.warning('Integration tests for "%s" not found.' % network_target, unique=True)
|
2017-01-18 20:52:16 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
'units': 'all',
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2017-07-15 01:51:32 +02:00
|
|
|
'network-integration': self.integration_all_target,
|
2017-01-18 20:52:16 +01:00
|
|
|
'units': 'all',
|
|
|
|
}
|
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
return None
|
|
|
|
|
|
|
|
def _classify_collection(self, path): # type: (str) -> t.Optional[t.Dict[str, str]]
|
|
|
|
"""Return the classification for the given path using rules specific to collections."""
|
|
|
|
result = self._classify_common(path)
|
|
|
|
|
|
|
|
if result is not None:
|
|
|
|
return result
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
def _classify_ansible(self, path): # type: (str) -> t.Optional[t.Dict[str, str]]
|
|
|
|
"""Return the classification for the given path using rules specific to Ansible."""
|
|
|
|
if path.startswith('test/units/compat/'):
|
2016-11-30 06:21:53 +01:00
|
|
|
return {
|
2019-08-29 00:13:00 +02:00
|
|
|
'units': 'test/units/',
|
|
|
|
}
|
|
|
|
|
|
|
|
result = self._classify_common(path)
|
|
|
|
|
|
|
|
if result is not None:
|
|
|
|
return result
|
|
|
|
|
|
|
|
dirname = os.path.dirname(path)
|
|
|
|
filename = os.path.basename(path)
|
|
|
|
name, ext = os.path.splitext(filename)
|
|
|
|
|
|
|
|
minimal = {}
|
|
|
|
|
|
|
|
if path.startswith('bin/'):
|
|
|
|
return all_tests(self.args) # broad impact, run all tests
|
|
|
|
|
|
|
|
if path.startswith('changelogs/'):
|
|
|
|
return minimal
|
|
|
|
|
|
|
|
if path.startswith('contrib/'):
|
|
|
|
return {
|
|
|
|
'units': 'test/units/contrib/'
|
|
|
|
}
|
|
|
|
|
|
|
|
if path.startswith('docs/'):
|
|
|
|
return minimal
|
|
|
|
|
|
|
|
if path.startswith('examples/'):
|
|
|
|
if path == 'examples/scripts/ConfigureRemotingForAnsible.ps1':
|
|
|
|
return {
|
|
|
|
'windows-integration': 'connection_winrm',
|
|
|
|
}
|
|
|
|
|
|
|
|
return minimal
|
|
|
|
|
|
|
|
if path.startswith('hacking/'):
|
|
|
|
return minimal
|
|
|
|
|
|
|
|
if path.startswith('lib/ansible/executor/powershell/'):
|
|
|
|
units_path = 'test/units/executor/powershell/'
|
|
|
|
|
|
|
|
if units_path not in self.units_paths:
|
|
|
|
units_path = None
|
|
|
|
|
|
|
|
return {
|
|
|
|
'windows-integration': self.integration_all_target,
|
|
|
|
'units': units_path,
|
2016-11-30 06:21:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if path.startswith('lib/ansible/'):
|
2017-07-15 01:51:32 +02:00
|
|
|
return all_tests(self.args) # broad impact, run all tests
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
if path.startswith('licenses/'):
|
|
|
|
return minimal
|
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
if path.startswith('packaging/'):
|
2017-08-11 18:54:34 +02:00
|
|
|
if path.startswith('packaging/requirements/'):
|
2017-08-12 02:33:39 +02:00
|
|
|
if name.startswith('requirements-') and ext == '.txt':
|
|
|
|
component = name.split('-', 1)[1]
|
|
|
|
|
|
|
|
candidates = (
|
|
|
|
'cloud/%s/' % component,
|
|
|
|
)
|
|
|
|
|
|
|
|
for candidate in candidates:
|
|
|
|
if candidate in self.integration_targets_by_alias:
|
|
|
|
return {
|
|
|
|
'integration': candidate,
|
|
|
|
}
|
|
|
|
|
|
|
|
return all_tests(self.args) # broad impact, run all tests
|
2017-08-11 18:54:34 +02:00
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
return minimal
|
|
|
|
|
2019-08-24 20:38:30 +02:00
|
|
|
if path.startswith('test/ansible_test/'):
|
|
|
|
return minimal # these tests are not invoked from ansible-test
|
|
|
|
|
2017-09-14 02:31:44 +02:00
|
|
|
if path.startswith('test/legacy/'):
|
|
|
|
return minimal
|
|
|
|
|
2019-08-08 03:32:30 +02:00
|
|
|
if path.startswith('test/lib/ansible_test/config/'):
|
|
|
|
if name.startswith('cloud-config-'):
|
2020-02-04 20:21:53 +01:00
|
|
|
# noinspection PyTypeChecker
|
2019-08-08 03:32:30 +02:00
|
|
|
cloud_target = 'cloud/%s/' % name.split('-')[2].split('.')[0]
|
|
|
|
|
|
|
|
if cloud_target in self.integration_targets_by_alias:
|
|
|
|
return {
|
|
|
|
'integration': cloud_target,
|
|
|
|
}
|
|
|
|
|
2019-08-06 23:43:29 +02:00
|
|
|
if path.startswith('test/lib/ansible_test/_data/completion/'):
|
|
|
|
if path == 'test/lib/ansible_test/_data/completion/docker.txt':
|
2017-11-21 22:33:40 +01:00
|
|
|
return all_tests(self.args, force=True) # force all tests due to risk of breaking changes in new test environment
|
|
|
|
|
2019-08-06 23:43:29 +02:00
|
|
|
if path.startswith('test/lib/ansible_test/_internal/cloud/'):
|
2017-05-09 10:15:27 +02:00
|
|
|
cloud_target = 'cloud/%s/' % name
|
|
|
|
|
|
|
|
if cloud_target in self.integration_targets_by_alias:
|
|
|
|
return {
|
|
|
|
'integration': cloud_target,
|
|
|
|
}
|
|
|
|
|
2017-07-15 01:51:32 +02:00
|
|
|
return all_tests(self.args) # test infrastructure, run all tests
|
2017-05-09 10:15:27 +02:00
|
|
|
|
2019-08-06 23:43:29 +02:00
|
|
|
if path.startswith('test/lib/ansible_test/_internal/sanity/'):
|
2017-08-19 02:21:11 +02:00
|
|
|
return {
|
|
|
|
'sanity': 'all', # test infrastructure, run all sanity checks
|
2019-08-07 01:26:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if path.startswith('test/lib/ansible_test/_data/sanity/'):
|
|
|
|
return {
|
|
|
|
'sanity': 'all', # test infrastructure, run all sanity checks
|
2017-08-19 02:21:11 +02:00
|
|
|
}
|
2017-10-19 22:37:22 +02:00
|
|
|
|
2019-08-09 18:38:19 +02:00
|
|
|
if path.startswith('test/lib/ansible_test/_internal/units/'):
|
|
|
|
return {
|
|
|
|
'units': 'all', # test infrastructure, run all unit tests
|
|
|
|
}
|
|
|
|
|
|
|
|
if path.startswith('test/lib/ansible_test/_data/units/'):
|
|
|
|
return {
|
|
|
|
'units': 'all', # test infrastructure, run all unit tests
|
|
|
|
}
|
|
|
|
|
|
|
|
if path.startswith('test/lib/ansible_test/_data/pytest/'):
|
|
|
|
return {
|
|
|
|
'units': 'all', # test infrastructure, run all unit tests
|
|
|
|
}
|
|
|
|
|
2019-08-06 23:43:29 +02:00
|
|
|
if path.startswith('test/lib/ansible_test/_data/requirements/'):
|
2017-10-19 22:37:22 +02:00
|
|
|
if name in (
|
|
|
|
'integration',
|
|
|
|
'network-integration',
|
|
|
|
'windows-integration',
|
|
|
|
):
|
|
|
|
return {
|
|
|
|
name: self.integration_all_target,
|
|
|
|
}
|
|
|
|
|
|
|
|
if name in (
|
|
|
|
'sanity',
|
|
|
|
'units',
|
|
|
|
):
|
|
|
|
return {
|
|
|
|
name: 'all',
|
|
|
|
}
|
|
|
|
|
|
|
|
if name.startswith('integration.cloud.'):
|
|
|
|
cloud_target = 'cloud/%s/' % name.split('.')[2]
|
|
|
|
|
|
|
|
if cloud_target in self.integration_targets_by_alias:
|
|
|
|
return {
|
|
|
|
'integration': cloud_target,
|
|
|
|
}
|
2017-08-19 02:21:11 +02:00
|
|
|
|
2019-08-06 23:43:29 +02:00
|
|
|
if path.startswith('test/lib/'):
|
2017-07-15 01:51:32 +02:00
|
|
|
return all_tests(self.args) # test infrastructure, run all tests
|
2016-11-30 06:21:53 +01:00
|
|
|
|
2018-01-24 20:07:24 +01:00
|
|
|
if path.startswith('test/utils/shippable/tools/'):
|
|
|
|
return minimal # not used by tests
|
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
if path.startswith('test/utils/shippable/'):
|
2018-01-24 20:07:24 +01:00
|
|
|
if dirname == 'test/utils/shippable':
|
|
|
|
test_map = {
|
|
|
|
'cloud.sh': 'integration:cloud/',
|
|
|
|
'freebsd.sh': 'integration:all',
|
|
|
|
'linux.sh': 'integration:all',
|
|
|
|
'network.sh': 'network-integration:all',
|
|
|
|
'osx.sh': 'integration:all',
|
|
|
|
'rhel.sh': 'integration:all',
|
|
|
|
'sanity.sh': 'sanity:all',
|
|
|
|
'units.sh': 'units:all',
|
|
|
|
'windows.sh': 'windows-integration:all',
|
|
|
|
}
|
|
|
|
|
|
|
|
test_match = test_map.get(filename)
|
|
|
|
|
|
|
|
if test_match:
|
|
|
|
test_command, test_target = test_match.split(':')
|
|
|
|
|
|
|
|
return {
|
|
|
|
test_command: test_target,
|
|
|
|
}
|
|
|
|
|
2018-07-24 05:46:22 +02:00
|
|
|
cloud_target = 'cloud/%s/' % name
|
|
|
|
|
|
|
|
if cloud_target in self.integration_targets_by_alias:
|
|
|
|
return {
|
|
|
|
'integration': cloud_target,
|
|
|
|
}
|
|
|
|
|
2017-07-15 01:51:32 +02:00
|
|
|
return all_tests(self.args) # test infrastructure, run all tests
|
2016-11-30 06:21:53 +01:00
|
|
|
|
|
|
|
if path.startswith('test/utils/'):
|
|
|
|
return minimal
|
|
|
|
|
|
|
|
if '/' not in path:
|
|
|
|
if path in (
|
|
|
|
'.gitattributes',
|
|
|
|
'.gitignore',
|
|
|
|
'.mailmap',
|
|
|
|
'COPYING',
|
|
|
|
'Makefile',
|
|
|
|
):
|
|
|
|
return minimal
|
|
|
|
|
|
|
|
if path in (
|
2019-08-29 00:13:00 +02:00
|
|
|
'setup.py',
|
2016-11-30 06:21:53 +01:00
|
|
|
'shippable.yml',
|
|
|
|
):
|
2017-08-12 02:33:39 +02:00
|
|
|
return all_tests(self.args) # broad impact, run all tests
|
2017-08-11 18:54:34 +02:00
|
|
|
|
2019-08-29 00:13:00 +02:00
|
|
|
if ext in (
|
|
|
|
'.in',
|
|
|
|
'.md',
|
|
|
|
'.rst',
|
|
|
|
'.toml',
|
|
|
|
'.txt',
|
|
|
|
):
|
2016-11-30 06:21:53 +01:00
|
|
|
return minimal
|
|
|
|
|
|
|
|
return None # unknown, will result in fall-back to run all tests
|
|
|
|
|
|
|
|
|
2017-11-21 22:33:40 +01:00
|
|
|
def all_tests(args, force=False):
|
2016-11-30 06:21:53 +01:00
|
|
|
"""
|
2017-07-15 01:51:32 +02:00
|
|
|
:type args: TestConfig
|
2017-11-21 22:33:40 +01:00
|
|
|
:type force: bool
|
2016-11-30 06:21:53 +01:00
|
|
|
:rtype: dict[str, str]
|
|
|
|
"""
|
2017-11-21 22:33:40 +01:00
|
|
|
if force:
|
|
|
|
integration_all_target = 'all'
|
|
|
|
else:
|
|
|
|
integration_all_target = get_integration_all_target(args)
|
2017-07-15 01:51:32 +02:00
|
|
|
|
2016-11-30 06:21:53 +01:00
|
|
|
return {
|
|
|
|
'sanity': 'all',
|
|
|
|
'units': 'all',
|
2017-07-15 01:51:32 +02:00
|
|
|
'integration': integration_all_target,
|
|
|
|
'windows-integration': integration_all_target,
|
|
|
|
'network-integration': integration_all_target,
|
2016-11-30 06:21:53 +01:00
|
|
|
}
|
2017-07-15 01:51:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
def get_integration_all_target(args):
|
|
|
|
"""
|
|
|
|
:type args: TestConfig
|
|
|
|
:rtype: str
|
|
|
|
"""
|
|
|
|
if isinstance(args, IntegrationConfig):
|
|
|
|
return args.changed_all_target
|
|
|
|
|
|
|
|
return 'all'
|