Skip to content

Commit d6546af

Browse files
bk2204gitster
authored andcommitted
t: add a function to check executable bit
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4db16f5 commit d6546af

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

t/README

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,12 @@ see test-lib-functions.sh for the full list and their options.
10981098
the symbolic link in the file system and a part that does; then only
10991099
the latter part need be protected by a SYMLINKS prerequisite (see below).
11001100

1101+
- test_path_is_executable
1102+
1103+
This tests whether a file is executable and prints an error message
1104+
if not. This must be used only under the POSIXPERM prerequisite
1105+
(see below).
1106+
11011107
- test_oid_init
11021108

11031109
This function loads facts and useful object IDs related to the hash

t/test-lib-functions.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,15 @@ test_path_is_symlink () {
901901
fi
902902
}
903903

904+
test_path_is_executable () {
905+
test "$#" -ne 1 && BUG "1 param"
906+
if ! test -x "$1"
907+
then
908+
echo "$1 is not executable"
909+
false
910+
fi
911+
}
912+
904913
# Check if the directory exists and is empty as expected, barf otherwise.
905914
test_dir_is_empty () {
906915
test "$#" -ne 1 && BUG "1 param"

0 commit comments

Comments
 (0)