Re: [PATCH v4 2/8] [Newcomer] t7004: Do not lose exit status to pipe

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

 



On Mon, Aug 5, 2024 at 8:00 PM AbdAlRahman Gad <abdobngad@xxxxxxxxx> wrote:
> Split "test-tool ... | sed" pipeline into two commands to avoid losing
> exit status from test-tool.
>
> Signed-off-by: AbdAlRahman Gad <abdobngad@xxxxxxxxx>
> ---
> diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
> @@ -97,7 +97,8 @@ test_expect_success 'creating a tag with --create-reflog should create reflog' '
> -       test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog1 | sed -e "s/^.* //" >actual &&
> +       test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog1 >actual.body &&
> +       sed -e "s/^.*   //" actual.body >actual &&

It's not just `test_tool` we care about; we also (importantly) don't
want to see `git` itself upstream of a pipe, and there are many such
instances remaining in this script. Here are some common examples:

    test $(git tag -l | wc -l) -eq 0 &&
    git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
    git tag -l | grep "^tag-one-line" >actual &&
    forged=$(git cat-file tag ... | sed -e ... | git mktag) &&
    git tag -l --no-sort "foo*" | sort >actual &&

By the way, these days, rather than:

    test $(git tag -l | wc -l) -eq 0 &&

we would say:

    test_stdout_line_count = 0 git tag -l &&

which nicely avoids placing `git` upstream of a pipe.





[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