tests: consolidate the file_size function into test-lib-functions.sh

In 8de7eeb54b (compression: unify pack.compression configuration
parsing, 2016-11-15), we introduced identical copies of the `file_size`
helper into three test scripts, with the plan to eventually consolidate
them into a single copy.

Let's do that, and adjust the function name to adhere to the `test_*`
naming convention.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin
2020-11-07 01:12:57 +00:00
committed by Junio C Hamano
parent 898f80736c
commit 53b67a801b
5 changed files with 24 additions and 42 deletions

View File

@ -4,12 +4,6 @@ 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 &&
@ -24,7 +18,7 @@ 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) &&
sz=$(test_file_size pack-*.pack) &&
case "$expect" in
small) test "$sz" -le 100000 ;;
large) test "$sz" -ge 100000 ;;