Re: [PATCH 1/2] t0001: remove pipes

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

 



On Tue, Feb 22, 2022 at 3:08 PM Shubham Mishra <shivam828787@xxxxxxxxx> wrote:
>
> pipes doesn't care about error codes and ignore them thus we should not use them in tests.

Only the exit code of the command before the pipe is ignored.

Also it's ok to use pipes if the command before the pipe is not `git`.
We trust regular commands to just work and we test only `git`.

> As an easy alternative, I am using a tmp file to write from git command so we can test the exit code.

In general, when improving the code in a way that has already been
used by others, it's a good idea to take a look at previous commits
doing the same thing. See for example 66c0c44df6 (t0000: avoid masking
git exit value through pipes, 2021-09-16). I am not saying that you
should copy paste the commit message though.

> Signed-off-by: Shubham Mishra <shivam828787@xxxxxxxxx>
> ---
>  t/t0001-init.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> index 3235ab4d53..9a8f209648 100755
> --- a/t/t0001-init.sh
> +++ b/t/t0001-init.sh
> @@ -489,11 +489,11 @@ test_expect_success 're-init from a linked worktree' '
>                 git worktree add ../linked-worktree &&
>                 mv .git/info/exclude expected-exclude &&
>                 cp .git/config expected-config &&
> -               find .git/worktrees -print | sort >expected &&
> +               find .git/worktrees -print >tmp && sort tmp >expected &&

Please put the `find` and `sort` commands on 2 different lines when
they are separated with &&.

>                 git -C ../linked-worktree init &&
>                 test_cmp expected-exclude .git/info/exclude &&
>                 test_cmp expected-config .git/config &&
> -               find .git/worktrees -print | sort >actual &&
> +               find .git/worktrees -print >tmp && sort tmp >actual &&

Idem.

>                 test_cmp expected actual
>         )
>  '
> --
> 2.25.1
>



[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