{"thread":{"id":"39087","subject":"[PATCH 2/3] t0027: Adapt check_warning() to MINGW","startedAt":"2015-04-15T17:00:47Z","lastAt":"2015-04-15T17:00:47Z","messageCount":1,"participants":["Torsten Bögershausen"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"259426","messageId":"552E993F.6030201@web.de","threadId":"39087","inReplyTo":null,"subject":"[PATCH 2/3] t0027: Adapt check_warning() to MINGW","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2015-04-15T17:00:47Z","receivedAt":"2015-04-15T17:00:47Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"When running under MINGW, the native line ending is CRLF and not LF.\nAdjust the check of the warnings with macros:\n  WLC:  LF become CRLF on non-MINGW\n  WCL:  CRLF become LF on non-MINGW\n  WMIX: Mixed line endings: either CRLF->LF or LF->CRLF\n\nImprove the information given by check_warning():\nUse test_cmp to show which warning is missing (or should'n t be there)\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n t/t0027-auto-crlf.sh | 29 +++++++++++++++++++----------\n 1 file changed, 19 insertions(+), 10 deletions(-)\n\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex 5858397..59dfe02 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -57,15 +57,13 @@ create_gitattributes () {\n \n check_warning () {\n \tcase \"$1\" in\n-\tLF_CRLF) grep \"LF will be replaced by CRLF\" $2;;\n-\tCRLF_LF) grep \"CRLF will be replaced by LF\" $2;;\n-\t'')\n-\t\t>expect\n-\t\tgrep \"will be replaced by\" $2 >actual\n-\t\ttest_cmp expect actual\n-\t\t;;\n-\t*) false ;;\n+\tLF_CRLF) echo \"warning: LF will be replaced by CRLF\" >\"$2\".expect ;;\n+\tCRLF_LF) echo \"warning: CRLF will be replaced by LF\" >\"$2\".expect ;;\n+\t'')\t                                                 >\"$2\".expect ;;\n+\t*) echo >&2 \"Illegal 1\": \"$1\" ; return false ;;\n \tesac\n+\tgrep \"will be replaced by\" \"$2\" | sed -e \"s/\\(.*\\) in [^ ]*$/\\1/\" >\"$2\".actual\n+\ttest_cmp \"$2\".expect \"$2\".actual\n }\n \n commit_check_warn () {\n@@ -169,6 +167,17 @@ test_expect_success 'setup master' '\n warn_LF_CRLF=\"LF will be replaced by CRLF\"\n warn_CRLF_LF=\"CRLF will be replaced by LF\"\n \n+if test_have_prereq MINGW\n+then\n+WLC=LF_CRLF\n+WCL=\n+WMIX=LF_CRLF\n+else\n+WLC=\n+WCL=CRLF_LF\n+WMIX=CRLF_LF\n+fi\n+\n test_expect_success 'commit files empty attr' '\n \tcommit_check_warn false \"\"     \"\"        \"\"        \"\"        \"\"        \"\" &&\n \tcommit_check_warn true  \"\"     \"LF_CRLF\" \"\"        \"LF_CRLF\" \"\"        \"\" &&\n@@ -176,13 +185,13 @@ test_expect_success 'commit files empty attr' '\n '\n \n test_expect_success 'commit files attr=auto' '\n-\tcommit_check_warn false \"auto\" \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"\" &&\n+\tcommit_check_warn false \"auto\" \"$WLC\"    \"$WCL\"    \"$WMIX\"   \"\"        \"\" &&\n \tcommit_check_warn true  \"auto\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"\"        \"\" &&\n \tcommit_check_warn input \"auto\" \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"\"\n '\n \n test_expect_success 'commit files attr=text' '\n-\tcommit_check_warn false \"text\" \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"CRLF_LF\" &&\n+\tcommit_check_warn false \"text\" \"$WLC\"    \"$WCL\"    \"$WMIX\"   \"$WLC\"    \"$WCL\" &&\n \tcommit_check_warn true  \"text\" \"LF_CRLF\" \"\"        \"LF_CRLF\" \"LF_CRLF\" \"\"        &&\n \tcommit_check_warn input \"text\" \"\"        \"CRLF_LF\" \"CRLF_LF\" \"\"        \"CRLF_LF\"\n '\n-- \n2.2.0.rc1.790.ge19fcd2\n"}]}