Skip to content

Commit cf3d868

Browse files
jiangxingitster
authored andcommitted
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 <[email protected]> Signed-off-by: Jiang Xin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5d5f4ea commit cf3d868

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

t/t5411/common-functions.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ create_commits_in () {
4242
make_user_friendly_and_stable_output () {
4343
sed \
4444
-e "s/ *\$//" \
45-
-e "s/ */ /g" \
45+
-e "s/ */ /g" \
4646
-e "s/'/\"/g" \
4747
-e "s/ / /g" \
4848
-e "s/$A/<COMMIT-A>/g" \
@@ -54,3 +54,8 @@ make_user_friendly_and_stable_output () {
5454
-e "s#To $URL_PREFIX/upstream.git#To <URL/of/upstream.git>#" \
5555
-e "/^error: / d"
5656
}
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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ test_expect_success "git-push --atomic ($PROTOCOL)" '
3636
main \
3737
$B:refs/heads/next \
3838
>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 &&
4443
cat >expect <<-EOF &&
4544
To <URL/of/upstream.git>
4645
! [rejected] main -> main (non-fast-forward)

t/t5411/test-0001-standard-git-push--porcelain.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ test_expect_success "git-push --atomic ($PROTOCOL/porcelain)" '
3737
main \
3838
$B:refs/heads/next \
3939
>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 &&
4645
cat >expect <<-EOF &&
4746
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)
5049
EOF
5150
test_cmp expect actual &&
5251
git -C "$upstream" show-ref >out &&

0 commit comments

Comments
 (0)