Skip to content

Commit fbaa226

Browse files
committed
Merge branch 'js/tests-windows-port-fix'
* js/tests-windows-port-fix: tests: undo special treatment of CRLF for Windows Windows: a test_cmp that is agnostic to random LF <> CRLF conversions t5300-pack-object: do not compare binary data using test_cmp
2 parents cbe59df + f94ea11 commit fbaa226

File tree

6 files changed

+72
-14
lines changed

6 files changed

+72
-14
lines changed

t/lib-credential.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ check() {
1818
cat stderr &&
1919
false
2020
fi &&
21-
if test_have_prereq MINGW
22-
then
23-
dos2unix -q stderr
24-
fi &&
2521
test_cmp expect-stdout stdout &&
2622
test_cmp expect-stderr stderr
2723
}

t/t5300-pack-object.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ test_expect_success \
151151
git cat-file $t $object || return 1
152152
done <obj-list
153153
} >current &&
154-
test_cmp expect current'
154+
cmp expect current'
155155

156156
test_expect_success \
157157
'use packed deltified (REF_DELTA) objects' \
@@ -166,7 +166,7 @@ test_expect_success \
166166
git cat-file $t $object || return 1
167167
done <obj-list
168168
} >current &&
169-
test_cmp expect current'
169+
cmp expect current'
170170

171171
test_expect_success \
172172
'use packed deltified (OFS_DELTA) objects' \
@@ -181,7 +181,7 @@ test_expect_success \
181181
git cat-file $t $object || return 1
182182
done <obj-list
183183
} >current &&
184-
test_cmp expect current'
184+
cmp expect current'
185185

186186
unset GIT_OBJECT_DIRECTORY
187187

@@ -195,9 +195,9 @@ test_expect_success 'survive missing objects/pack directory' '
195195
rm -fr $GOP &&
196196
git index-pack --stdin --keep=test <../test-3-${packname_3}.pack &&
197197
test -f $GOP/pack-${packname_3}.pack &&
198-
test_cmp $GOP/pack-${packname_3}.pack ../test-3-${packname_3}.pack &&
198+
cmp $GOP/pack-${packname_3}.pack ../test-3-${packname_3}.pack &&
199199
test -f $GOP/pack-${packname_3}.idx &&
200-
test_cmp $GOP/pack-${packname_3}.idx ../test-3-${packname_3}.idx &&
200+
cmp $GOP/pack-${packname_3}.idx ../test-3-${packname_3}.idx &&
201201
test -f $GOP/pack-${packname_3}.keep
202202
)
203203
'

t/t7407-submodule-foreach.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,6 @@ test_expect_success 'ensure "status --cached --recursive" preserves the --cached
254254
) &&
255255
git submodule status --cached --recursive -- nested1 > ../actual
256256
) &&
257-
if test_have_prereq MINGW
258-
then
259-
dos2unix actual
260-
fi &&
261257
test_cmp expect actual
262258
'
263259

t/t9001-send-email.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ test_expect_success $PREREQ \
2323
echo do
2424
echo " echo \"!\$a!\""
2525
echo "done >commandline\$output"
26-
test_have_prereq MINGW && echo "dos2unix commandline\$output"
2726
echo "cat > msgtxt\$output"
2827
) >fake.sendmail &&
2928
chmod +x ./fake.sendmail &&

t/test-lib-functions.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,3 +710,69 @@ test_ln_s_add () {
710710
git update-index --add --cacheinfo 120000 $ln_s_obj "$2"
711711
fi
712712
}
713+
714+
# The following mingw_* functions obey POSIX shell syntax, but are actually
715+
# bash scripts, and are meant to be used only with bash on Windows.
716+
717+
# A test_cmp function that treats LF and CRLF equal and avoids to fork
718+
# diff when possible.
719+
mingw_test_cmp () {
720+
# Read text into shell variables and compare them. If the results
721+
# are different, use regular diff to report the difference.
722+
local test_cmp_a= test_cmp_b=
723+
724+
# When text came from stdin (one argument is '-') we must feed it
725+
# to diff.
726+
local stdin_for_diff=
727+
728+
# Since it is difficult to detect the difference between an
729+
# empty input file and a failure to read the files, we go straight
730+
# to diff if one of the inputs is empty.
731+
if test -s "$1" && test -s "$2"
732+
then
733+
# regular case: both files non-empty
734+
mingw_read_file_strip_cr_ test_cmp_a <"$1"
735+
mingw_read_file_strip_cr_ test_cmp_b <"$2"
736+
elif test -s "$1" && test "$2" = -
737+
then
738+
# read 2nd file from stdin
739+
mingw_read_file_strip_cr_ test_cmp_a <"$1"
740+
mingw_read_file_strip_cr_ test_cmp_b
741+
stdin_for_diff='<<<"$test_cmp_b"'
742+
elif test "$1" = - && test -s "$2"
743+
then
744+
# read 1st file from stdin
745+
mingw_read_file_strip_cr_ test_cmp_a
746+
mingw_read_file_strip_cr_ test_cmp_b <"$2"
747+
stdin_for_diff='<<<"$test_cmp_a"'
748+
fi
749+
test -n "$test_cmp_a" &&
750+
test -n "$test_cmp_b" &&
751+
test "$test_cmp_a" = "$test_cmp_b" ||
752+
eval "diff -u \"\$@\" $stdin_for_diff"
753+
}
754+
755+
# $1 is the name of the shell variable to fill in
756+
mingw_read_file_strip_cr_ () {
757+
# Read line-wise using LF as the line separator
758+
# and use IFS to strip CR.
759+
local line
760+
while :
761+
do
762+
if IFS=$'\r' read -r -d $'\n' line
763+
then
764+
# good
765+
line=$line$'\n'
766+
else
767+
# we get here at EOF, but also if the last line
768+
# was not terminated by LF; in the latter case,
769+
# some text was read
770+
if test -z "$line"
771+
then
772+
# EOF, really
773+
break
774+
fi
775+
fi
776+
eval "$1=\$$1\$line"
777+
done
778+
}

t/test-lib.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ case $(uname -s) in
752752
test_set_prereq NOT_CYGWIN
753753
test_set_prereq SED_STRIPS_CR
754754
test_set_prereq GREP_STRIPS_CR
755+
GIT_TEST_CMP=mingw_test_cmp
755756
;;
756757
*CYGWIN*)
757758
test_set_prereq POSIXPERM

0 commit comments

Comments
 (0)