Skip to content

Commit

Permalink
completion: simplify __gitcomp() test helper
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Felipe Contreras authored and Junio C Hamano committed Nov 16, 2012
1 parent e461523 commit 1739303
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions t/t9902-completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 1739303

Please sign in to comment.