t5000, t5003: do not use test_cmp to compare binary files

test_cmp() is primarily meant to compare text files (and display the difference for debug purposes). Raw "cmp" is better suited to compare binary files (tar, zip, etc.). On MinGW, test_cmp is a shell function mingw_test_cmp that tries to read both files into environment, stripping CR characters (introduced in commit 4d715ac0). This function usually speeds things up, as fork is extremly slow on Windows. But no wonder that this function is extremely slow and sometimes even crashes when comparing large tar or zip files. Signed-off-by: Stepan Kasal <kasal@ucw.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stepan Kasal committed Jun 4, 2014 at 17:57 UTC b93e6e36637bed9d80f9ffa786ea78044fde6bac
5 files changed +28 -22
t/t5000-tar-tree.sh
+17 -17
@@ -164,7 +164,7 @@ check_tar with_olde-prefix olde-
164 test_expect_success 'git archive on large files' '
165 test_config core.bigfilethreshold 1 &&
166 git archive HEAD >b3.tar &&
167 - test_cmp b.tar b3.tar
167 + test_cmp_bin b.tar b3.tar
168 '
169
170 test_expect_success \
@@ -173,15 +173,15 @@ test_expect_success \
173
174 test_expect_success \
175 'git archive vs. the same in a bare repo' \
176 - 'test_cmp b.tar b3.tar'
176 + 'test_cmp_bin b.tar b3.tar'
177
178 test_expect_success 'git archive with --output' \
179 'git archive --output=b4.tar HEAD &&
180 - test_cmp b.tar b4.tar'
180 + test_cmp_bin b.tar b4.tar'
181
182 test_expect_success 'git archive --remote' \
183 'git archive --remote=. HEAD >b5.tar &&
184 - test_cmp b.tar b5.tar'
184 + test_cmp_bin b.tar b5.tar'
185
186 test_expect_success \
187 'validate file modification time' \
@@ -198,7 +198,7 @@ test_expect_success \
198
199 test_expect_success 'git archive with --output, override inferred format' '
200 git archive --format=tar --output=d4.zip HEAD &&
201 - test_cmp b.tar d4.zip
201 + test_cmp_bin b.tar d4.zip
202 '
203
204 test_expect_success \
@@ -244,34 +244,34 @@ test_expect_success 'archive --list shows only enabled remote filters' '
244 test_expect_success 'invoke tar filter by format' '
245 git archive --format=tar.foo HEAD >config.tar.foo &&
246 tr ab ba <config.tar.foo >config.tar &&
247 - test_cmp b.tar config.tar &&
247 + test_cmp_bin b.tar config.tar &&
248 git archive --format=bar HEAD >config.bar &&
249 tr ab ba <config.bar >config.tar &&
250 - test_cmp b.tar config.tar
250 + test_cmp_bin b.tar config.tar
251 '
252
253 test_expect_success 'invoke tar filter by extension' '
254 git archive -o config-implicit.tar.foo HEAD &&
255 - test_cmp config.tar.foo config-implicit.tar.foo &&
255 + test_cmp_bin config.tar.foo config-implicit.tar.foo &&
256 git archive -o config-implicit.bar HEAD &&
257 - test_cmp config.tar.foo config-implicit.bar
257 + test_cmp_bin config.tar.foo config-implicit.bar
258 '
259
260 test_expect_success 'default output format remains tar' '
261 git archive -o config-implicit.baz HEAD &&
262 - test_cmp b.tar config-implicit.baz
262 + test_cmp_bin b.tar config-implicit.baz
263 '
264
265 test_expect_success 'extension matching requires dot' '
266 git archive -o config-implicittar.foo HEAD &&
267 - test_cmp b.tar config-implicittar.foo
267 + test_cmp_bin b.tar config-implicittar.foo
268 '
269
270 test_expect_success 'only enabled filters are available remotely' '
271 test_must_fail git archive --remote=. --format=tar.foo HEAD \
272 >remote.tar.foo &&
273 git archive --remote=. --format=bar >remote.bar HEAD &&
274 - test_cmp remote.bar config.bar
274 + test_cmp_bin remote.bar config.bar
275 '
276
277 test_expect_success GZIP 'git archive --format=tgz' '
@@ -280,27 +280,27 @@ test_expect_success GZIP 'git archive --format=tgz' '
280
281 test_expect_success GZIP 'git archive --format=tar.gz' '
282 git archive --format=tar.gz HEAD >j1.tar.gz &&
283 - test_cmp j.tgz j1.tar.gz
283 + test_cmp_bin j.tgz j1.tar.gz
284 '
285
286 test_expect_success GZIP 'infer tgz from .tgz filename' '
287 git archive --output=j2.tgz HEAD &&
288 - test_cmp j.tgz j2.tgz
288 + test_cmp_bin j.tgz j2.tgz
289 '
290
291 test_expect_success GZIP 'infer tgz from .tar.gz filename' '
292 git archive --output=j3.tar.gz HEAD &&
293 - test_cmp j.tgz j3.tar.gz
293 + test_cmp_bin j.tgz j3.tar.gz
294 '
295
296 test_expect_success GZIP 'extract tgz file' '
297 gzip -d -c <j.tgz >j.tar &&
298 - test_cmp b.tar j.tar
298 + test_cmp_bin b.tar j.tar
299 '
300
301 test_expect_success GZIP 'remote tar.gz is allowed by default' '
302 git archive --remote=. --format=tar.gz HEAD >remote.tar.gz &&
303 - test_cmp j.tgz remote.tar.gz
303 + test_cmp_bin j.tgz remote.tar.gz
304 '
305
306 test_expect_success GZIP 'remote tar.gz can be disabled' '
t/t5001-archive-attr.sh
+1 -1
@@ -68,7 +68,7 @@ test_expect_missing worktree2/ignored-by-worktree
68
69 test_expect_success 'git archive vs. bare' '
70 (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
72 '
73
74 test_expect_success 'git archive with worktree attributes, bare' '
t/t5003-archive-zip.sh
+3 -3
@@ -97,15 +97,15 @@ test_expect_success \
97
98 test_expect_success \
99 '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'
101
102 test_expect_success 'git archive --format=zip with --output' \
103 'git archive --format=zip --output=d2.zip HEAD &&
104 - test_cmp d.zip d2.zip'
104 + test_cmp_bin d.zip d2.zip'
105
106 test_expect_success 'git archive with --output, inferring format' '
107 git archive --output=d3.zip HEAD &&
108 - test_cmp d.zip d3.zip
108 + test_cmp_bin d.zip d3.zip
109 '
110
111 test_expect_success \
t/t5004-archive-corner-cases.sh
+1 -1
@@ -45,7 +45,7 @@ test_expect_success HEADER_ONLY_TAR_OK 'tar archive of commit with empty tree' '
45 test_expect_success 'tar archive of empty tree is empty' '
46 git archive --format=tar HEAD: >empty.tar &&
47 perl -e "print \"\\0\" x 10240" >10knuls.tar &&
48 - test_cmp 10knuls.tar empty.tar
48 + test_cmp_bin 10knuls.tar empty.tar
49 '
50
51 test_expect_success 'tar archive of empty tree with prefix' '
t/test-lib-functions.sh
+6
@@ -617,6 +617,12 @@ test_cmp() {
617 $GIT_TEST_CMP "$@"
618 }
619
620 +# test_cmp_bin - helper to compare binary files
621 +
622 +test_cmp_bin() {
623 + cmp "$@"
624 +}
625 +
626 # Check if the file expected to be empty is indeed empty, and barfs
627 # otherwise.
628