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.sh75
1 files changed, 45 insertions, 30 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 6348e8d733..b2810478a2 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -172,12 +172,23 @@ debug () {
# --notick
# Do not call test_tick before making a commit
# --append
-# Use "echo >>" instead of "echo >" when writing "<contents>" to
-# "<file>"
+# Use ">>" instead of ">" when writing "<contents>" to "<file>"
+# --printf
+# Use "printf" instead of "echo" when writing "<contents>" to
+# "<file>", use this to write escape sequences such as "\0", a
+# trailing "\n" won't be added automatically. This option
+# supports nothing but the FORMAT of printf(1), i.e. no custom
+# ARGUMENT(s).
# --signoff
# Invoke "git commit" with --signoff
# --author <author>
# Invoke "git commit" with --author <author>
+# --no-tag
+# Do not tag the resulting commit
+# --annotate
+# Create an annotated tag with "--annotate -m <message>". Calls
+# test_tick between making the commit and tag, unless --notick
+# is given.
#
# This will commit a file with the given contents and the given commit
# message, and tag the resulting commit with the given tag name.
@@ -186,17 +197,21 @@ debug () {
test_commit () {
notick= &&
+ echo=echo &&
append= &&
author= &&
signoff= &&
indir= &&
- no_tag= &&
+ tag=light &&
while test $# != 0
do
case "$1" in
--notick)
notick=yes
;;
+ --printf)
+ echo=printf
+ ;;
--append)
append=yes
;;
@@ -218,7 +233,10 @@ test_commit () {
shift
;;
--no-tag)
- no_tag=yes
+ tag=none
+ ;;
+ --annotate)
+ tag=annotate
;;
*)
break
@@ -230,9 +248,9 @@ test_commit () {
file=${2:-"$1.t"} &&
if test -n "$append"
then
- echo "${3-$1}" >>"$indir$file"
+ $echo "${3-$1}" >>"$indir$file"
else
- echo "${3-$1}" >"$indir$file"
+ $echo "${3-$1}" >"$indir$file"
fi &&
git ${indir:+ -C "$indir"} add "$file" &&
if test -z "$notick"
@@ -242,10 +260,20 @@ test_commit () {
git ${indir:+ -C "$indir"} commit \
${author:+ --author "$author"} \
$signoff -m "$1" &&
- if test -z "$no_tag"
- then
+ case "$tag" in
+ none)
+ ;;
+ light)
git ${indir:+ -C "$indir"} tag "${4:-$1}"
- fi
+ ;;
+ annotate)
+ if test -z "$notick"
+ then
+ test_tick
+ fi &&
+ git ${indir:+ -C "$indir"} tag -a -m "$1" "${4:-$1}"
+ ;;
+ esac
}
# Call test_merge with the arguments "<message> <commit>", where <commit>
@@ -1025,13 +1053,6 @@ test_cmp_bin () {
cmp "$@"
}
-# Wrapper for test_cmp which used to be used for
-# GIT_TEST_GETTEXT_POISON=false. Only here as a shim for other
-# in-flight changes. Should not be used and will be removed soon.
-test_i18ncmp () {
- test_cmp "$@"
-}
-
# Wrapper for grep which used to be used for
# GIT_TEST_GETTEXT_POISON=false. Only here as a shim for other
# in-flight changes. Should not be used and will be removed soon.
@@ -1222,22 +1243,10 @@ test_atexit () {
} && (exit \"\$eval_ret\"); eval_ret=\$?; $test_atexit_cleanup"
}
-# Most tests can use the created repository, but some may need to create more.
+# Deprecated wrapper for "git init", use "git init" directly instead
# Usage: test_create_repo <directory>
test_create_repo () {
- test "$#" = 1 ||
- BUG "not 1 parameter to test-create-repo"
- repo="$1"
- mkdir -p "$repo"
- (
- cd "$repo" || error "Cannot setup test environment"
- "${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
- ) || exit
+ git init "$@"
}
# This function helps on symlink challenged file systems when it is not
@@ -1699,3 +1708,9 @@ test_region () {
return 0
}
+
+# Print the destination of symlink(s) provided as arguments. Basically
+# the same as the readlink command, but it's not available everywhere.
+test_readlink () {
+ perl -le 'print readlink($_) for @ARGV' "$@"
+}