Re: [PATCH 15/15] t1507: teach full_name() to accept `!` arg

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

 



On Tue, Dec 17, 2019 at 7:02 AM Denton Liu <liu.denton@xxxxxxxxx> wrote:
> Before, we were running `test_must_fail full_name`. However,
> `test_must_fail` should only be used on git commands. Teach full_name()
> to accept `!` as a potential first argument which will prepend
> `test_must_fail` to the enclosed git command. This increases the
> granularity of test_must_fail since it no longer runs on the `cd` as
> well.
>
> Signed-off-by: Denton Liu <liu.denton@xxxxxxxxx>
> ---
> diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh
> @@ -29,8 +29,14 @@ test_expect_success 'setup' '
>  full_name () {
> +       fail= &&
> +       if test "x$1" = 'x!'
> +       then
> +               fail=test_must_fail &&
> +               shift
> +       fi &&
>         (cd clone &&
> -        git rev-parse --symbolic-full-name "$@")
> +        $fail git rev-parse --symbolic-full-name "$@")
>  }

Yuck. These days this is entirely unnecessary. My suggestion is to
drop the full_name() function altogether and just invoke git-rev-parse
directly at the (few) call sites, taking advantage of the fact that we
now have -C. So...

> @@ -79,7 +85,7 @@ test_expect_success 'upstream of branch with @ at end' '
>  test_expect_success 'refs/heads/my-side@{upstream} does not resolve to my-side{upstream}' '
> -       test_must_fail full_name refs/heads/my-side@{upstream}
> +       full_name ! refs/heads/my-side@{upstream}
>  '

This just becomes:

    test_must_fail git -C clone rev-parse --symbolic-full-name
refs/heads/my-side@{upstream}

Similarly for the other call sites.

> @@ -91,9 +97,9 @@ test_expect_success 'my-side@{u} resolves to correct commit' '
>  test_expect_success 'not-tracking@{u} fails' '
> -       test_must_fail full_name non-tracking@{u} &&
> +       full_name ! non-tracking@{u} &&
>         (cd clone && git checkout --no-track -b non-tracking) &&
> -       test_must_fail full_name non-tracking@{u}
> +       full_name ! non-tracking@{u}
>  '



[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