Skip to content

Commit f337efa

Browse files
Brice Lambsonpatthoyts
authored andcommitted
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 <[email protected]>
1 parent c29187a commit f337efa

File tree

3 files changed

+36
-35
lines changed

3 files changed

+36
-35
lines changed

t/t0026-eol-config.sh

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@ has_cr() {
88
tr '\015' Q <"$1" | grep Q >/dev/null
99
}
1010

11-
# core.eol crlf and core.autocrlf input are not permitted.
12-
# this lets us check for the core.eol native being crlf.
13-
set_native_eol_prereq() {
14-
rm -rf eol && mkdir eol &&
15-
( cd eol &&
16-
git init --quiet &&
17-
git config core.autocrlf input &&
18-
git config core.eol native &&
19-
git var core.eol 2> /dev/null
20-
) ||
21-
test_set_prereq NATIVE_EOL_IS_CRLF
22-
}
23-
set_native_eol_prereq
24-
2511
test_expect_success setup '
2612
2713
git config core.autocrlf false &&
@@ -94,7 +80,7 @@ test_expect_success 'autocrlf=true overrides unset eol' '
9480
test -z "$onediff" -a -z "$twodiff"
9581
'
9682

97-
test_expect_success NATIVE_EOL_IS_CRLF 'eol native is crlf' '
83+
test_expect_success NATIVE_CRLF 'eol native is crlf' '
9884
9985
rm -rf native_eol && mkdir native_eol &&
10086
( cd native_eol &&

t/t6038-merge-text-auto.sh

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ test_expect_success 'Merge after setting text=auto' '
7272
same line
7373
EOF
7474
75+
if test_have_prereq NATIVE_CRLF; then
76+
append_cr <expected >expected.temp &&
77+
mv expected.temp expected
78+
fi &&
7579
git config merge.renormalize true &&
7680
git rm -fr . &&
7781
rm -f .gitattributes &&
@@ -86,6 +90,10 @@ test_expect_success 'Merge addition of text=auto' '
8690
same line
8791
EOF
8892
93+
if test_have_prereq NATIVE_CRLF; then
94+
append_cr <expected >expected.temp &&
95+
mv expected.temp expected
96+
fi &&
8997
git config merge.renormalize true &&
9098
git rm -fr . &&
9199
rm -f .gitattributes &&
@@ -95,16 +103,19 @@ test_expect_success 'Merge addition of text=auto' '
95103
'
96104

97105
test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
98-
q_to_cr <<-\EOF >expected &&
99-
<<<<<<<
100-
first line
101-
same line
102-
=======
103-
first lineQ
104-
same lineQ
105-
>>>>>>>
106-
EOF
107-
106+
echo "<<<<<<<" >expected &&
107+
if test_have_prereq NATIVE_CRLF; then
108+
echo first line | append_cr >>expected &&
109+
echo same line | append_cr >>expected &&
110+
echo ======= | append_cr >>expected
111+
else
112+
echo first line >>expected &&
113+
echo same line >>expected &&
114+
echo ======= >>expected
115+
fi &&
116+
echo first line | append_cr >>expected &&
117+
echo same line | append_cr >>expected &&
118+
echo ">>>>>>>" >>expected &&
108119
git config merge.renormalize false &&
109120
rm -f .gitattributes &&
110121
git reset --hard a &&
@@ -114,16 +125,19 @@ test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
114125
'
115126

116127
test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
117-
q_to_cr <<-\EOF >expected &&
118-
<<<<<<<
119-
first lineQ
120-
same lineQ
121-
=======
122-
first line
123-
same line
124-
>>>>>>>
125-
EOF
126-
128+
echo "<<<<<<<" >expected &&
129+
echo first line | append_cr >>expected &&
130+
echo same line | append_cr >>expected &&
131+
if test_have_prereq NATIVE_CRLF; then
132+
echo ======= | append_cr >>expected &&
133+
echo first line | append_cr >>expected &&
134+
echo same line | append_cr >>expected
135+
else
136+
echo ======= >>expected &&
137+
echo first line >>expected &&
138+
echo same line >>expected
139+
fi &&
140+
echo ">>>>>>>" >>expected &&
127141
git config merge.renormalize false &&
128142
rm -f .gitattributes &&
129143
git reset --hard b &&

t/test-lib.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ case $(uname -s) in
828828
# exec does not inherit the PID
829829
test_set_prereq MINGW
830830
test_set_prereq NOT_CYGWIN
831+
test_set_prereq NATIVE_CRLF
831832
test_set_prereq SED_STRIPS_CR
832833
test_set_prereq GREP_STRIPS_CR
833834
;;

0 commit comments

Comments
 (0)