summaryrefslogtreecommitdiff
path: root/t/t5411/common-functions.sh
diff options
context:
space:
mode:
authorJiang Xin <worldhello.net@gmail.com>2021-06-17 03:17:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-06-17 05:12:21 (GMT)
commit2bafb3d702d4cd77de0d3e68f13188980e0de734 (patch)
tree6f394212728100328ee3baa90c79298fdd5d272e /t/t5411/common-functions.sh
parent5210225f256d01938960d439bff9d809c2ff1809 (diff)
downloadgit-2bafb3d702d4cd77de0d3e68f13188980e0de734.zip
git-2bafb3d702d4cd77de0d3e68f13188980e0de734.tar.gz
git-2bafb3d702d4cd77de0d3e68f13188980e0de734.tar.bz2
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/t5411/common-functions.sh')
-rw-r--r--t/t5411/common-functions.sh9
1 files changed, 5 insertions, 4 deletions
diff --git a/t/t5411/common-functions.sh b/t/t5411/common-functions.sh
index 6694858..6c347b4 100644
--- a/t/t5411/common-functions.sh
+++ b/t/t5411/common-functions.sh
@@ -33,17 +33,14 @@ create_commits_in () {
# Format the output of git-push, git-show-ref and other 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
+# without having to worry about changes of the commit ID (full or abbrev.)
# of the output. Single quotes are replaced with double quotes, because
# it is boring to prepare unquoted single quotes in expect text. We also
# remove some locale error messages. The emitted human-readable errors are
# redundant to the more machine-readable output the tests already assert.
make_user_friendly_and_stable_output () {
sed \
- -e "s/ *\$//" \
- -e "s/ */ /g" \
-e "s/'/\"/g" \
- -e "s/ / /g" \
-e "s/$A/<COMMIT-A>/g" \
-e "s/$B/<COMMIT-B>/g" \
-e "s/$TAG/<TAG-v123>/g" \
@@ -59,6 +56,10 @@ filter_out_user_friendly_and_stable_output () {
sed -n ${1+"$@"}
}
+format_and_save_expect () {
+ sed -e 's/^> //' -e 's/Z$//' >expect
+}
+
test_cmp_refs () {
indir=
if test "$1" = "-C"