From: SZEDER Gábor Date: Tue, 17 Apr 2012 10:27:15 +0000 (+0200) Subject: tests: add tests for the __gitcomp() completion helper function X-Git-Tag: v1.7.11-rc0~104^2~5 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=74a8c849f1257dde0c42feac95ba517bae625647;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index a6eaa15c1..de1c3e91d 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -73,6 +73,91 @@ test_completion () 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' ' run_completion "git \"\"" && # built-in