All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denton Liu <liu.denton@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH v2 8/8] t5801: teach compare_refs() to accept !
Date: Thu, 26 Mar 2020 04:27:55 -0400	[thread overview]
Message-ID: <6a9d3cef2a0daf1b058921bd0cd3397f7753e537.1585209554.git.liu.denton@gmail.com> (raw)
In-Reply-To: <cover.1585209554.git.liu.denton@gmail.com>

Before, testing if two refs weren't equal with compare_refs() was done
with `test_must_fail compare_refs`. This was wrong for two reasons.
First, test_must_fail should only be used on git commands. Second,
negating the error code is a little heavy-handed since in the case where
one of the git invocations within compare_refs() fails, we will report
success, even though it failed at an unexpected point.

Teach compare_refs() to accept `!` as the first argument which would
_only_ negate the test_cmp()'s return code.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 t/t5801-remote-helpers.sh | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 121e5c6edb..0f04b6cddb 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -11,9 +11,15 @@ test_description='Test remote-helper import and export commands'
 PATH="$TEST_DIRECTORY/t5801:$PATH"
 
 compare_refs() {
+	fail= &&
+	if test "x$1" = 'x!'
+	then
+		fail='!' &&
+		shift
+	fi &&
 	git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
 	git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
-	test_cmp expect actual
+	eval $fail test_cmp expect actual
 }
 
 test_expect_success 'setup repository' '
@@ -189,7 +195,7 @@ test_expect_success GPG 'push signed tag' '
 	git push origin signed-tag
 	) &&
 	compare_refs local signed-tag^{} server signed-tag^{} &&
-	test_must_fail compare_refs local signed-tag server signed-tag
+	compare_refs ! local signed-tag server signed-tag
 '
 
 test_expect_success GPG 'push signed tag with signed-tags capability' '
-- 
2.26.0.159.g23e2136ad0


  parent reply	other threads:[~2020-03-26  8:28 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25  5:54 [PATCH 0/8] t: replace incorrect test_must_fail usage (part 3) Denton Liu
2020-03-25  5:54 ` [PATCH 1/8] t5512: don't use `test_must_fail test_cmp` Denton Liu
2020-03-25  5:54 ` [PATCH 2/8] t5512: generate references with generate_references() Denton Liu
2020-03-25  6:08   ` Eric Sunshine
2020-03-25  6:41   ` Junio C Hamano
2020-03-25  5:54 ` [PATCH 3/8] t5512: stop losing return codes of git commands Denton Liu
2020-03-25  5:54 ` [PATCH 4/8] t5550: remove use of `test_might_fail grep` Denton Liu
2020-03-25  6:35   ` Junio C Hamano
2020-03-25  5:54 ` [PATCH 5/8] t5607: reorder `nongit test_must_fail` Denton Liu
2020-03-25  5:54 ` [PATCH 6/8] t5612: don't use `test_must_fail test_cmp` Denton Liu
2020-03-25  5:54 ` [PATCH 7/8] t5612: stop losing return codes of git commands Denton Liu
2020-03-25  5:54 ` [PATCH 8/8] t5801: teach compare_refs() to accept ! Denton Liu
2020-03-25  6:31   ` Junio C Hamano
2020-03-25  6:36     ` Eric Sunshine
2020-03-25  6:43 ` [PATCH 0/8] t: replace incorrect test_must_fail usage (part 3) Junio C Hamano
2020-03-26  8:27 ` [PATCH v2 " Denton Liu
2020-03-26  8:27   ` [PATCH v2 1/8] t5512: don't use `test_must_fail test_cmp` Denton Liu
2020-03-26  8:27   ` [PATCH v2 2/8] t5512: stop losing git exit code in here-docs Denton Liu
2020-03-26 15:24     ` Eric Sunshine
2020-03-26  8:27   ` [PATCH v2 3/8] t5512: stop losing return codes of git commands Denton Liu
2020-03-26  8:27   ` [PATCH v2 4/8] t5550: simplify no matching line check Denton Liu
2020-03-26 15:26     ` Eric Sunshine
2020-03-26  8:27   ` [PATCH v2 5/8] t5607: reorder `nongit test_must_fail` Denton Liu
2020-03-26  8:27   ` [PATCH v2 6/8] t5612: don't use `test_must_fail test_cmp` Denton Liu
2020-03-26  8:27   ` [PATCH v2 7/8] t5612: stop losing return codes of git commands Denton Liu
2020-03-26  8:27   ` Denton Liu [this message]
2020-03-27  0:43   ` [PATCH v2 9/9] fixup! t5512: stop losing git exit code in here-docs Denton Liu
2020-03-27 17:46     ` Junio C Hamano
2020-03-27 20:29       ` Eric Sunshine
2020-03-27 21:39         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a9d3cef2a0daf1b058921bd0cd3397f7753e537.1585209554.git.liu.denton@gmail.com \
    --to=liu.denton@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.