From b5386e6dc256b92e5b752cc660ea7315ef9e0e1a Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Thu, 1 Sep 2022 11:34:57 +0900 Subject: [PATCH 1/2] test(Makefile.am): update EXTRA_DIST --- test/t/Makefile.am | 2 ++ test/t/unit/Makefile.am | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/test/t/Makefile.am b/test/t/Makefile.am index 8b6dcdcbc4f..8bcbdd842f1 100644 --- a/test/t/Makefile.am +++ b/test/t/Makefile.am @@ -21,6 +21,7 @@ EXTRA_DIST = \ test_apt_build.py \ test_apt_cache.py \ test_apt_get.py \ + test_apt_mark.py \ test_aptitude.py \ test_arch.py \ test_arp.py \ @@ -256,6 +257,7 @@ EXTRA_DIST = \ test_ip.py \ test_ipcalc.py \ test_iperf.py \ + test_iperf3.py \ test_ipmitool.py \ test_ipsec.py \ test_iptables.py \ diff --git a/test/t/unit/Makefile.am b/test/t/unit/Makefile.am index 7aad78c3f05..ed590cf650b 100644 --- a/test/t/unit/Makefile.am +++ b/test/t/unit/Makefile.am @@ -1,6 +1,10 @@ EXTRA_DIST = \ + test_unit_command_offset.py \ test_unit_count_args.py \ + test_unit_deprecate_func.py \ + test_unit_dequote.py \ test_unit_expand.py \ + test_unit_expand_glob.py \ test_unit_expand_tilde_by_ref.py \ test_unit_filedir.py \ test_unit_find_unique_completion_pair.py \ @@ -10,6 +14,7 @@ EXTRA_DIST = \ test_unit_ip_addresses.py \ test_unit_known_hosts_real.py \ test_unit_longopt.py \ + test_unit_looks_like_path.py \ test_unit_parse_help.py \ test_unit_parse_usage.py \ test_unit_pgids.py \ @@ -18,7 +23,9 @@ EXTRA_DIST = \ test_unit_quote.py \ test_unit_quote_readline.py \ test_unit_tilde.py \ + test_unit_unlocal.py \ test_unit_variables.py \ + test_unit_xfunc.py \ test_unit_xinetd_services.py all: From 649afc70477c626db1d250c96dc7ce961d9fdd20 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Thu, 1 Sep 2022 12:19:07 +0900 Subject: [PATCH 2/2] test(_comp_expand_glob): avoid tempenv for functions in POSIX mode --- test/t/unit/test_unit_expand_glob.py | 79 ++++++++++------------------ 1 file changed, 28 insertions(+), 51 deletions(-) diff --git a/test/t/unit/test_unit_expand_glob.py b/test/t/unit/test_unit_expand_glob.py index 2d3b85ef28b..64d04a7d6fa 100644 --- a/test/t/unit/test_unit_expand_glob.py +++ b/test/t/unit/test_unit_expand_glob.py @@ -6,101 +6,78 @@ @pytest.mark.bashcomp( cmd=None, cwd="_filedir", - ignore_env=r"^\+(my_array=|declare -f dump_array$)", + ignore_env=r"^\+declare -f (dump_array|__tester)$", ) class TestExpandGlob: - def test_match_all(self, bash): + @pytest.fixture(scope="class") + def functions(self, bash): assert_bash_exec( bash, - "dump_array() { ((${#my_array[@]})) && printf '<%s>' \"${my_array[@]}\"; echo; }", + "dump_array() { ((${#arr[@]})) && printf '<%s>' \"${arr[@]}\"; echo; }", ) - output = assert_bash_exec( + assert_bash_exec( bash, - "LC_ALL= LC_COLLATE=C _comp_expand_glob my_array '*';dump_array", - want_output=True, + '__tester() { local LC_ALL= LC_COLLATE=C arr; _comp_expand_glob arr "$@";dump_array; }', ) + + def test_match_all(self, bash, functions): + output = assert_bash_exec(bash, "__tester '*'", want_output=True) assert output.strip() == "" - def test_match_pattern(self, bash): - output = assert_bash_exec( - bash, - "LC_ALL= LC_COLLATE=C _comp_expand_glob my_array 'a*';dump_array", - want_output=True, - ) + def test_match_pattern(self, bash, functions): + output = assert_bash_exec(bash, "__tester 'a*'", want_output=True) assert output.strip() == "" - def test_match_unmatched(self, bash): + def test_match_unmatched(self, bash, functions): output = assert_bash_exec( - bash, - "_comp_expand_glob my_array 'unmatched-*';dump_array", - want_output=True, + bash, "__tester 'unmatched-*'", want_output=True ) assert output.strip() == "" - def test_match_multiple_words(self, bash): - output = assert_bash_exec( - bash, - "_comp_expand_glob my_array 'b* e*';dump_array", - want_output=True, - ) + def test_match_multiple_words(self, bash, functions): + output = assert_bash_exec(bash, "__tester 'b* e*'", want_output=True) assert output.strip() == "" - def test_match_brace_expansion(self, bash): + def test_match_brace_expansion(self, bash, functions): output = assert_bash_exec( - bash, - "_comp_expand_glob my_array 'brac{ket,unmatched}*';dump_array", - want_output=True, + bash, "__tester 'brac{ket,unmatched}*'", want_output=True ) assert output.strip() == "" - def test_protect_from_noglob(self, bash): - with bash_env_saved(bash) as bash_env: + def test_protect_from_noglob(self, bash, functions): + with bash_env_saved(bash, functions) as bash_env: bash_env.set("noglob", True) - output = assert_bash_exec( - bash, - "LC_ALL= LC_COLLATE=C _comp_expand_glob my_array 'a*';dump_array", - want_output=True, - ) + output = assert_bash_exec(bash, "__tester 'a*'", want_output=True) assert output.strip() == "" - def test_protect_from_failglob(self, bash): + def test_protect_from_failglob(self, bash, functions): with bash_env_saved(bash) as bash_env: bash_env.shopt("failglob", True) output = assert_bash_exec( - bash, - "_comp_expand_glob my_array 'unmatched-*';dump_array", - want_output=True, + bash, "__tester 'unmatched-*'", want_output=True ) assert output.strip() == "" - def test_protect_from_nullglob(self, bash): + def test_protect_from_nullglob(self, bash, functions): with bash_env_saved(bash) as bash_env: bash_env.shopt("nullglob", False) output = assert_bash_exec( - bash, - "_comp_expand_glob my_array 'unmatched-*';dump_array", - want_output=True, + bash, "__tester 'unmatched-*'", want_output=True ) assert output.strip() == "" - def test_protect_from_dotglob(self, bash): + def test_protect_from_dotglob(self, bash, functions): with bash_env_saved(bash) as bash_env: bash_env.shopt("dotglob", True) output = assert_bash_exec( - bash, - "_comp_expand_glob my_array 'ext/foo/*';dump_array", - want_output=True, + bash, "__tester 'ext/foo/*'", want_output=True ) assert output.strip() == "" - def test_protect_from_GLOBIGNORE(self, bash): + def test_protect_from_GLOBIGNORE(self, bash, functions): with bash_env_saved(bash) as bash_env: # Note: dotglob is changed by GLOBIGNORE bash_env.save_shopt("dotglob") bash_env.write_variable("GLOBIGNORE", "*") - output = assert_bash_exec( - bash, - "LC_ALL= LC_COLLATE=C _comp_expand_glob my_array 'a*';dump_array", - want_output=True, - ) + output = assert_bash_exec(bash, "__tester 'a*'", want_output=True) assert output.strip() == ""