Re: [PATCH 2/6] t3433: remove loops from tests

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

 



On Tue, Apr 7, 2020 at 7:11 AM Phillip Wood <phillip.wood123@xxxxxxxxx> wrote:
>
> From: Phillip Wood <phillip.wood@xxxxxxxxxxxxx>
>
> Looping inside a test is asking for trouble as we only detect any
> failure on the last iteration. Instead get all the dates at once which
> is also more efficient. Note the previous code accidentally compared the
> diffs as well as the dates this is fixed as well.

Add a semicolon between "dates" and "this" in the last sentence?

>
> Signed-off-by: Phillip Wood <phillip.wood@xxxxxxxxxxxxx>
> ---
>  t/t3433-rebase-options-compatibility.sh | 18 +++++-------------
>  1 file changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/t/t3433-rebase-options-compatibility.sh b/t/t3433-rebase-options-compatibility.sh
> index 5166f158dd..2b4d75f1ef 100755
> --- a/t/t3433-rebase-options-compatibility.sh
> +++ b/t/t3433-rebase-options-compatibility.sh
> @@ -90,13 +90,9 @@ test_expect_success '--committer-date-is-author-date works with rebase -r' '
>         git checkout side &&
>         git merge --no-ff commit3 &&
>         git rebase -r --root --committer-date-is-author-date &&
> -       git rev-list HEAD >rev_list &&
> -       while read HASH
> -       do
> -               git show $HASH --pretty="format:%ai" >authortime
> -               git show $HASH --pretty="format:%ci" >committertime
> -               test_cmp authortime committertime
> -       done <rev_list
> +       git log --pretty="format:%ai" >authortime &&
> +       git log --pretty="format:%ci" >committertime &&
> +       test_cmp authortime committertime
>  '
>
>  # Checking for +0000 in author time is enough since default
> @@ -120,12 +116,8 @@ test_expect_success '--ignore-date works with rebase -r' '
>         git checkout side &&
>         git merge --no-ff commit3 &&
>         git rebase -r --root --ignore-date &&
> -       git rev-list HEAD >rev_list &&
> -       while read HASH
> -       do
> -               git show $HASH --pretty="format:%ai" >authortime
> -               grep "+0000" authortime
> -       done <rev_list
> +       git log --pretty=%ai >authortime &&
> +       ! grep -v "+0000" authortime
>  '

The new form is much more readable (and more correct and efficient, as
you point out).  Thanks.



[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