summaryrefslogtreecommitdiff
path: root/t/helper/test-path-utils.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2019-01-29 14:19:33 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-29 17:26:47 (GMT)
commit5868bd862059fcf96e2908e94427da6e7fcd1394 (patch)
treefe4c30c50d0df19bf547db69da1e633ca6e4b7d4 /t/helper/test-path-utils.c
parent5f7864663bdb71635b4aaf0d996db14e4d521ff6 (diff)
downloadgit-5868bd862059fcf96e2908e94427da6e7fcd1394.zip
git-5868bd862059fcf96e2908e94427da6e7fcd1394.tar.gz
git-5868bd862059fcf96e2908e94427da6e7fcd1394.tar.bz2
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>
Diffstat (limited to 't/helper/test-path-utils.c')
-rw-r--r--t/helper/test-path-utils.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index ae091d9..30211d6 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -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;