Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiang Xin <worldhello.net@gmail.com>2021-06-17 06:17:25 +0300
committerJunio C Hamano <gitster@pobox.com>2021-06-17 08:12:21 +0300
commit2bafb3d702d4cd77de0d3e68f13188980e0de734 (patch)
tree6f394212728100328ee3baa90c79298fdd5d272e /t/t6020-bundle-misc.sh
parent5210225f256d01938960d439bff9d809c2ff1809 (diff)
test: compare raw output, not mangle tabs and spaces
Before comparing with the expect file, we used to call function "make_user_friendly_and_stable_output" to filter out trailing spaces in output. Ævar recommends using pattern "s/Z$//" to prepare expect file, and then compare it with raw output. Since we have fixed the issue of occasionally missing the clear-to-eol suffix when displaying sideband #2 messages, it is safe and stable to test against raw output. Suggested-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t6020-bundle-misc.sh')
-rwxr-xr-xt/t6020-bundle-misc.sh45
1 files changed, 24 insertions, 21 deletions
diff --git a/t/t6020-bundle-misc.sh b/t/t6020-bundle-misc.sh
index 881f72fd44..cf13bcc3c8 100755
--- a/t/t6020-bundle-misc.sh
+++ b/t/t6020-bundle-misc.sh
@@ -82,7 +82,7 @@ test_commit_setvar () {
# Format the output of git commands to make a user-friendly and stable
# text. We can easily prepare the expect text without having to worry
-# about future changes of the commit ID and spaces of the output.
+# about future changes of the commit ID.
make_user_friendly_and_stable_output () {
sed \
-e "s/${A%${A#???????}}[0-9a-f]*/<COMMIT-A>/g" \
@@ -103,8 +103,11 @@ make_user_friendly_and_stable_output () {
-e "s/${P%${P#???????}}[0-9a-f]*/<COMMIT-P>/g" \
-e "s/${TAG1%${TAG1#???????}}[0-9a-f]*/<TAG-1>/g" \
-e "s/${TAG2%${TAG2#???????}}[0-9a-f]*/<TAG-2>/g" \
- -e "s/${TAG3%${TAG3#???????}}[0-9a-f]*/<TAG-3>/g" \
- -e "s/ *\$//"
+ -e "s/${TAG3%${TAG3#???????}}[0-9a-f]*/<TAG-3>/g"
+}
+
+format_and_save_expect () {
+ sed -e 's/Z$//' >expect
}
# (C) (D, pull/1/head, topic/1)
@@ -179,11 +182,11 @@ test_expect_success 'create bundle from special rev: main^!' '
git bundle verify special-rev.bdl |
make_user_friendly_and_stable_output >actual &&
- cat >expect <<-\EOF &&
+ format_and_save_expect <<-\EOF &&
The bundle contains this ref:
<COMMIT-P> refs/heads/main
The bundle requires this ref:
- <COMMIT-O>
+ <COMMIT-O> Z
EOF
test_cmp expect actual &&
@@ -200,12 +203,12 @@ test_expect_success 'create bundle with --max-count option' '
git bundle verify max-count.bdl |
make_user_friendly_and_stable_output >actual &&
- cat >expect <<-\EOF &&
+ format_and_save_expect <<-\EOF &&
The bundle contains these 2 refs:
<COMMIT-P> refs/heads/main
<TAG-1> refs/tags/v1
The bundle requires this ref:
- <COMMIT-O>
+ <COMMIT-O> Z
EOF
test_cmp expect actual &&
@@ -225,7 +228,7 @@ test_expect_success 'create bundle with --since option' '
git bundle verify since.bdl |
make_user_friendly_and_stable_output >actual &&
- cat >expect <<-\EOF &&
+ format_and_save_expect <<-\EOF &&
The bundle contains these 5 refs:
<COMMIT-P> refs/heads/main
<COMMIT-N> refs/heads/release
@@ -233,8 +236,8 @@ test_expect_success 'create bundle with --since option' '
<TAG-3> refs/tags/v3
<COMMIT-P> HEAD
The bundle requires these 2 refs:
- <COMMIT-M>
- <COMMIT-K>
+ <COMMIT-M> Z
+ <COMMIT-K> Z
EOF
test_cmp expect actual &&
@@ -293,13 +296,13 @@ test_expect_success 'create bundle 2 - has prerequisites' '
--stdin \
release <input &&
- cat >expect <<-\EOF &&
+ format_and_save_expect <<-\EOF &&
The bundle contains this ref:
<COMMIT-N> refs/heads/release
The bundle requires these 3 refs:
- <COMMIT-D>
- <COMMIT-E>
- <COMMIT-G>
+ <COMMIT-D> Z
+ <COMMIT-E> Z
+ <COMMIT-G> Z
EOF
git bundle verify 2.bdl |
@@ -317,11 +320,11 @@ test_expect_success 'create bundle 2 - has prerequisites' '
test_expect_success 'fail to verify bundle without prerequisites' '
git init --bare test1.git &&
- cat >expect <<-\EOF &&
+ format_and_save_expect <<-\EOF &&
error: Repository lacks these prerequisite commits:
- error: <COMMIT-D>
- error: <COMMIT-E>
- error: <COMMIT-G>
+ error: <COMMIT-D> Z
+ error: <COMMIT-E> Z
+ error: <COMMIT-G> Z
EOF
test_must_fail git -C test1.git bundle verify ../2.bdl 2>&1 |
@@ -352,13 +355,13 @@ test_expect_success 'create bundle 3 - two refs, same object' '
--stdin \
main HEAD <input &&
- cat >expect <<-\EOF &&
+ format_and_save_expect <<-\EOF &&
The bundle contains these 2 refs:
<COMMIT-P> refs/heads/main
<COMMIT-P> HEAD
The bundle requires these 2 refs:
- <COMMIT-M>
- <COMMIT-K>
+ <COMMIT-M> Z
+ <COMMIT-K> Z
EOF
git bundle verify 3.bdl |