]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: add a function to check executable bit
authorbrian m. carlson <bk2204@github.com>
Tue, 27 Jun 2023 16:18:56 +0000 (16:18 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Jun 2023 18:31:05 +0000 (11:31 -0700)
In line with our other helper functions for paths, let's add a function
to check whether a path is executable, and if not, print a suitable
error message.  Document this function, and note that it must only be
used under the POSIXPERM prerequisite, since it doesn't otherwise work
on Windows.

Signed-off-by: brian m. carlson <bk2204@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/README
t/test-lib-functions.sh

index bdfac4cceb2cef503070bdefc338ed73264e40b0..3e155011de986ff6b3d1143093c6b9657d92ddea 100644 (file)
--- a/t/README
+++ b/t/README
@@ -1098,6 +1098,12 @@ see test-lib-functions.sh for the full list and their options.
    the symbolic link in the file system and a part that does; then only
    the latter part need be protected by a SYMLINKS prerequisite (see below).
 
+ - test_path_is_executable
+
+   This tests whether a file is executable and prints an error message
+   if not. This must be used only under the POSIXPERM prerequisite
+   (see below).
+
  - test_oid_init
 
    This function loads facts and useful object IDs related to the hash
index 6e19ebc922a4166565664995d849bbd248c93ff6..2ef579edf316b41be16188841e54fb3804b8a7f4 100644 (file)
@@ -901,6 +901,15 @@ test_path_is_symlink () {
        fi
 }
 
+test_path_is_executable () {
+       test "$#" -ne 1 && BUG "1 param"
+       if ! test -x "$1"
+       then
+               echo "$1 is not executable"
+               false
+       fi
+}
+
 # Check if the directory exists and is empty as expected, barf otherwise.
 test_dir_is_empty () {
        test "$#" -ne 1 && BUG "1 param"