test functions: add function `test_file_not_empty`
authorRohit Ashiwal <rohit.ashiwal265@gmail.com>
Mon, 4 Mar 2019 12:07:59 +0000 (17:37 +0530)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 Mar 2019 05:21:27 +0000 (14:21 +0900)
Add a helper function to ensure that a given path is a non-empty file,
and give an error message when it is not.

Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib-functions.sh
index 80402a428f7735a031658a904d4f623f38e43464..681c41ba329a90db8c668fde4640025872f1e622 100644 (file)
@@ -593,6 +593,15 @@ test_dir_is_empty () {
        fi
 }
 
+# Check if the file exists and has a size greater than zero
+test_file_not_empty () {
+       if ! test -s "$1"
+       then
+               echo "'$1' is not a non-empty file."
+               false
+       fi
+}
+
 test_path_is_missing () {
        if test -e "$1"
        then