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
path: root/t/t5411
diff options
context:
space:
mode:
authorJiang Xin <worldhello.net@gmail.com>2020-11-11 14:32:00 +0300
committerJunio C Hamano <gitster@pobox.com>2020-11-11 23:46:55 +0300
commitcf3d868f353c4a5a9ecf4fbc2a44960671ba59cb (patch)
tree9084aee29e86c40f6bdc082d7044f2f993e73391 /t/t5411
parent5d5f4ea30def2ac765c5517f768366524768c110 (diff)
t5411: new helper filter_out_user_friendly_and_stable_output
New helper `filter_out_user_friendly_and_stable_output` will call common helpr function `make_user_friendly_and_stable_output` and use additional arguments to filter out messages for specific test cases. Suggested-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5411')
-rw-r--r--t/t5411/common-functions.sh7
-rw-r--r--t/t5411/test-0000-standard-git-push.sh9
-rw-r--r--t/t5411/test-0001-standard-git-push--porcelain.sh15
3 files changed, 17 insertions, 14 deletions
diff --git a/t/t5411/common-functions.sh b/t/t5411/common-functions.sh
index 521a347710..344d13f61a 100644
--- a/t/t5411/common-functions.sh
+++ b/t/t5411/common-functions.sh
@@ -42,7 +42,7 @@ create_commits_in () {
make_user_friendly_and_stable_output () {
sed \
-e "s/ *\$//" \
- -e "s/ */ /g" \
+ -e "s/ */ /g" \
-e "s/'/\"/g" \
-e "s/ / /g" \
-e "s/$A/<COMMIT-A>/g" \
@@ -54,3 +54,8 @@ make_user_friendly_and_stable_output () {
-e "s#To $URL_PREFIX/upstream.git#To <URL/of/upstream.git>#" \
-e "/^error: / d"
}
+
+filter_out_user_friendly_and_stable_output () {
+ make_user_friendly_and_stable_output |
+ sed -n ${1+"$@"}
+}
diff --git a/t/t5411/test-0000-standard-git-push.sh b/t/t5411/test-0000-standard-git-push.sh
index 2b04b49367..47b058af7e 100644
--- a/t/t5411/test-0000-standard-git-push.sh
+++ b/t/t5411/test-0000-standard-git-push.sh
@@ -36,11 +36,10 @@ test_expect_success "git-push --atomic ($PROTOCOL)" '
main \
$B:refs/heads/next \
>out 2>&1 &&
- make_user_friendly_and_stable_output <out |
- sed -n \
- -e "/^To / { s/ */ /g; p; }" \
- -e "/^ ! / { s/ */ /g; p; }" \
- >actual &&
+ filter_out_user_friendly_and_stable_output \
+ -e "/^To / { p; }" \
+ -e "/^ ! / { p; }" \
+ <out >actual &&
cat >expect <<-EOF &&
To <URL/of/upstream.git>
! [rejected] main -> main (non-fast-forward)
diff --git a/t/t5411/test-0001-standard-git-push--porcelain.sh b/t/t5411/test-0001-standard-git-push--porcelain.sh
index 747307f8da..bbead12bbb 100644
--- a/t/t5411/test-0001-standard-git-push--porcelain.sh
+++ b/t/t5411/test-0001-standard-git-push--porcelain.sh
@@ -37,16 +37,15 @@ test_expect_success "git-push --atomic ($PROTOCOL/porcelain)" '
main \
$B:refs/heads/next \
>out 2>&1 &&
- make_user_friendly_and_stable_output <out |
- sed -n \
- -e "s/^# GETTEXT POISON #//" \
- -e "/^To / { s/ */ /g; p; }" \
- -e "/^! / { s/ */ /g; p; }" \
- >actual &&
+ filter_out_user_friendly_and_stable_output \
+ -e "s/^# GETTEXT POISON #//" \
+ -e "/^To / { p; }" \
+ -e "/^! / { p; }" \
+ <out >actual &&
cat >expect <<-EOF &&
To <URL/of/upstream.git>
- ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
- ! <COMMIT-B>:refs/heads/next [rejected] (atomic push failed)
+ ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
+ ! <COMMIT-B>:refs/heads/next [rejected] (atomic push failed)
EOF
test_cmp expect actual &&
git -C "$upstream" show-ref >out &&