completion: simplify __gitcomp() test helper
authorFelipe Contreras <felipe.contreras@gmail.com>
Sun, 11 Nov 2012 14:35:58 +0000 (15:35 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Nov 2012 19:18:53 +0000 (11:18 -0800)
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>
t/t9902-completion.sh

index f754de31221d2fd8f2b2fc23186031a09e463882..96542b5c5245918570be45e0a158adac5fcb12e8 100755 (executable)
@@ -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
 }