From: Denton Liu <liu.denton@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH 2/8] t5512: generate references with generate_references()
Date: Wed, 25 Mar 2020 01:54:49 -0400 [thread overview]
Message-ID: <674de50db28a50554d7af6e5c869c427d06f78aa.1585115341.git.liu.denton@gmail.com> (raw)
In-Reply-To: <cover.1585115341.git.liu.denton@gmail.com>
The expected references are generated using a here-doc with some inline
subshells. If one of the `git rev-parse` invocations within the
subshells failed, its return code is swallowed and we won't know about
it. Replace these here-docs with generate_references(), which actually
reports when `git rev-parse` fails.
Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
t/t5512-ls-remote.sh | 50 +++++++++++++++++++-------------------------
1 file changed, 21 insertions(+), 29 deletions(-)
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index 08b98f12b8..62d02152c7 100755
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
@@ -4,6 +4,14 @@ test_description='git ls-remote'
. ./test-lib.sh
+generate_references () {
+ for i
+ do
+ oid=$(git rev-parse "$i") || return 1
+ printf '%s\t%s\n' "$oid" "$i"
+ done
+}
+
test_expect_success setup '
>file &&
git add file &&
@@ -43,34 +51,19 @@ test_expect_success 'ls-remote self' '
'
test_expect_success 'ls-remote --sort="version:refname" --tags self' '
- cat >expect <<-EOF &&
- $(git rev-parse mark) refs/tags/mark
- $(git rev-parse mark1.1) refs/tags/mark1.1
- $(git rev-parse mark1.2) refs/tags/mark1.2
- $(git rev-parse mark1.10) refs/tags/mark1.10
- EOF
+ generate_references refs/tags/mark refs/tags/mark1.1 refs/tags/mark1.2 refs/tags/mark1.10 >expect &&
git ls-remote --sort="version:refname" --tags self >actual &&
test_cmp expect actual
'
test_expect_success 'ls-remote --sort="-version:refname" --tags self' '
- cat >expect <<-EOF &&
- $(git rev-parse mark1.10) refs/tags/mark1.10
- $(git rev-parse mark1.2) refs/tags/mark1.2
- $(git rev-parse mark1.1) refs/tags/mark1.1
- $(git rev-parse mark) refs/tags/mark
- EOF
+ generate_references refs/tags/mark1.10 refs/tags/mark1.2 refs/tags/mark1.1 refs/tags/mark >expect &&
git ls-remote --sort="-version:refname" --tags self >actual &&
test_cmp expect actual
'
test_expect_success 'ls-remote --sort="-refname" --tags self' '
- cat >expect <<-EOF &&
- $(git rev-parse mark1.2) refs/tags/mark1.2
- $(git rev-parse mark1.10) refs/tags/mark1.10
- $(git rev-parse mark1.1) refs/tags/mark1.1
- $(git rev-parse mark) refs/tags/mark
- EOF
+ generate_references refs/tags/mark1.2 refs/tags/mark1.10 refs/tags/mark1.1 refs/tags/mark >expect &&
git ls-remote --sort="-refname" --tags self >actual &&
test_cmp expect actual
'
@@ -212,17 +205,16 @@ test_expect_success 'protocol v2 supports hiderefs' '
test_expect_success 'ls-remote --symref' '
git fetch origin &&
- cat >expect <<-EOF &&
- ref: refs/heads/master HEAD
- $(git rev-parse HEAD) HEAD
- $(git rev-parse refs/heads/master) refs/heads/master
- $(git rev-parse HEAD) refs/remotes/origin/HEAD
- $(git rev-parse refs/remotes/origin/master) refs/remotes/origin/master
- $(git rev-parse refs/tags/mark) refs/tags/mark
- $(git rev-parse refs/tags/mark1.1) refs/tags/mark1.1
- $(git rev-parse refs/tags/mark1.10) refs/tags/mark1.10
- $(git rev-parse refs/tags/mark1.2) refs/tags/mark1.2
- EOF
+ echo "ref: refs/heads/master HEAD" >expect &&
+ generate_references HEAD \
+ refs/heads/master >>expect &&
+ oid=$(git rev-parse HEAD) &&
+ echo "$oid refs/remotes/origin/HEAD" >>expect &&
+ generate_references refs/remotes/origin/master \
+ refs/tags/mark \
+ refs/tags/mark1.1 \
+ refs/tags/mark1.10 \
+ refs/tags/mark1.2 >>expect &&
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
# protocol v0 here.
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref >actual &&
--
2.25.0.114.g5b0ca878e0
next prev parent reply other threads:[~2020-03-25 5:55 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 ` Denton Liu [this message]
2020-03-25 6:08 ` [PATCH 2/8] t5512: generate references with generate_references() 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 ` [PATCH v2 8/8] t5801: teach compare_refs() to accept ! Denton Liu
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=674de50db28a50554d7af6e5c869c427d06f78aa.1585115341.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).