tests: add tests for the __gitcomp() completion helper function
These tests check that trailing space, prefix, and suffix are added correctly. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
5c293a6be4
commit
74a8c849f1
|
@ -73,6 +73,91 @@ test_completion ()
|
||||||
test_cmp expected out
|
test_cmp expected out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
(
|
||||||
|
local -a COMPREPLY &&
|
||||||
|
cur="--re" &&
|
||||||
|
__gitcomp "--dry-run --reuse-message= --reedit-message=
|
||||||
|
--reset-author" &&
|
||||||
|
IFS="$newline" &&
|
||||||
|
echo "${COMPREPLY[*]}" > out
|
||||||
|
) &&
|
||||||
|
test_cmp expected out
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success '__gitcomp - trailing space - config keys' '
|
||||||
|
sed -e "s/Z$//" >expected <<-\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 &&
|
||||||
|
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 &&
|
||||||
|
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 &&
|
||||||
|
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' '
|
test_expect_success 'basic' '
|
||||||
run_completion "git \"\"" &&
|
run_completion "git \"\"" &&
|
||||||
# built-in
|
# built-in
|
||||||
|
|
Loading…
Reference in New Issue