Re: [RFC PATCH 1/3] add test for git grep --recursive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 29/09/10 13:35, Ãvar ArnfjÃrà Bjarmason wrote:
> On Wed, Sep 29, 2010 at 20:28, Chris Packham <judge.packham@xxxxxxxxx> wrote:
>> Signed-off-by: Chris Packham <judge.packham@xxxxxxxxx>
>> ---
>>  t/t7820-grep-recursive.sh |  101 +++++++++++++++++++++++++++++++++++++++++++++
>>  1 files changed, 101 insertions(+), 0 deletions(-)
>>  create mode 100644 t/t7820-grep-recursive.sh
>>
>> diff --git a/t/t7820-grep-recursive.sh b/t/t7820-grep-recursive.sh
>> new file mode 100644
>> index 0000000..4bbd109
>> --- /dev/null
>> +++ b/t/t7820-grep-recursive.sh
>> @@ -0,0 +1,101 @@
>> +#!/bin/sh
>> +#
>> +# Copyright (c) 2010 Chris Packham
>> +#
>> +
>> +test_description='git grep --recursive test
>> +
>> +This test checks the ability of git grep to search within submodules when told
>> +to do so with the --recursive option'
>> +
>> +. ./test-lib.sh
>> +
>> +test_expect_success 'setup - initial commit' '
>> +       printf "one two three\nfour five six\n" >t &&
>> +       git add t &&
>> +       git commit -m "initial commit"
>> +'
>> +submodurl=$TRASH_DIRECTORY
>> +
>> +test_expect_success 'setup submodules for test' '
>> +       for mod in $(seq 1 5 | sed "s/.*/submodule&/"); do
>> +               git submodule add "$submodurl" $mod &&
>> +               git submodule init $mod
>> +       done
>> +'
>> +
>> +test_expect_success 'update data in each submodule' '
>> +       for n in $(seq 1 5); do
> 
> seq isn't portable to windows, so we usually write out "1 2 3 4 5"
> directly.
> 
>> +               (cd submodule$n &&
>> +                       sed -i "s/^four.*/& #$n/" t &&
>> +                       git commit -a -m"update")
>> +       done
>> +'
>> +
>> +cat >expected <<EOF
>> +t:four five six
>> +EOF
>> +test_expect_success 'non-recursive grep in base' '
>> +       git grep "five" >actual &&
>> +       test_cmp expected actual
>> +'
> 
> Put the "cat >expected <<EOF" inside the test:
> 
>     test_expect_success 'non-recursive grep in base' '
>         cat >expected <<\EOF &&
>         t:four five six
>         EOF
>         git grep "five" >actual &&
>         test_cmp expected actual
>     '
> 
> ditto for the rest.

Thanks for the review, will be in next re-roll.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]