aboutsummaryrefslogtreecommitdiffstats
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
authorbrian m. carlson <bk2204@github.com>2023-06-27 16:18:56 +0000
committerJunio C Hamano <gitster@pobox.com>2023-06-27 11:31:05 -0700
commitd6546af75c3cda2815f2e4d5322dd7a41cc0963b (patch)
tree45c9ba6f88b5e41afa7e43df4fb924673f4973b6 /t/test-lib-functions.sh
parentvar: mark unused parameters in git_var callbacks (diff)
downloadgit-d6546af75c3cda2815f2e4d5322dd7a41cc0963b.tar.gz
git-d6546af75c3cda2815f2e4d5322dd7a41cc0963b.zip
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 <bk2204@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r--t/test-lib-functions.sh9
1 files changed, 9 insertions, 0 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 6e19ebc922..2ef579edf3 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -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"