completion: simplify __gitcomp() test helper

By using print_comp as suggested by SZEDER Gábor.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Felipe Contreras 2012-11-11 15:35:58 +01:00 коммит произвёл Junio C Hamano
Родитель e461523892
Коммит 173930330a
1 изменённых файлов: 5 добавлений и 10 удалений

Просмотреть файл

@ -70,23 +70,18 @@ test_completion ()
test_cmp expected out
}
newline=$'\n'
# 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 ()
{
local -a COMPREPLY &&
sed -e 's/Z$//' >expected &&
(
local -a COMPREPLY &&
cur="$1" &&
shift &&
__gitcomp "$@" &&
IFS="$newline" &&
echo "${COMPREPLY[*]}" >out
) &&
cur="$1" &&
shift &&
__gitcomp "$@" &&
print_comp &&
test_cmp expected out
}