Re: [PATCH v3 8/8] update-ref: add test cases covering --stdin signature

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

 



On Mon, Sep 2, 2013 at 1:48 PM, Brad King <brad.king@xxxxxxxxxxx> wrote:
> Extend t/t1400-update-ref.sh to cover cases using the --stdin option.
>
> Signed-off-by: Brad King <brad.king@xxxxxxxxxxx>
> ---
>  t/t1400-update-ref.sh |  256 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 256 insertions(+)
>
> diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
> index e415ee0..b6d7dfa 100755
> --- a/t/t1400-update-ref.sh
> +++ b/t/t1400-update-ref.sh
> @@ -302,4 +302,260 @@ test_expect_success \
>         'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \
>         'test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F")'
>
> +a=refs/heads/a
> +b=refs/heads/b
> +c=refs/heads/c
> +z=0000000000000000000000000000000000000000
> +e='""'
> +pws='path with space'
> +
> +test_expect_success 'stdin fails on bad input line with only whitespace' '
> +       echo " " >stdin &&
> +       test_must_fail git update-ref --stdin <stdin 2>err &&
> +       grep "fatal: no ref on line:  " err
> +'
> +
> +test_expect_success 'stdin fails on bad input line with only --' '
> +       echo "--" >stdin &&
> +       test_must_fail git update-ref --stdin <stdin 2>err &&
> +       grep "fatal: no ref on line: --" err
> +'
> +
> +test_expect_success 'stdin fails on bad input line with only --bad-option' '
> +       echo "--bad-option" >stdin &&
> +       test_must_fail git update-ref --stdin <stdin 2>err &&
> +       grep "fatal: unknown option --bad-option" err
> +'

When you decomposed the monolithic test from v1 into individual tests,
you dropped a couple cases ("fatal: unknown option'" and "fatal:
unterminated single-quote"). Was this intentional?

> +test_expect_success 'stdin fails with duplicate refs' '
> +       cat >stdin <<-EOF &&
> +$a $m
> +$b $m
> +$a $m
> +EOF
> +       test_must_fail git update-ref --stdin <stdin 2>err &&
> +       grep "fatal: Multiple updates for ref '"'"'$a'"'"' not allowed." err
> +'

The leading '-' on '-EOF' allows you to indent the content of the
heredoc and the terminating EOF, which makes the test read nicely:

    test_expect_success 'stdin fails with duplicate refs' '
        cat >stdin <<-EOF &&
        $a $m
        $b $m
        $a $m
        EOF
        test_must_fail git update-ref ...
    '

> +
> +test_expect_success 'stdin create ref works with no old value' '
> +       echo "$a $m" >stdin &&
> +       git update-ref --stdin <stdin &&
> +       git rev-parse $m >expect &&
> +       git rev-parse $a >actual &&
> +       test_cmp expect actual
> +'
--
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]