]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tests: avoid calling Perl just to determine file sizes
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Tue, 29 Jan 2019 14:19:33 +0000 (06:19 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 Jan 2019 17:26:47 +0000 (09:26 -0800)
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>
t/helper/test-path-utils.c
t/t0021-conversion.sh
t/t1050-large.sh
t/t5315-pack-objects-compression.sh
t/t9303-fast-import-compression.sh

index ae091d9b3e63cb506b2530217d40048b301faaa3..30211d6d641538453dd7a36c5627ef11a26e2dde 100644 (file)
@@ -291,6 +291,18 @@ int cmd__path_utils(int argc, const char **argv)
                return !!res;
        }
 
+       if (argc > 2 && !strcmp(argv[1], "file-size")) {
+               int res = 0, i;
+               struct stat st;
+
+               for (i = 2; i < argc; i++)
+                       if (stat(argv[i], &st))
+                               res = error_errno("Cannot stat '%s'", argv[i]);
+                       else
+                               printf("%"PRIuMAX"\n", (uintmax_t)st.st_size);
+               return !!res;
+       }
+
        fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
                argv[1] ? argv[1] : "(there was none)");
        return 1;
index fd5f1ac649dc411bf3c70dcb54f7965e4006aca8..e10f5f787fca8b3f7789bcf9043d7c81929f070e 100755 (executable)
@@ -24,7 +24,7 @@ generate_random_characters () {
 }
 
 file_size () {
-       perl -e 'print -s $ARGV[0]' "$1"
+       test-tool path-utils file-size "$1"
 }
 
 filter_git () {
index 1a9b21b2934b0a4fae7f74bb8c4da65d32218ca0..dcb4dbba673eb2eb6e13117babb6b75e8e59a49a 100755 (executable)
@@ -8,7 +8,7 @@ test_description='adding and checking out large blobs'
 # This should be moved to test-lib.sh together with the
 # copy in t0021 after both topics have graduated to 'master'.
 file_size () {
-       perl -e 'print -s $ARGV[0]' "$1"
+       test-tool path-utils file-size "$1"
 }
 
 test_expect_success setup '
index 34c47dae09966bb3b1de8178769b078509625b1e..df970d75845e782980835d853176acb580ab70d4 100755 (executable)
@@ -7,7 +7,7 @@ test_description='pack-object compression configuration'
 # This should be moved to test-lib.sh together with the
 # copy in t0021 after both topics have graduated to 'master'.
 file_size () {
-       perl -e 'print -s $ARGV[0]' "$1"
+       test-tool path-utils file-size "$1"
 }
 
 test_expect_success setup '
index 856219f46a7fc47332789d66a13f6fd4603520cb..5045f02a5331fcf4cb3973e81cff22620f0ad628 100755 (executable)
@@ -6,7 +6,7 @@ test_description='compression setting of fast-import utility'
 # This should be moved to test-lib.sh together with the
 # copy in t0021 after both topics have graduated to 'master'.
 file_size () {
-       perl -e 'print -s $ARGV[0]' "$1"
+       test-tool path-utils file-size "$1"
 }
 
 import_large () {