mirror of
https://github.com/git/git.git
synced 2026-02-08 00:41:37 +00:00
Introduce and use test_cmp_text
On Windows, we suffer from frequently leaked DOS line endings. Let's ignore them. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -19,11 +19,7 @@ check() {
|
||||
false
|
||||
fi &&
|
||||
test_cmp expect-stdout stdout &&
|
||||
if test_have_prereq MINGW
|
||||
then
|
||||
dos2unix stderr
|
||||
fi &&
|
||||
test_cmp expect-stderr stderr
|
||||
test_cmp_text expect-stderr stderr
|
||||
}
|
||||
|
||||
read_chunk() {
|
||||
|
||||
@@ -96,7 +96,7 @@ EOF
|
||||
|
||||
test_expect_success $PREREQ \
|
||||
'Verify commandline' \
|
||||
'test_cmp expected commandline1'
|
||||
'test_cmp_text expected commandline1'
|
||||
|
||||
test_expect_success $PREREQ 'Send patches with --envelope-sender' '
|
||||
clean_fake_sendmail &&
|
||||
@@ -116,7 +116,7 @@ EOF
|
||||
|
||||
test_expect_success $PREREQ \
|
||||
'Verify commandline' \
|
||||
'test_cmp expected commandline1'
|
||||
'test_cmp_text expected commandline1'
|
||||
|
||||
test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' '
|
||||
clean_fake_sendmail &&
|
||||
@@ -136,7 +136,7 @@ EOF
|
||||
|
||||
test_expect_success $PREREQ \
|
||||
'Verify commandline' \
|
||||
'test_cmp expected commandline1'
|
||||
'test_cmp_text expected commandline1'
|
||||
|
||||
test_expect_success $PREREQ 'setup expect' "
|
||||
cat >expected-show-all-headers <<\EOF
|
||||
@@ -260,7 +260,7 @@ test_expect_success $PREREQ 'Show all headers' '
|
||||
-e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
|
||||
-e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
|
||||
>actual-show-all-headers &&
|
||||
test_cmp expected-show-all-headers actual-show-all-headers
|
||||
test_cmp_text expected-show-all-headers actual-show-all-headers
|
||||
'
|
||||
|
||||
test_expect_success $PREREQ 'Prompting works' '
|
||||
@@ -428,13 +428,13 @@ test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
|
||||
2>errors &&
|
||||
# The first message is a reply to --in-reply-to
|
||||
sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
|
||||
test_cmp expect actual &&
|
||||
test_cmp_text expect actual &&
|
||||
# Second and subsequent messages are replies to the first one
|
||||
sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
|
||||
sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
|
||||
test_cmp expect actual &&
|
||||
test_cmp_text expect actual &&
|
||||
sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
|
||||
test_cmp expect actual
|
||||
test_cmp_text expect actual
|
||||
'
|
||||
|
||||
test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
|
||||
@@ -449,13 +449,13 @@ test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
|
||||
$patches $patches $patches \
|
||||
2>errors &&
|
||||
sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
|
||||
test_cmp expect actual &&
|
||||
test_cmp_text expect actual &&
|
||||
sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
|
||||
sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
|
||||
test_cmp expect actual &&
|
||||
test_cmp_text expect actual &&
|
||||
sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
|
||||
sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
|
||||
test_cmp expect actual
|
||||
test_cmp_text expect actual
|
||||
'
|
||||
|
||||
test_expect_success $PREREQ 'setup fake editor' '
|
||||
@@ -527,7 +527,7 @@ test_suppression () {
|
||||
-e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
|
||||
-e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
|
||||
>actual-suppress-$1${2+"-$2"} &&
|
||||
test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
|
||||
test_cmp_text expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
|
||||
}
|
||||
|
||||
test_expect_success $PREREQ 'sendemail.cc set' '
|
||||
@@ -1243,7 +1243,7 @@ test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
|
||||
grep email-using-8bit stdout &&
|
||||
grep "Which 8bit encoding" stdout &&
|
||||
egrep "Content|MIME" msgtxt1 >actual &&
|
||||
test_cmp actual content-type-decl
|
||||
test_cmp_text actual content-type-decl
|
||||
'
|
||||
|
||||
test_expect_success $PREREQ 'sendemail.8bitEncoding works' '
|
||||
@@ -1254,7 +1254,7 @@ test_expect_success $PREREQ 'sendemail.8bitEncoding works' '
|
||||
--smtp-server="$(pwd)/fake.sendmail" \
|
||||
email-using-8bit >stdout &&
|
||||
egrep "Content|MIME" msgtxt1 >actual &&
|
||||
test_cmp actual content-type-decl
|
||||
test_cmp_text actual content-type-decl
|
||||
'
|
||||
|
||||
test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
|
||||
@@ -1266,7 +1266,7 @@ test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
|
||||
--8bit-encoding=UTF-8 \
|
||||
email-using-8bit >stdout &&
|
||||
egrep "Content|MIME" msgtxt1 >actual &&
|
||||
test_cmp actual content-type-decl
|
||||
test_cmp_text actual content-type-decl
|
||||
'
|
||||
|
||||
test_expect_success $PREREQ 'setup expect' '
|
||||
@@ -1295,7 +1295,7 @@ test_expect_success $PREREQ '--8bit-encoding also treats subject' '
|
||||
--8bit-encoding=UTF-8 \
|
||||
email-using-8bit >stdout &&
|
||||
grep "Subject" msgtxt1 >actual &&
|
||||
test_cmp expected actual
|
||||
test_cmp_text expected actual
|
||||
'
|
||||
|
||||
# Note that the patches in this test are deliberately out of order; we
|
||||
|
||||
@@ -791,12 +791,24 @@ else
|
||||
test_set_prereq C_LOCALE_OUTPUT
|
||||
fi
|
||||
|
||||
# Use this instead of test_cmp to compare files that are expected to contain
|
||||
# text (and therefore it should not matter whether the line ends in an LF or
|
||||
# a CR/LF).
|
||||
test_cmp_text () {
|
||||
if test_have_prereq MINGW
|
||||
then
|
||||
dos2unix "$1" &&
|
||||
dos2unix "$2"
|
||||
fi &&
|
||||
test_cmp "$@"
|
||||
}
|
||||
|
||||
# Use this instead of test_cmp to compare files that contain expected and
|
||||
# actual output from git commands that can be translated. When running
|
||||
# under GETTEXT_POISON this pretends that the command produced expected
|
||||
# results.
|
||||
test_i18ncmp () {
|
||||
test -n "$GETTEXT_POISON" || test_cmp "$@"
|
||||
test -n "$GETTEXT_POISON" || test_cmp_text "$@"
|
||||
}
|
||||
|
||||
# Use this instead of "grep expected-string actual" to see if the
|
||||
|
||||
Reference in New Issue
Block a user