Skip to content

Commit 0dd83ba

Browse files
tboegidscho
authored andcommitted
t0027: support NATIVE_CRLF platforms
t0027 expects the native end-of-lines to be a single line feed character. On Windows, however, we set it to a carriage return character followed by a line feed character. Thus, we have to modify t0027 to expect different warnings depending on the end-of-line markers. Adjust the check of the warnings and use these macros: WILC: Warn if LF becomes CRLF WICL: Warn if CRLF becomes LF WAMIX: 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 shouldn't be there). Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Torsten Bögershausen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a10cf7d commit 0dd83ba

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

t/t0027-auto-crlf.sh

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,13 @@ create_gitattributes () {
5757

5858
check_warning () {
5959
case "$1" in
60-
LF_CRLF) grep "LF will be replaced by CRLF" $2;;
61-
CRLF_LF) grep "CRLF will be replaced by LF" $2;;
62-
'')
63-
>expect
64-
grep "will be replaced by" $2 >actual
65-
test_cmp expect actual
66-
;;
67-
*) false ;;
60+
LF_CRLF) echo "warning: LF will be replaced by CRLF" >"$2".expect ;;
61+
CRLF_LF) echo "warning: CRLF will be replaced by LF" >"$2".expect ;;
62+
'') >"$2".expect ;;
63+
*) echo >&2 "Illegal 1": "$1" ; return false ;;
6864
esac
65+
grep "will be replaced by" "$2" | sed -e "s/\(.*\) in [^ ]*$/\1/" >"$2".actual
66+
test_cmp "$2".expect "$2".actual
6967
}
7068

7169
commit_check_warn () {
@@ -169,20 +167,34 @@ test_expect_success 'setup master' '
169167
warn_LF_CRLF="LF will be replaced by CRLF"
170168
warn_CRLF_LF="CRLF will be replaced by LF"
171169

170+
# WILC stands for "Warn if (this OS) converts LF into CRLF".
171+
# WICL: Warn if CRLF becomes LF
172+
# WAMIX: Mixed line endings: either CRLF->LF or LF->CRLF
173+
if test_have_prereq NATIVE_CRLF
174+
then
175+
WILC=LF_CRLF
176+
WICL=
177+
WAMIX=LF_CRLF
178+
else
179+
WILC=
180+
WICL=CRLF_LF
181+
WAMIX=CRLF_LF
182+
fi
183+
172184
test_expect_success 'commit files empty attr' '
173185
commit_check_warn false "" "" "" "" "" "" &&
174186
commit_check_warn true "" "LF_CRLF" "" "LF_CRLF" "" "" &&
175187
commit_check_warn input "" "" "CRLF_LF" "CRLF_LF" "" ""
176188
'
177189

178190
test_expect_success 'commit files attr=auto' '
179-
commit_check_warn false "auto" "" "CRLF_LF" "CRLF_LF" "" "" &&
191+
commit_check_warn false "auto" "$WILC" "$WICL" "$WAMIX" "" "" &&
180192
commit_check_warn true "auto" "LF_CRLF" "" "LF_CRLF" "" "" &&
181193
commit_check_warn input "auto" "" "CRLF_LF" "CRLF_LF" "" ""
182194
'
183195

184196
test_expect_success 'commit files attr=text' '
185-
commit_check_warn false "text" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" &&
197+
commit_check_warn false "text" "$WILC" "$WICL" "$WAMIX" "$WILC" "$WICL" &&
186198
commit_check_warn true "text" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
187199
commit_check_warn input "text" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF"
188200
'

0 commit comments

Comments
 (0)