git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] t0027: Adapt check_warning() to MINGW

From
Torsten Bögershausen <tboegi@web.de>
Date
Apr 15, 2015, 17:00 UTC
Message-ID
<552E993F.6030201@web.de>
When running under MINGW, the native line ending is CRLF and not LF.
Adjust the check of the warnings with macros:
  WLC:  LF become CRLF on non-MINGW
  WCL:  CRLF become LF on non-MINGW
  WMIX: Mixed line endings: either CRLF->LF or LF->CRLF

Improve the information given by check_warning(): Use test_cmp to show which warning is missing (or should'n t be there)

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
 t/t0027-auto-crlf.sh | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh
index 5858397..59dfe02 100755
--- a/t/t0027-auto-crlf.sh
+++ b/t/t0027-auto-crlf.sh
@@ -57,15 +57,13 @@ create_gitattributes () {
 
 check_warning () {
 	case "$1" in
-	LF_CRLF) grep "LF will be replaced by CRLF" $2;;
-	CRLF_LF) grep "CRLF will be replaced by LF" $2;;
-	'')
-		>expect
-		grep "will be replaced by" $2 >actual
-		test_cmp expect actual
-		;;
-	*) false ;;
+	LF_CRLF) echo "warning: LF will be replaced by CRLF" >"$2".expect ;;
+	CRLF_LF) echo "warning: CRLF will be replaced by LF" >"$2".expect ;;
+	'')	                                                 >"$2".expect ;;
+	*) echo >&2 "Illegal 1": "$1" ; return false ;;
 	esac
+	grep "will be replaced by" "$2" | sed -e "s/\(.*\) in [^ ]*$/\1/" >"$2".actual
+	test_cmp "$2".expect "$2".actual
 }
 
 commit_check_warn () {
@@ -169,6 +167,17 @@ test_expect_success 'setup master' '
 warn_LF_CRLF="LF will be replaced by CRLF"
 warn_CRLF_LF="CRLF will be replaced by LF"
 
+if test_have_prereq MINGW
+then
+WLC=LF_CRLF
+WCL=
+WMIX=LF_CRLF
+else
+WLC=
+WCL=CRLF_LF
+WMIX=CRLF_LF
+fi
+
 test_expect_success 'commit files empty attr' '
 	commit_check_warn false ""     ""        ""        ""        ""        "" &&
 	commit_check_warn true  ""     "LF_CRLF" ""        "LF_CRLF" ""        "" &&
@@ -176,13 +185,13 @@ test_expect_success 'commit files empty attr' '
 '
 
 test_expect_success 'commit files attr=auto' '
-	commit_check_warn false "auto" ""        "CRLF_LF" "CRLF_LF" ""        "" &&
+	commit_check_warn false "auto" "$WLC"    "$WCL"    "$WMIX"   ""        "" &&
 	commit_check_warn true  "auto" "LF_CRLF" ""        "LF_CRLF" ""        "" &&
 	commit_check_warn input "auto" ""        "CRLF_LF" "CRLF_LF" ""        ""
 '
 
 test_expect_success 'commit files attr=text' '
-	commit_check_warn false "text" ""        "CRLF_LF" "CRLF_LF" ""        "CRLF_LF" &&
+	commit_check_warn false "text" "$WLC"    "$WCL"    "$WMIX"   "$WLC"    "$WCL" &&
 	commit_check_warn true  "text" "LF_CRLF" ""        "LF_CRLF" "LF_CRLF" ""        &&
 	commit_check_warn input "text" ""        "CRLF_LF" "CRLF_LF" ""        "CRLF_LF"
 '
-- 
2.2.0.rc1.790.ge19fcd2
Message 1 of 1 in “t0027: Adapt check_warning() to MINGW”
  1. 2/3 t0027: Adapt check_warning() to MINGWTorsten Bögershausen, Apr 15, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.