Clean up two issues in the tests I added in 74a8c849 (tests: add tests
for the __gitcomp() completion helper function, 2012-04-17):
- The COMPREPLY array is created using 'local -a' while in a
subshell. However, the local keyword should only be used in a
shell function, and a variable created in a subshell is by
definition local to that subshell. Use 'declare -a' instead.
- The contents of the COMPREPLY array is written through an IFS
fiddling + echo + redirection combo, although there is the
print_comp() helper function for exactly this purpose.
Signed-off-by: SZEDER Gábor
---
t/t9902-completion.sh | 27 ++-
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index cbd0fb66..cc375ed0 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -70,8 +70,6 @@ test_completion_long ()
test_completion "$1"
}
-newline=$'\n'
-
test_expect_success '__gitcomp - trailing space - options' '
sed -e "s/Z$//" >expected <<-\EOF &&
--reuse-message=Z
@@ -79,12 +77,11 @@ test_expect_success '__gitcomp - trailing space - options' '
--reset-author Z
EOF
(
- local -a COMPREPLY &&
+ declare -a COMPREPLY &&
cur="--re" &&
__gitcomp "--dry-run --reuse-message= --reedit-message=
--reset-author" &&
- IFS="$newline" &&
- echo "${COMPREPLY[*]}" > out
+ print_comp
) &&
test_cmp expected out
'
@@ -97,12 +94,11 @@ test_expect_success '__gitcomp - trailing space - config
keys' '
browser.Z
EOF
(
- local -a COMPREPLY &&
+ declare -a COMPREPLY &&
cur="br" &&
__gitcomp "branch. branch.autosetupmerge
branch.autosetuprebase browser." &&
- IFS="$newline" &&
- echo "${COMPREPLY[*]}" > out
+ print_comp
) &&
test_cmp expected out
'
@@ -113,12 +109,11 @@ test_expect_success '__gitcomp - option parameter' '
resolve Z
EOF
(
- local -a COMPREPLY &&
+ declare -a COMPREPLY &&
cur="--strategy=re" &&
__gitcomp "octopus ours recursive resolve subtree
" "" "re" &&
- IFS="$newline" &&
- echo "${COMPREPLY[*]}" > out
+ print_comp
) &&
test_cmp expected out
'
@@ -129,12 +124,11 @@ test_expect_success '__gitcomp - prefix' '
branch.maint.mergeoptions Z
EOF
(
- local -a COMPREPLY &&
+ declare -a COMPREPLY &&
cur="branch.me" &&
__gitcomp "remote merge mergeoptions rebase
" "branch.maint." "me" &&
- IFS="$newline" &&
- echo "${COMPREPLY[*]}" > out
+ print_comp
) &&
test_cmp expected out
'
@@ -145,12 +139,11 @@ test_expect_success '__gitcomp - suffix' '
branch.maint.Z
EOF
(
- local -a COMPREPLY &&
+ declare -a COMPREPLY &&
cur="branch.me" &&
__gitcomp "master maint next pu
" "branch." "ma" "." &&
- IFS="$newline" &&
- echo "${COMPREPLY[*]}" > out
+ print_comp
) &&
test_cmp expected out
'
--
1.8.0.rc0.83.gc8e1777
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html