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>
This commit is contained in:

committed by
Junio C Hamano

parent
5210225f25
commit
2bafb3d702
@ -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"
|
||||
|
Reference in New Issue
Block a user