completion: refactor __gitcomp related tests
Remove lots of duplicated code; no functional changes intended. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
2fbaf81381
commit
e461523892
@ -72,87 +72,65 @@ test_completion ()
|
||||
|
||||
newline=$'\n'
|
||||
|
||||
test_expect_success '__gitcomp - trailing space - options' '
|
||||
sed -e "s/Z$//" >expected <<-\EOF &&
|
||||
--reuse-message=Z
|
||||
--reedit-message=Z
|
||||
--reset-author Z
|
||||
EOF
|
||||
# Test __gitcomp.
|
||||
# The first argument is the typed text so far (cur); the rest are
|
||||
# passed to __gitcomp. Expected output comes is read from the
|
||||
# standard input, like test_completion().
|
||||
test_gitcomp ()
|
||||
{
|
||||
sed -e 's/Z$//' >expected &&
|
||||
(
|
||||
local -a COMPREPLY &&
|
||||
cur="--re" &&
|
||||
__gitcomp "--dry-run --reuse-message= --reedit-message=
|
||||
--reset-author" &&
|
||||
cur="$1" &&
|
||||
shift &&
|
||||
__gitcomp "$@" &&
|
||||
IFS="$newline" &&
|
||||
echo "${COMPREPLY[*]}" >out
|
||||
) &&
|
||||
test_cmp expected out
|
||||
}
|
||||
|
||||
test_expect_success '__gitcomp - trailing space - options' '
|
||||
test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message=
|
||||
--reset-author" <<-EOF
|
||||
--reuse-message=Z
|
||||
--reedit-message=Z
|
||||
--reset-author Z
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_success '__gitcomp - trailing space - config keys' '
|
||||
sed -e "s/Z$//" >expected <<-\EOF &&
|
||||
test_gitcomp "br" "branch. branch.autosetupmerge
|
||||
branch.autosetuprebase browser." <<-\EOF
|
||||
branch.Z
|
||||
branch.autosetupmerge Z
|
||||
branch.autosetuprebase Z
|
||||
browser.Z
|
||||
EOF
|
||||
(
|
||||
local -a COMPREPLY &&
|
||||
cur="br" &&
|
||||
__gitcomp "branch. branch.autosetupmerge
|
||||
branch.autosetuprebase browser." &&
|
||||
IFS="$newline" &&
|
||||
echo "${COMPREPLY[*]}" > out
|
||||
) &&
|
||||
test_cmp expected out
|
||||
'
|
||||
|
||||
test_expect_success '__gitcomp - option parameter' '
|
||||
sed -e "s/Z$//" >expected <<-\EOF &&
|
||||
test_gitcomp "--strategy=re" "octopus ours recursive resolve subtree" \
|
||||
"" "re" <<-\EOF
|
||||
recursive Z
|
||||
resolve Z
|
||||
EOF
|
||||
(
|
||||
local -a COMPREPLY &&
|
||||
cur="--strategy=re" &&
|
||||
__gitcomp "octopus ours recursive resolve subtree
|
||||
" "" "re" &&
|
||||
IFS="$newline" &&
|
||||
echo "${COMPREPLY[*]}" > out
|
||||
) &&
|
||||
test_cmp expected out
|
||||
'
|
||||
|
||||
test_expect_success '__gitcomp - prefix' '
|
||||
sed -e "s/Z$//" >expected <<-\EOF &&
|
||||
test_gitcomp "branch.me" "remote merge mergeoptions rebase" \
|
||||
"branch.maint." "me" <<-\EOF
|
||||
branch.maint.merge Z
|
||||
branch.maint.mergeoptions Z
|
||||
EOF
|
||||
(
|
||||
local -a COMPREPLY &&
|
||||
cur="branch.me" &&
|
||||
__gitcomp "remote merge mergeoptions rebase
|
||||
" "branch.maint." "me" &&
|
||||
IFS="$newline" &&
|
||||
echo "${COMPREPLY[*]}" > out
|
||||
) &&
|
||||
test_cmp expected out
|
||||
'
|
||||
|
||||
test_expect_success '__gitcomp - suffix' '
|
||||
sed -e "s/Z$//" >expected <<-\EOF &&
|
||||
test_gitcomp "branch.me" "master maint next pu" "branch." \
|
||||
"ma" "." <<-\EOF
|
||||
branch.master.Z
|
||||
branch.maint.Z
|
||||
EOF
|
||||
(
|
||||
local -a COMPREPLY &&
|
||||
cur="branch.me" &&
|
||||
__gitcomp "master maint next pu
|
||||
" "branch." "ma" "." &&
|
||||
IFS="$newline" &&
|
||||
echo "${COMPREPLY[*]}" > out
|
||||
) &&
|
||||
test_cmp expected out
|
||||
'
|
||||
|
||||
test_expect_success 'basic' '
|
||||
|
Loading…
Reference in New Issue
Block a user