git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Christian Couder <christian.couder@gmail.com>
To: Shubham Mishra <shivam828787@gmail.com>
Cc: git <git@vger.kernel.org>, Taylor Blau <me@ttaylorr.com>
Subject: Re: [PATCH 1/2] t0001: remove pipes
Date: Tue, 22 Feb 2022 21:32:30 +0100	[thread overview]
Message-ID: <CAP8UFD1FVuoe7V3JU+hExsbjWTkNZFCZFV4qc65YLd4ow-Da5w@mail.gmail.com> (raw)
In-Reply-To: <20220222114313.14921-2-shivam828787@gmail.com>

On Tue, Feb 22, 2022 at 3:08 PM Shubham Mishra <shivam828787@gmail.com> 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@gmail.com>
> ---
>  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
>

  parent reply	other threads:[~2022-02-22 20:32 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 11:43 [PATCH 0/2] microproject: avoid using pipes in test Shubham Mishra
2022-02-22 11:43 ` [PATCH 1/2] t0001: remove pipes Shubham Mishra
2022-02-22 13:54   ` Derrick Stolee
2022-02-22 18:16     ` Shubham Mishra
2022-02-22 20:32   ` Christian Couder [this message]
2022-02-23 21:07     ` Junio C Hamano
2022-02-24  3:28       ` Christian Couder
2022-02-22 11:43 ` [PATCH 2/2] t0003: " Shubham Mishra
2022-02-22 13:50 ` [PATCH 0/2] microproject: avoid using pipes in test Derrick Stolee
2022-02-22 14:24 ` Ævar Arnfjörð Bjarmason
2022-02-22 19:12   ` Shubham Mishra
2022-02-22 19:39   ` Taylor Blau
2022-02-23 11:53 ` [PATCH v2 0/2] avoid pipes with Git on LHS Shubham Mishra
2022-02-23 11:53   ` [PATCH v2 1/2] t0001: " Shubham Mishra
2022-02-23 17:53     ` Taylor Blau
2022-02-23 18:01       ` Shubham Mishra
2022-02-23 18:02         ` Taylor Blau
2022-02-23 21:10     ` Junio C Hamano
2022-02-24  5:14       ` Shubham Mishra
2022-02-23 11:53   ` [PATCH v2 2/2] t0003: " Shubham Mishra
2022-02-23 17:54     ` Taylor Blau
2022-02-23 19:59       ` Shubham Mishra
2022-02-23 12:08   ` [PATCH v2 0/2] " Shubham Mishra
2022-02-23 13:19     ` Shaoxuan Yuan
2022-02-23 18:01       ` Taylor Blau
2022-02-23 20:04         ` Shubham Mishra
2022-02-24  3:43 ` [PATCH 0/2] microproject: avoid using pipes in test Christian Couder
2022-02-24  5:22   ` Shubham Mishra
2022-02-24  9:29     ` Christian Couder
2022-02-24 10:13       ` Shubham Mishra
2022-02-24 18:22         ` Christian Couder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAP8UFD1FVuoe7V3JU+hExsbjWTkNZFCZFV4qc65YLd4ow-Da5w@mail.gmail.com \
    --to=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=me@ttaylorr.com \
    --cc=shivam828787@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).