From: "Justin Tobler via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Justin Tobler <jltobler@gmail.com>, Justin Tobler <jltobler@gmail.com>
Subject: [PATCH 1/2] t1401: generalize reference locking
Date: Wed, 10 Jan 2024 18:52:29 +0000 [thread overview]
Message-ID: <cb78b549e5e826ffef39c55bd726164e6b7bb755.1704912750.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1634.git.1704912750.gitgitgadget@gmail.com>
From: Justin Tobler <jltobler@gmail.com>
Some tests set up reference locks by directly creating the lockfile.
While this works for the files reference backend, reftable reference
locks operate differently and are incompatible with this approach.
Refactor the test to use git-update-ref(1) to lock refs instead so that
the test does not need to be aware of how the ref backend locks refs.
Signed-off-by: Justin Tobler <jltobler@gmail.com>
---
t/t1401-symbolic-ref.sh | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh
index c7745e1bf69..bafe8db24df 100755
--- a/t/t1401-symbolic-ref.sh
+++ b/t/t1401-symbolic-ref.sh
@@ -105,10 +105,30 @@ test_expect_success LONG_REF 'we can parse long symbolic ref' '
test_cmp expect actual
'
-test_expect_success 'symbolic-ref reports failure in exit code' '
- test_when_finished "rm -f .git/HEAD.lock" &&
- >.git/HEAD.lock &&
- test_must_fail git symbolic-ref HEAD refs/heads/whatever
+test_expect_success PIPE 'symbolic-ref reports failure in exit code' '
+ mkfifo in out &&
+ (git update-ref --stdin <in >out &) &&
+
+ exec 9>in &&
+ exec 8<out &&
+ test_when_finished "exec 9>&-" &&
+ test_when_finished "exec 8<&-" &&
+
+ echo "start" >&9 &&
+ echo "start: ok" >expected &&
+ read line <&8 &&
+ echo "$line" >actual &&
+ test_cmp expected actual &&
+
+ echo "update HEAD refs/heads/foo" >&9 &&
+
+ echo "prepare" >&9 &&
+ echo "prepare: ok" >expected &&
+ read line <&8 &&
+ echo "$line" >actual &&
+ test_cmp expected actual &&
+
+ test_must_fail git symbolic-ref HEAD refs/heads/bar
'
test_expect_success 'symbolic-ref writes reflog entry' '
--
gitgitgadget
next prev parent reply other threads:[~2024-01-10 18:52 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-10 18:52 [PATCH 0/2] Generalize reference locking in tests Justin Tobler via GitGitGadget
2024-01-10 18:52 ` Justin Tobler via GitGitGadget [this message]
2024-01-11 7:13 ` [PATCH 1/2] t1401: generalize reference locking Jeff King
2024-01-11 11:08 ` Patrick Steinhardt
2024-01-12 7:01 ` Jeff King
2024-01-12 7:45 ` Patrick Steinhardt
2024-01-12 8:03 ` Jeff King
2024-01-11 20:19 ` Justin Tobler
2024-01-10 18:52 ` [PATCH 2/2] t5541: " Justin Tobler via GitGitGadget
2024-01-11 7:28 ` Jeff King
2024-01-11 18:47 ` Junio C Hamano
2024-01-11 20:20 ` Justin Tobler
2024-01-11 0:36 ` [PATCH 0/2] Generalize reference locking in tests Junio C Hamano
2024-01-11 20:20 ` Justin Tobler
2024-01-11 20:24 ` [PATCH v2 " Justin Tobler via GitGitGadget
2024-01-11 20:24 ` [PATCH v2 1/2] t1401: remove lockfile creation Justin Tobler via GitGitGadget
2024-01-11 20:24 ` [PATCH v2 2/2] t5541: " Justin Tobler via GitGitGadget
2024-01-12 7:03 ` Jeff King
2024-01-12 17:58 ` Junio C Hamano
2024-01-13 22:25 ` Justin Tobler
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=cb78b549e5e826ffef39c55bd726164e6b7bb755.1704912750.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=jltobler@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).