Re: [PATCH v2 5/6] completion: refactor __gitcomp related tests
On Fri, Nov 16, 2012 at 8:13 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
> Not asking for a re-roll but am asking for clarification so that I
> can locally update before queuing.
>
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> Lots of duplicated code!
>
> ... removed, you mean?
Show 28 quoted lines
>> No functional changes.
>>
>> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
>> ---
>> t/t9902-completion.sh | 76 ++++++++++++++++++---------------------------------
>> 1 file changed, 27 insertions(+), 49 deletions(-)
>>
>> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
>> index 59cdbfd..66c7af6 100755
>> --- a/t/t9902-completion.sh
>> +++ b/t/t9902-completion.sh
>> @@ -71,87 +71,65 @@ test_completion ()
>>
>> 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
>> +# Test __gitcomp.
>> +# Arguments are:
>> +# 1: typed text so far (cur)
>> +# *: arguments to pass to __gitcomp
>
> s/\*/remainder/, perhaps? I think you shift $1 out and do not pass
> it to __gitcomp.
Right, by * I meant the rest.
> And expected output is from the standard input just like
> test_completion?
Show 27 quoted lines
>> +test_gitcomp ()
>> +{
>> + sed -e 's/Z$//' > expected &&
>> (
>> local -a COMPREPLY &&
>> - cur="--re" &&
>> - __gitcomp "--dry-run --reuse-message= --reedit-message=
>> - --reset-author" &&
>> + cur="$1" &&
>> + shift &&
>> + __gitcomp "$@" &&
>> IFS="$newline" &&
>> echo "${COMPREPLY[*]}" > out
>> ) &&
>> test_cmp expected out
>> +}
>> +
>> +test_expect_success '__gitcomp - trailing space - options' '
>> + test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message=
>> + --reset-author" <<-EOF
>> + --reuse-message=Z
>> + --reedit-message=Z
>> + --reset-author Z
>> + EOF
>> '
>
> Nice shrinkage.That's a comment about the whole patch series I hope :)
Cheers.
--
Felipe Contreras