summaryrefslogtreecommitdiff
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r--t/test-lib-functions.sh29
1 files changed, 18 insertions, 11 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 59bbf75..2f08ce7 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -367,9 +367,14 @@ test_chmod () {
git update-index --add "--chmod=$@"
}
-# Get the modebits from a file.
+# Get the modebits from a file or directory, ignoring the setgid bit (g+s).
+# This bit is inherited by subdirectories at their creation. So we remove it
+# from the returning string to prevent callers from having to worry about the
+# state of the bit in the test directory.
+#
test_modebits () {
- ls -l "$1" | sed -e 's|^\(..........\).*|\1|'
+ ls -ld "$1" | sed -e 's|^\(..........\).*|\1|' \
+ -e 's|^\(......\)S|\1-|' -e 's|^\(......\)s|\1x|'
}
# Unset a configuration variable, but don't fail if it doesn't exist.
@@ -423,7 +428,7 @@ write_script () {
# - Explicitly using test_have_prereq.
#
# - Implicitly by specifying the prerequisite tag in the calls to
-# test_expect_{success,failure,code}.
+# test_expect_{success,failure} and test_external{,_without_stderr}.
#
# The single parameter is the prerequisite tag (a simple word, in all
# capital letters by convention).
@@ -474,15 +479,15 @@ test_lazy_prereq () {
test_run_lazy_prereq_ () {
script='
-mkdir -p "$TRASH_DIRECTORY/prereq-test-dir" &&
+mkdir -p "$TRASH_DIRECTORY/prereq-test-dir-'"$1"'" &&
(
- cd "$TRASH_DIRECTORY/prereq-test-dir" &&'"$2"'
+ cd "$TRASH_DIRECTORY/prereq-test-dir-'"$1"'" &&'"$2"'
)'
say >&3 "checking prerequisite: $1"
say >&3 "$script"
test_eval_ "$script"
eval_ret=$?
- rm -rf "$TRASH_DIRECTORY/prereq-test-dir"
+ rm -rf "$TRASH_DIRECTORY/prereq-test-dir-$1"
if test "$eval_ret" = 0; then
say >&3 "prerequisite $1 ok"
else
@@ -955,7 +960,7 @@ test_expect_code () {
# - cmp's output is not nearly as easy to read as diff -u
# - not all diff versions understand "-u"
-test_cmp() {
+test_cmp () {
eval "$GIT_TEST_CMP" '"$@"'
}
@@ -968,7 +973,7 @@ test_cmp() {
#
# test_cmp_config foo core.bar
#
-test_cmp_config() {
+test_cmp_config () {
local GD &&
if test "$1" = "-C"
then
@@ -984,7 +989,7 @@ test_cmp_config() {
# test_cmp_bin - helper to compare binary files
-test_cmp_bin() {
+test_cmp_bin () {
cmp "$@"
}
@@ -1202,7 +1207,9 @@ test_create_repo () {
mkdir -p "$repo"
(
cd "$repo" || error "Cannot setup test environment"
- "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" init \
+ "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" -c \
+ init.defaultBranch="${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" \
+ init \
"--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 ||
error "cannot run git init -- have you built things yet?"
mv .git/hooks .git/hooks-disabled
@@ -1418,7 +1425,7 @@ nongit () {
# whitespace and put in a single packet. Note that data containing NULs must be
# given on stdin, and that empty input becomes an empty packet, not a flush
# packet (for that you can just print 0000 yourself).
-packetize() {
+packetize () {
if test $# -gt 0
then
packet="$*"