Re: [PATCH 15/15] t1507: teach full_name() to accept `!` arg
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Dec 17, 2019, 19:54 UTC
- Message-ID
- <CAPig+cQiNpgEURfNr91V=j2mk6Y3c28NPgKj9NigU3XFRS=ZbA@mail.gmail.com>
- In-Reply-To
- <cd392a74acb1bc7f3b09f167278afd5959a21fca.1576583819.git.liu.denton@gmail.com>
On Tue, Dec 17, 2019 at 7:02 AM Denton Liu <liu.denton@gmail.com> wrote:
Show 22 quoted lines
> 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@gmail.com>
> ---
> 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...
Show 5 quoted lines
> @@ -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.
Show 8 quoted lines
> @@ -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}
> '