@@ -75,6 +75,12 @@ run_completion ()
__git_wrap__git_main && print_comp
}
+run_func ()
+{
+ local -a COMPREPLY &&
+ "$@" && print_comp
+}
+
# Test high-level completion
# Arguments are:
# 1: typed text so far (cur)
@@ -452,8 +458,7 @@ test_expect_success '__gitcomp_direct - puts everything into COMPREPLY as-is' '
EOF
(
cur=should_be_ignored &&
- __gitcomp_direct "$(cat expected)" &&
- print_comp
+ run_func __gitcomp_direct "$(cat expected)"
) &&
test_cmp expected out
'
@@ -547,7 +552,7 @@ test_expect_success '__gitcomp - equal skip' '
'
test_expect_success '__gitcomp - doesnt fail because of invalid variable name' '
- __gitcomp "$invalid_variable_name"
+ run_func __gitcomp "$invalid_variable_name"
'
read -r -d "" refs <<-\EOF
@@ -586,7 +591,7 @@ test_expect_success '__gitcomp_nl - no suffix' '
'
test_expect_success '__gitcomp_nl - doesnt fail because of invalid variable name' '
- __gitcomp_nl "$invalid_variable_name"
+ run_func __gitcomp_nl "$invalid_variable_name"
'
test_expect_success '__git_remotes - list remotes from $GIT_DIR/remotes and from config file' '
@@ -1087,8 +1092,7 @@ test_expect_success '__git_complete_refs - simple' '
EOF
(
cur= &&
- __git_complete_refs &&
- print_comp
+ run_func __git_complete_refs
) &&
test_cmp expected out
'
@@ -1100,8 +1104,7 @@ test_expect_success '__git_complete_refs - matching' '
EOF
(
cur=mat &&
- __git_complete_refs &&
- print_comp
+ run_func __git_complete_refs
) &&
test_cmp expected out
'
@@ -1114,8 +1117,7 @@ test_expect_success '__git_complete_refs - remote' '
EOF
(
cur= &&
- __git_complete_refs --remote=other &&
- print_comp
+ run_func __git_complete_refs --remote=other
) &&
test_cmp expected out
'
@@ -1133,8 +1135,7 @@ test_expect_success '__git_complete_refs - track' '
EOF
(
cur= &&
- __git_complete_refs --track &&
- print_comp
+ run_func __git_complete_refs --track
) &&
test_cmp expected out
'
@@ -1146,8 +1147,7 @@ test_expect_success '__git_complete_refs - current word' '
EOF
(
cur="--option=mat" &&
- __git_complete_refs --cur="${cur#*=}" &&
- print_comp
+ run_func __git_complete_refs --cur="${cur#*=}"
) &&
test_cmp expected out
'
@@ -1159,8 +1159,7 @@ test_expect_success '__git_complete_refs - prefix' '
EOF
(
cur=v1.0..mat &&
- __git_complete_refs --pfx=v1.0.. --cur=mat &&
- print_comp
+ run_func __git_complete_refs --pfx=v1.0.. --cur=mat
) &&
test_cmp expected out
'
@@ -1176,8 +1175,7 @@ test_expect_success '__git_complete_refs - suffix' '
EOF
(
cur= &&
- __git_complete_refs --sfx=. &&
- print_comp
+ run_func __git_complete_refs --sfx=.
) &&
test_cmp expected out
'
@@ -1190,8 +1188,7 @@ test_expect_success '__git_complete_fetch_refspecs - simple' '
EOF
(
cur= &&
- __git_complete_fetch_refspecs other &&
- print_comp
+ run_func __git_complete_fetch_refspecs other
) &&
test_cmp expected out
'
@@ -1202,8 +1199,7 @@ test_expect_success '__git_complete_fetch_refspecs - matching' '
EOF
(
cur=br &&
- __git_complete_fetch_refspecs other "" br &&
- print_comp
+ run_func __git_complete_fetch_refspecs other "" br
) &&
test_cmp expected out
'
@@ -1216,8 +1212,7 @@ test_expect_success '__git_complete_fetch_refspecs - prefix' '
EOF
(
cur="+" &&
- __git_complete_fetch_refspecs other "+" "" &&
- print_comp
+ run_func __git_complete_fetch_refspecs other "+" ""
) &&
test_cmp expected out
'
@@ -1230,8 +1225,7 @@ test_expect_success '__git_complete_fetch_refspecs - fully qualified' '
EOF
(
cur=refs/ &&
- __git_complete_fetch_refspecs other "" refs/ &&
- print_comp
+ run_func __git_complete_fetch_refspecs other "" refs/
) &&
test_cmp expected out
'
@@ -1244,8 +1238,7 @@ test_expect_success '__git_complete_fetch_refspecs - fully qualified & prefix' '
EOF
(
cur=+refs/ &&
- __git_complete_fetch_refspecs other + refs/ &&
- print_comp
+ run_func __git_complete_fetch_refspecs other + refs/
) &&
test_cmp expected out
'
@@ -1931,8 +1924,7 @@ test_path_completion ()
# unusual characters in path names. By requesting only
# untracked files we do not have to bother adding any
# paths to the index in those tests.
- __git_complete_index_file --others &&
- print_comp
+ run_func __git_complete_index_file --others
) &&
test_cmp expected out
}
@@ -2457,8 +2449,7 @@ do
words=(git push '$flag' other ma) &&
cword=${#words[@]} cur=${words[cword-1]} &&
__git_cmd_idx=1 &&
- __git_complete_remote_or_refspec &&
- print_comp
+ run_func __git_complete_remote_or_refspec
) &&
test_cmp expected out
'
@@ -2471,8 +2462,7 @@ do
words=(git push other '$flag' ma) &&
cword=${#words[@]} cur=${words[cword-1]} &&
__git_cmd_idx=1 &&
- __git_complete_remote_or_refspec &&
- print_comp
+ run_func __git_complete_remote_or_refspec
) &&
test_cmp expected out
'
Pretty straightforward: runs functions. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> --- t/t9902-completion.sh | 58 ++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 34 deletions(-)