diff --git a/t/lib-credential.sh b/t/lib-credential.sh index 8a2c7cc6ff..49d4094d4a 100755 --- a/t/lib-credential.sh +++ b/t/lib-credential.sh @@ -23,11 +23,7 @@ check() { dos2unix -q stderr 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() { diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh index 150c98ca01..4dfe31dd26 100755 --- a/t/t7407-submodule-foreach.sh +++ b/t/t7407-submodule-foreach.sh @@ -77,10 +77,6 @@ test_expect_success 'test basic "submodule foreach" usage' ' git config foo.bar zar && git submodule foreach "git config --file \"\$toplevel/.git/config\" foo.bar" ) && - if test_have_prereq MINGW - then - dos2unix actual - fi && test_i18ncmp expect actual ' @@ -162,10 +158,6 @@ test_expect_success 'test messages from "foreach --recursive"' ' cd clone2 && git submodule foreach --recursive "true" > ../actual ) && - if test_have_prereq MINGW - then - dos2unix actual - fi && test_i18ncmp expect actual ' @@ -184,11 +176,7 @@ test_expect_success 'test "foreach --quiet --recursive"' ' cd clone2 && git submodule foreach -q --recursive "echo \$name-\$path" > ../actual ) && - if test_have_prereq MINGW - then - dos2unix actual - fi && - test_cmp expect actual + test_cmp_text expect actual ' test_expect_success 'use "update --recursive" to checkout all submodules' ' @@ -235,11 +223,7 @@ test_expect_success 'test "status --recursive"' ' cd clone3 && git submodule status --recursive > ../actual ) && - if test_have_prereq MINGW - then - dos2unix actual - fi && - test_cmp expect actual + test_cmp_text expect actual ' sed -e "/nested2 /s/.*/+$nested2sha1 nested1\/nested2 (file2~1)/;/sub[1-3]/d" < expect > expect2 @@ -254,11 +238,7 @@ test_expect_success 'ensure "status --cached --recursive" preserves the --cached ) && git submodule status --cached --recursive -- nested1 > ../actual ) && - if test_have_prereq MINGW - then - dos2unix actual - fi && - test_cmp expect actual + test_cmp_text expect actual ' test_expect_success 'use "git clone --recursive" to checkout all submodules' ' diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index ebd5c5db45..6eb8e0a862 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -23,7 +23,6 @@ test_expect_success $PREREQ \ echo do echo " echo \"!\$a!\"" echo "done >commandline\$output" - test_have_prereq MINGW && echo "dos2unix commandline\$output" echo "cat > msgtxt\$output" ) >fake.sendmail && chmod +x ./fake.sendmail && @@ -97,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 && @@ -117,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 && @@ -137,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 @@ -186,7 +185,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' ' @@ -354,13 +353,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' ' @@ -375,13 +374,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' ' @@ -453,7 +452,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' ' @@ -1204,7 +1203,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' ' @@ -1215,7 +1214,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' ' @@ -1227,7 +1226,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' ' @@ -1256,7 +1255,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 diff --git a/t/test-lib.sh b/t/test-lib.sh index 1ced6b5722..60b2821d05 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -713,12 +713,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