Thread (58 messages) 58 messages, 3 authors, 2019-12-20

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

From: Eric Sunshine <hidden>
Date: 2019-12-17 19:54:50

On Tue, Dec 17, 2019 at 7:02 AM Denton Liu [off-list ref] wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
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...
quoted hunk ↗ jump to hunk
@@ -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.
quoted hunk ↗ jump to hunk
@@ -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}
 '
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help