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 Mon, Jul 2, 2018 at 2:14 PM Stefan Beller <sbeller@xxxxxxxxxx> wrote:
> On Sun, Jul 1, 2018 at 5:25 PM Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote:
> >  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)

I did consider dropping the subshell in favor of -C, however, decided
to keep it since the subshell has value by making it very explicit to
the reader that this git-grep command is running in a subdirectory
(which is what this test is all about). Contrast that with -C which is
easy to overlook and might not fully convince the reader that the
command's entire execution is within the subdirectory, whereas there
is no question that the entire execution of git-diff in "(cd s &&
git-diff ...)" occurs in the subdirectory.

I can make the test_must_be_empty() change if I re-roll.



[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