Skip to content

Commit ef93714

Browse files
committed
Merge branch 'sk/test-cmp-bin' into maint
* sk/test-cmp-bin: t5000, t5003: do not use test_cmp to compare binary files
2 parents 79e9dba + b93e6e3 commit ef93714

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

t/t5000-tar-tree.sh

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

170170
test_expect_success \
@@ -173,15 +173,15 @@ test_expect_success \
173173

174174
test_expect_success \
175175
'git archive vs. the same in a bare repo' \
176-
'test_cmp b.tar b3.tar'
176+
'test_cmp_bin b.tar b3.tar'
177177

178178
test_expect_success 'git archive with --output' \
179179
'git archive --output=b4.tar HEAD &&
180-
test_cmp b.tar b4.tar'
180+
test_cmp_bin b.tar b4.tar'
181181

182182
test_expect_success 'git archive --remote' \
183183
'git archive --remote=. HEAD >b5.tar &&
184-
test_cmp b.tar b5.tar'
184+
test_cmp_bin b.tar b5.tar'
185185

186186
test_expect_success \
187187
'validate file modification time' \
@@ -198,7 +198,7 @@ test_expect_success \
198198

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

204204
test_expect_success \
@@ -244,34 +244,34 @@ test_expect_success 'archive --list shows only enabled remote filters' '
244244
test_expect_success 'invoke tar filter by format' '
245245
git archive --format=tar.foo HEAD >config.tar.foo &&
246246
tr ab ba <config.tar.foo >config.tar &&
247-
test_cmp b.tar config.tar &&
247+
test_cmp_bin b.tar config.tar &&
248248
git archive --format=bar HEAD >config.bar &&
249249
tr ab ba <config.bar >config.tar &&
250-
test_cmp b.tar config.tar
250+
test_cmp_bin b.tar config.tar
251251
'
252252

253253
test_expect_success 'invoke tar filter by extension' '
254254
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 &&
256256
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
258258
'
259259

260260
test_expect_success 'default output format remains tar' '
261261
git archive -o config-implicit.baz HEAD &&
262-
test_cmp b.tar config-implicit.baz
262+
test_cmp_bin b.tar config-implicit.baz
263263
'
264264

265265
test_expect_success 'extension matching requires dot' '
266266
git archive -o config-implicittar.foo HEAD &&
267-
test_cmp b.tar config-implicittar.foo
267+
test_cmp_bin b.tar config-implicittar.foo
268268
'
269269

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

277277
test_expect_success GZIP 'git archive --format=tgz' '
@@ -280,27 +280,27 @@ test_expect_success GZIP 'git archive --format=tgz' '
280280

281281
test_expect_success GZIP 'git archive --format=tar.gz' '
282282
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
284284
'
285285

286286
test_expect_success GZIP 'infer tgz from .tgz filename' '
287287
git archive --output=j2.tgz HEAD &&
288-
test_cmp j.tgz j2.tgz
288+
test_cmp_bin j.tgz j2.tgz
289289
'
290290

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

296296
test_expect_success GZIP 'extract tgz file' '
297297
gzip -d -c <j.tgz >j.tar &&
298-
test_cmp b.tar j.tar
298+
test_cmp_bin b.tar j.tar
299299
'
300300

301301
test_expect_success GZIP 'remote tar.gz is allowed by default' '
302302
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
304304
'
305305

306306
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/test-lib-functions.sh

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

620+
# test_cmp_bin - helper to compare binary files
621+
622+
test_cmp_bin() {
623+
cmp "$@"
624+
}
625+
620626
# Check if the file expected to be empty is indeed empty, and barfs
621627
# otherwise.
622628

0 commit comments

Comments
 (0)