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>
Jiang Xin committed
Nov 11, 2020 at 19:32 UTC
cf3d868f353c4a5a9ecf4fbc2a44960671ba59cb
3 files changed
+17
-14
t/t5411/common-functions.sh
+6
-1
@@ -42,7 +42,7 @@ create_commits_in () {
42
make_user_friendly_and_stable_output () {
43
sed \
44
-e "s/ *\$//" \
45
- -e "s/ */ /g" \
45
+ -e "s/ */ /g" \
46
-e "s/'/\"/g" \
47
-e "s/ / /g" \
48
-e "s/$A/<COMMIT-A>/g" \
@@ -54,3 +54,8 @@ make_user_friendly_and_stable_output () {
54
-e "s#To $URL_PREFIX/upstream.git#To <URL/of/upstream.git>#" \
55
-e "/^error: / d"
56
}
57
+
58
+filter_out_user_friendly_and_stable_output () {
59
+ make_user_friendly_and_stable_output |
60
+ sed -n ${1+"$@"}
61
+}
t/t5411/test-0000-standard-git-push.sh
+4
-5
@@ -36,11 +36,10 @@ test_expect_success "git-push --atomic ($PROTOCOL)" '
36
main \
37
$B:refs/heads/next \
38
>out 2>&1 &&
39
- make_user_friendly_and_stable_output <out |
40
- sed -n \
41
- -e "/^To / { s/ */ /g; p; }" \
42
- -e "/^ ! / { s/ */ /g; p; }" \
43
- >actual &&
39
+ filter_out_user_friendly_and_stable_output \
40
+ -e "/^To / { p; }" \
41
+ -e "/^ ! / { p; }" \
42
+ <out >actual &&
43
cat >expect <<-EOF &&
44
To <URL/of/upstream.git>
45
! [rejected] main -> main (non-fast-forward)
t/t5411/test-0001-standard-git-push--porcelain.sh
+7
-8
@@ -37,16 +37,15 @@ test_expect_success "git-push --atomic ($PROTOCOL/porcelain)" '
37
main \
38
$B:refs/heads/next \
39
>out 2>&1 &&
40
- make_user_friendly_and_stable_output <out |
41
- sed -n \
42
- -e "s/^# GETTEXT POISON #//" \
43
- -e "/^To / { s/ */ /g; p; }" \
44
- -e "/^! / { s/ */ /g; p; }" \
45
- >actual &&
40
+ filter_out_user_friendly_and_stable_output \
41
+ -e "s/^# GETTEXT POISON #//" \
42
+ -e "/^To / { p; }" \
43
+ -e "/^! / { p; }" \
44
+ <out >actual &&
45
cat >expect <<-EOF &&
46
To <URL/of/upstream.git>
48
- ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
49
- ! <COMMIT-B>:refs/heads/next [rejected] (atomic push failed)
47
+ ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
48
+ ! <COMMIT-B>:refs/heads/next [rejected] (atomic push failed)
49
EOF
50
test_cmp expect actual &&
51
git -C "$upstream" show-ref >out &&