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

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

 



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.
--
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]