diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:19 +0000 |
commit | 6c09f2a45c5541e9c207d14fc7aa21a4a0066bde (patch) | |
tree | 0221189d367bf661f6f9493c4f17a03f0dd4b7d2 /test/t/unit/test_unit_compgen_commands.py | |
parent | Releasing progress-linux version 1:2.11-8~progress7.99u1. (diff) | |
download | bash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.tar.xz bash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.zip |
Merging upstream version 1:2.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/t/unit/test_unit_compgen_commands.py')
-rw-r--r-- | test/t/unit/test_unit_compgen_commands.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/t/unit/test_unit_compgen_commands.py b/test/t/unit/test_unit_compgen_commands.py new file mode 100644 index 0000000..d866239 --- /dev/null +++ b/test/t/unit/test_unit_compgen_commands.py @@ -0,0 +1,47 @@ +import pytest + +from conftest import assert_bash_exec, assert_complete, bash_env_saved + + +@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+COMPREPLY=") +class TestUtilCompgenCommands: + @pytest.fixture(scope="class") + def functions(self, request, bash): + assert_bash_exec( + bash, + r"_comp_compgen_commands__test() {" + r" local COMPREPLY=() cur=${1-};" + r" _comp_compgen_commands;" + r' printf "%s\n" "${COMPREPLY[@]-}";' + r"}", + ) + assert_bash_exec( + bash, + "_comp_cmd_ccc() {" + " local cur;" + " _comp_get_words cur;" + " unset -v COMPREPLY;" + " _comp_compgen_commands;" + "}; complete -F _comp_cmd_ccc ccc", + ) + + def test_basic(self, bash, functions): + output = assert_bash_exec( + bash, "_comp_compgen_commands__test sh", want_output=True + ) + assert output.strip() + + @pytest.mark.parametrize( + "shopt_no_empty,result_empty", ((True, True), (False, False)) + ) + def test_empty(self, bash, functions, shopt_no_empty, result_empty): + with bash_env_saved(bash) as bash_env: + bash_env.shopt("no_empty_cmd_completion", shopt_no_empty) + output = assert_bash_exec( + bash, "_comp_compgen_commands__test", want_output=True + ) + assert (output.strip() == "") == result_empty + + def test_spaces(self, bash, functions): + completion = assert_complete(bash, "ccc shared/default/bar") + assert completion == r"\ bar.d/" |