Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit db19ecf

Browse files
committed
test: Introduce binary compare function
In msysgit there were some crashes caused by the line conversions when comparing binary files. I've also used the patch originally by Stepan Kasal to extend coverage of binary compares. Signed-off-by: Michael Geddes <[email protected]>
1 parent 1930ec6 commit db19ecf

7 files changed

+32
-23
lines changed

t/t5000-tar-tree.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ check_tar with_olde-prefix olde-
165165
test_expect_success 'git archive on large files' '
166166
test_config core.bigfilethreshold 1 &&
167167
git archive HEAD >b3.tar &&
168-
test_cmp b.tar b3.tar
168+
test_cmp_bin b.tar b3.tar
169169
'
170170

171171
test_expect_success \
@@ -174,15 +174,15 @@ test_expect_success \
174174

175175
test_expect_success \
176176
'git archive vs. the same in a bare repo' \
177-
'test_cmp b.tar b3.tar'
177+
'test_cmp_bin b.tar b3.tar'
178178

179179
test_expect_success 'git archive with --output' \
180180
'git archive --output=b4.tar HEAD &&
181-
test_cmp b.tar b4.tar'
181+
test_cmp_bin b.tar b4.tar'
182182

183183
test_expect_success 'git archive --remote' \
184184
'git archive --remote=. HEAD >b5.tar &&
185-
test_cmp b.tar b5.tar'
185+
test_cmp_bin b.tar b5.tar'
186186

187187
test_expect_success \
188188
'validate file modification time' \
@@ -199,7 +199,7 @@ test_expect_success \
199199

200200
test_expect_success 'git archive with --output, override inferred format' '
201201
git archive --format=tar --output=d4.zip HEAD &&
202-
test_cmp b.tar d4.zip
202+
test_cmp_bin b.tar d4.zip
203203
'
204204

205205
test_expect_success \
@@ -245,34 +245,34 @@ test_expect_success 'archive --list shows only enabled remote filters' '
245245
test_expect_success 'invoke tar filter by format' '
246246
git archive --format=tar.foo HEAD >config.tar.foo &&
247247
tr ab ba <config.tar.foo >config.tar &&
248-
test_cmp b.tar config.tar &&
248+
test_cmp_bin b.tar config.tar &&
249249
git archive --format=bar HEAD >config.bar &&
250250
tr ab ba <config.bar >config.tar &&
251-
test_cmp b.tar config.tar
251+
test_cmp_bin b.tar config.tar
252252
'
253253

254254
test_expect_success 'invoke tar filter by extension' '
255255
git archive -o config-implicit.tar.foo HEAD &&
256-
test_cmp config.tar.foo config-implicit.tar.foo &&
256+
test_cmp_bin config.tar.foo config-implicit.tar.foo &&
257257
git archive -o config-implicit.bar HEAD &&
258-
test_cmp config.tar.foo config-implicit.bar
258+
test_cmp_bin config.tar.foo config-implicit.bar
259259
'
260260

261261
test_expect_success 'default output format remains tar' '
262262
git archive -o config-implicit.baz HEAD &&
263-
test_cmp b.tar config-implicit.baz
263+
test_cmp_bin b.tar config-implicit.baz
264264
'
265265

266266
test_expect_success 'extension matching requires dot' '
267267
git archive -o config-implicittar.foo HEAD &&
268-
test_cmp b.tar config-implicittar.foo
268+
test_cmp_bin b.tar config-implicittar.foo
269269
'
270270

271271
test_expect_success 'only enabled filters are available remotely' '
272272
test_must_fail git archive --remote=. --format=tar.foo HEAD \
273273
>remote.tar.foo &&
274274
git archive --remote=. --format=bar >remote.bar HEAD &&
275-
test_cmp remote.bar config.bar
275+
test_cmp_bin remote.bar config.bar
276276
'
277277

278278
test_expect_success GZIP 'git archive --format=tgz' '
@@ -281,27 +281,27 @@ test_expect_success GZIP 'git archive --format=tgz' '
281281

282282
test_expect_success GZIP 'git archive --format=tar.gz' '
283283
git archive --format=tar.gz HEAD >j1.tar.gz &&
284-
test_cmp j.tgz j1.tar.gz
284+
test_cmp_bin j.tgz j1.tar.gz
285285
'
286286

287287
test_expect_success GZIP 'infer tgz from .tgz filename' '
288288
git archive --output=j2.tgz HEAD &&
289-
test_cmp j.tgz j2.tgz
289+
test_cmp_bin j.tgz j2.tgz
290290
'
291291

292292
test_expect_success GZIP 'infer tgz from .tar.gz filename' '
293293
git archive --output=j3.tar.gz HEAD &&
294-
test_cmp j.tgz j3.tar.gz
294+
test_cmp_bin j.tgz j3.tar.gz
295295
'
296296

297297
test_expect_success GZIP 'extract tgz file' '
298298
gzip -d -c <j.tgz >j.tar &&
299-
test_cmp b.tar j.tar
299+
test_cmp_bin b.tar j.tar
300300
'
301301

302302
test_expect_success GZIP 'remote tar.gz is allowed by default' '
303303
git archive --remote=. --format=tar.gz HEAD >remote.tar.gz &&
304-
test_cmp j.tgz remote.tar.gz
304+
test_cmp_bin j.tgz remote.tar.gz
305305
'
306306

307307
test_expect_success GZIP 'remote tar.gz can be disabled' '

t/t5001-archive-attr.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ test_expect_missing worktree2/ignored-by-worktree
6868

6969
test_expect_success 'git archive vs. bare' '
7070
(cd bare && git archive HEAD) >bare-archive.tar &&
71-
test_cmp archive.tar bare-archive.tar
71+
test_cmp_bin archive.tar bare-archive.tar
7272
'
7373

7474
test_expect_success 'git archive with worktree attributes, bare' '

t/t5003-archive-zip.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ test_expect_success \
9797

9898
test_expect_success \
9999
'git archive --format=zip vs. the same in a bare repo' \
100-
'test_cmp d.zip d1.zip'
100+
'test_cmp_bin d.zip d1.zip'
101101

102102
test_expect_success 'git archive --format=zip with --output' \
103103
'git archive --format=zip --output=d2.zip HEAD &&
104-
test_cmp d.zip d2.zip'
104+
test_cmp_bin d.zip d2.zip'
105105

106106
test_expect_success 'git archive with --output, inferring format' '
107107
git archive --output=d3.zip HEAD &&
108-
test_cmp d.zip d3.zip
108+
test_cmp_bin d.zip d3.zip
109109
'
110110

111111
test_expect_success \

t/t5004-archive-corner-cases.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test_expect_success HEADER_ONLY_TAR_OK 'tar archive of commit with empty tree' '
4545
test_expect_success 'tar archive of empty tree is empty' '
4646
git archive --format=tar HEAD: >empty.tar &&
4747
perl -e "print \"\\0\" x 10240" >10knuls.tar &&
48-
test_cmp 10knuls.tar empty.tar
48+
test_cmp_bin 10knuls.tar empty.tar
4949
'
5050

5151
test_expect_success 'tar archive of empty tree with prefix' '

t/t9300-fast-import.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2687,7 +2687,7 @@ test_expect_success 'R: verify created pack' '
26872687
test_expect_success \
26882688
'R: verify written objects' \
26892689
'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2690-
test_cmp expect actual &&
2690+
test_cmp_bin expect actual &&
26912691
a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
26922692
b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
26932693
test $a = $b'

t/test-lib-functions.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,14 @@ test_cmp() {
617617
$GIT_TEST_CMP "$@"
618618
}
619619

620+
test_cmp_bin() {
621+
if test -z "$GIT_TEST_CMP_BIN" ; then
622+
$GIT_TEST_CMP "$@"
623+
else
624+
$GIT_TEST_CMP_BIN "$@"
625+
fi
626+
}
627+
620628
# Check if the file expected to be empty is indeed empty, and barfs
621629
# otherwise.
622630

t/test-lib.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,7 @@ case $(uname -s) in
881881
test_set_prereq SED_STRIPS_CR
882882
test_set_prereq GREP_STRIPS_CR
883883
GIT_TEST_CMP=mingw_test_cmp
884+
GIT_TEST_CMP_BIN="cmp -s -c"
884885
;;
885886
*CYGWIN*)
886887
test_set_prereq POSIXPERM

0 commit comments

Comments
 (0)