Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ansible-test - Improve help for unsupported cwd. (#76866)
* ansible-test - Improve help for unsupported cwd. * The `--help` option is now available when an unsupported cwd is in use. * The `--help` output now shows the same instructions about cwd as would be shown in error messages if the cwd is unsupported. * Add `--version` support to show the ansible-core version. * The explanation about cwd usage has been improved to explain more clearly what is required. Resolves #64523 Resolves #67551
- Loading branch information
Showing
10 changed files
with
171 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
minor_changes: | ||
- ansible-test - The ``--help`` option is now available when an unsupported cwd is in use. | ||
- ansible-test - The ``--help`` output now shows the same instructions about cwd as would be shown in error messages if the cwd is unsupported. | ||
- ansible-test - Add ``--version`` support to show the ansible-core version. | ||
- ansible-test - The explanation about cwd usage has been improved to explain more clearly what is required. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Argument parsing epilog generation.""" | ||
from __future__ import annotations | ||
|
||
from .argparsing import ( | ||
CompositeActionCompletionFinder, | ||
) | ||
|
||
from ..data import ( | ||
data_context, | ||
) | ||
|
||
|
||
def get_epilog(completer: CompositeActionCompletionFinder) -> str: | ||
"""Generate and return the epilog to use for help output.""" | ||
if completer.enabled: | ||
epilog = 'Tab completion available using the "argcomplete" python package.' | ||
else: | ||
epilog = 'Install the "argcomplete" python package to enable tab completion.' | ||
|
||
if data_context().content.unsupported: | ||
epilog += '\n\n' + data_context().explain_working_directory() | ||
|
||
return epilog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
test/lib/ansible_test/_internal/provider/layout/unsupported.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Layout provider for an unsupported directory layout.""" | ||
from __future__ import annotations | ||
|
||
import typing as t | ||
|
||
from . import ( | ||
ContentLayout, | ||
LayoutProvider, | ||
) | ||
|
||
|
||
class UnsupportedLayout(LayoutProvider): | ||
"""Layout provider for an unsupported directory layout.""" | ||
sequence = 0 # disable automatic detection | ||
|
||
@staticmethod | ||
def is_content_root(path): # type: (str) -> bool | ||
"""Return True if the given path is a content root for this provider.""" | ||
return False | ||
|
||
def create(self, root, paths): # type: (str, t.List[str]) -> ContentLayout | ||
"""Create a Layout using the given root and paths.""" | ||
plugin_paths = dict((p, p) for p in self.PLUGIN_TYPES) | ||
|
||
return ContentLayout(root, | ||
paths, | ||
plugin_paths=plugin_paths, | ||
collection=None, | ||
test_path='', | ||
results_path='', | ||
sanity_path='', | ||
sanity_messages=None, | ||
integration_path='', | ||
integration_targets_path='', | ||
integration_vars_path='', | ||
integration_messages=None, | ||
unit_path='', | ||
unit_module_path='', | ||
unit_module_utils_path='', | ||
unit_messages=None, | ||
unsupported=True, | ||
) |
22 changes: 22 additions & 0 deletions
22
test/lib/ansible_test/_internal/provider/source/unsupported.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Source provider to use when the layout is unsupported.""" | ||
from __future__ import annotations | ||
|
||
import typing as t | ||
|
||
from . import ( | ||
SourceProvider, | ||
) | ||
|
||
|
||
class UnsupportedSource(SourceProvider): | ||
"""Source provider to use when the layout is unsupported.""" | ||
sequence = 0 # disable automatic detection | ||
|
||
@staticmethod | ||
def is_content_root(path): # type: (str) -> bool | ||
"""Return True if the given path is a content root for this provider.""" | ||
return False | ||
|
||
def get_paths(self, path): # type: (str) -> t.List[str] | ||
"""Return the list of available content paths under the given path.""" | ||
return [] |