Re: [PATCH 12/25] t7810: use test_expect_code() instead of hand-rolled comparison

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

 



On Sun, Jul 1, 2018 at 5:25 PM Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote:
>
> This test manually checks the exit code of git-grep for a particular
> value. In doing so, it intentionally breaks the &&-chain. Modernize the
> test by taking advantage of test_expect_code() and a normal &&-chain.
>
> Signed-off-by: Eric Sunshine <sunshine@xxxxxxxxxxxxxx>
> ---
>  t/t7810-grep.sh | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
> index 1797f632a3..fecee602c1 100755
> --- a/t/t7810-grep.sh
> +++ b/t/t7810-grep.sh
> @@ -845,10 +845,9 @@ test_expect_success 'grep from a subdirectory to search wider area (1)' '
>  test_expect_success 'grep from a subdirectory to search wider area (2)' '
>         mkdir -p s &&
>         (
> -               cd s || exit 1
> -               ( git grep xxyyzz .. >out ; echo $? >status )
> -               ! test -s out &&
> -               test 1 = $(cat status)
> +               cd s &&
> +               test_expect_code 1 git grep xxyyzz .. >out &&
> +               ! test -s out
>         )

Further optimisation would be possible if I understand the code correctly:

    test_expect_code git -C s grep xxyyzz .. >../out
    test_must_be_empty out

(dropping the subshell entirely)


>  '
>
> --
> 2.18.0.203.gfac676dfb9
>



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

  Powered by Linux