ansible-test - Allow target prefixes to use `_` (#80021)

Integration test target prefixes defined in a `tests/integration/target-prefixes.{group}` file can now contain an underscore (`_`) character.
pull/80055/head
Matt Clay 1 year ago committed by GitHub
parent fe2732b91e
commit e6cffce0eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,4 @@
bugfixes:
- ansible-test - Integration test target prefixes defined in a ``tests/integration/target-prefixes.{group}`` file
can now contain an underscore (``_``) character.
Resolves issue https://github.com/ansible/ansible/issues/79225

@ -31,5 +31,17 @@ class OptionsTest(unittest.TestCase):
raise Exception(f'{ex}:\n>>> Standard Output:\n{ex.stdout}\n>>> Standard Error:\n{ex.stderr}') from ex
class PrefixesTest(unittest.TestCase):
def test_prefixes(self):
try:
command = ['ansible-test', 'integration', '--list-targets']
something = subprocess.run([*command, 'something/'], text=True, capture_output=True, check=True)
self.assertEqual(something.stdout.splitlines(), ['one-part_test', 'two_part_test'])
except subprocess.CalledProcessError as ex:
raise Exception(f'{ex}:\n>>> Standard Output:\n{ex.stdout}\n>>> Standard Error:\n{ex.stderr}') from ex
if __name__ == '__main__':
unittest.main()

@ -610,13 +610,9 @@ class IntegrationTarget(CompletionTarget):
if 'needs/httptester' in groups:
groups.append('cloud/httptester') # backwards compatibility for when it was not a cloud plugin
if '_' in self.name:
prefix = self.name[:self.name.find('_')]
else:
prefix = None
if prefix in prefixes:
group = prefixes[prefix]
for prefix, group in prefixes.items():
if not self.name.startswith(f'{prefix}_'):
continue
if group != prefix:
group = '%s/%s' % (group, prefix)

Loading…
Cancel
Save