1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-20 06:26:30 +02:00
git/t/t5315-pack-objects-compress...
Johannes Schindelin 5868bd8620 tests: avoid calling Perl just to determine file sizes
It is a bit ridiculous to spin up a full-blown Perl instance (especially
on Windows, where that means spinning up a full POSIX emulation layer,
AKA the MSYS2 runtime) just to tell how large a given file is.

So let's just use the test-tool to do that job instead.

This command will also be used over the next commits, to allow for
cutting out individual test cases' verbose log from the file generated
via --verbose-log.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-01-29 09:26:47 -08:00

45 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
test_description='pack-object compression configuration'
. ./test-lib.sh
# This should be moved to test-lib.sh together with the
# copy in t0021 after both topics have graduated to 'master'.
file_size () {
test-tool path-utils file-size "$1"
}
test_expect_success setup '
printf "%2000000s" X |
git hash-object -w --stdin >object-name &&
# make sure it resulted in a loose object
ob=$(sed -e "s/\(..\).*/\1/" object-name) &&
ject=$(sed -e "s/..\(.*\)/\1/" object-name) &&
test -f .git/objects/$ob/$ject
'
while read expect config
do
test_expect_success "pack-objects with $config" '
test_when_finished "rm -f pack-*.*" &&
git $config pack-objects pack <object-name &&
sz=$(file_size pack-*.pack) &&
case "$expect" in
small) test "$sz" -le 100000 ;;
large) test "$sz" -ge 100000 ;;
esac
'
done <<\EOF
large -c core.compression=0
small -c core.compression=9
large -c core.compression=0 -c pack.compression=0
large -c core.compression=9 -c pack.compression=0
small -c core.compression=0 -c pack.compression=9
small -c core.compression=9 -c pack.compression=9
large -c pack.compression=0
small -c pack.compression=9
EOF
test_done