Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Introduce and use test_cmp_text
Browse files Browse the repository at this point in the history
On Windows, we suffer from frequently leaked DOS line endings. Let's
ignore them.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Apr 10, 2014
1 parent c3f9224 commit 8d0429c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
6 changes: 1 addition & 5 deletions t/lib-credential.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
30 changes: 15 additions & 15 deletions t/t9001-send-email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -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 &&
Expand All @@ -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
Expand Down Expand Up @@ -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' '
Expand Down Expand Up @@ -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' '
Expand All @@ -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' '
Expand Down Expand Up @@ -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' '
Expand Down Expand Up @@ -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' '
Expand All @@ -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' '
Expand All @@ -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' '
Expand Down Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8d0429c

Please sign in to comment.