From 92a963c8931a2f603f977181695687cb242a25b1 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Thu, 15 Aug 2013 18:58:39 -0700 Subject: [PATCH] MinGW: Update tests to handle a native eol of crlf Some of the tests were written with the assumption that the native eol would always be lf. After defining NATIVE_CRLF on MinGW, these tests began failing. This change will update the tests to also handle a native eol of crlf. Signed-off-by: Brice Lambson --- t/t0026-eol-config.sh | 16 +------------- t/t6038-merge-text-auto.sh | 54 +++++++++++++++++++++++++++++----------------- t/test-lib.sh | 1 + 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/t/t0026-eol-config.sh b/t/t0026-eol-config.sh index a524f046b9..00ff53f768 100755 --- a/t/t0026-eol-config.sh +++ b/t/t0026-eol-config.sh @@ -8,20 +8,6 @@ has_cr() { tr '\015' Q <"$1" | grep Q >/dev/null } -# core.eol crlf and core.autocrlf input are not permitted. -# this lets us check for the core.eol native being crlf. -set_native_eol_prereq() { - rm -rf eol && mkdir eol && - ( cd eol && - git init --quiet && - git config core.autocrlf input && - git config core.eol native && - git var core.eol 2> /dev/null - ) || - test_set_prereq NATIVE_EOL_IS_CRLF -} -set_native_eol_prereq - test_expect_success setup ' git config core.autocrlf false && @@ -94,7 +80,7 @@ test_expect_success 'autocrlf=true overrides unset eol' ' test -z "$onediff" -a -z "$twodiff" ' -test_expect_success NATIVE_EOL_IS_CRLF 'eol native is crlf' ' +test_expect_success NATIVE_CRLF 'eol native is crlf' ' rm -rf native_eol && mkdir native_eol && ( cd native_eol && diff --git a/t/t6038-merge-text-auto.sh b/t/t6038-merge-text-auto.sh index d9c2d386dd..67c59b7e97 100755 --- a/t/t6038-merge-text-auto.sh +++ b/t/t6038-merge-text-auto.sh @@ -72,6 +72,10 @@ test_expect_success 'Merge after setting text=auto' ' same line EOF + if test_have_prereq NATIVE_CRLF; then + append_cr expected.temp && + mv expected.temp expected + fi && git config merge.renormalize true && git rm -fr . && rm -f .gitattributes && @@ -86,6 +90,10 @@ test_expect_success 'Merge addition of text=auto' ' same line EOF + if test_have_prereq NATIVE_CRLF; then + append_cr expected.temp && + mv expected.temp expected + fi && git config merge.renormalize true && git rm -fr . && rm -f .gitattributes && @@ -95,16 +103,19 @@ test_expect_success 'Merge addition of text=auto' ' ' test_expect_success 'Detect CRLF/LF conflict after setting text=auto' ' - q_to_cr <<-\EOF >expected && - <<<<<<< - first line - same line - ======= - first lineQ - same lineQ - >>>>>>> - EOF - + echo "<<<<<<<" >expected && + if test_have_prereq NATIVE_CRLF; then + echo first line | append_cr >>expected && + echo same line | append_cr >>expected && + echo ======= | append_cr >>expected + else + echo first line >>expected && + echo same line >>expected && + echo ======= >>expected + fi && + echo first line | append_cr >>expected && + echo same line | append_cr >>expected && + echo ">>>>>>>" >>expected && git config merge.renormalize false && rm -f .gitattributes && git reset --hard a && @@ -114,16 +125,19 @@ test_expect_success 'Detect CRLF/LF conflict after setting text=auto' ' ' test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' ' - q_to_cr <<-\EOF >expected && - <<<<<<< - first lineQ - same lineQ - ======= - first line - same line - >>>>>>> - EOF - + echo "<<<<<<<" >expected && + echo first line | append_cr >>expected && + echo same line | append_cr >>expected && + if test_have_prereq NATIVE_CRLF; then + echo ======= | append_cr >>expected && + echo first line | append_cr >>expected && + echo same line | append_cr >>expected + else + echo ======= >>expected && + echo first line >>expected && + echo same line >>expected + fi && + echo ">>>>>>>" >>expected && git config merge.renormalize false && rm -f .gitattributes && git reset --hard b && diff --git a/t/test-lib.sh b/t/test-lib.sh index 852bd8f14a..aed8aac809 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -754,6 +754,7 @@ case $(uname -s) in # exec does not inherit the PID test_set_prereq MINGW test_set_prereq NOT_CYGWIN + test_set_prereq NATIVE_CRLF test_set_prereq SED_STRIPS_CR test_set_prereq GREP_STRIPS_CR GIT_TEST_CMP=mingw_test_cmp -- 2.11.4.GIT