Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-06-14 07:33:29 +0300
committerJunio C Hamano <gitster@pobox.com>2021-06-14 07:33:29 +0300
commit2019256717d70bcfa1c6cd3869cfdc02310adb7a (patch)
treea354a9651be896d3b088356b0a73fb280fb14df8 /t/test-lib-functions.sh
parentc189dba20e6d94e4408bcc6ad298f0c157f05b43 (diff)
parentf0d4d398e281009bc5e34d830b37c0c1df2fb8a8 (diff)
Merge branch 'ab/test-lib-updates'
Test clean-up. * ab/test-lib-updates: test-lib: split up and deprecate test_create_repo() test-lib: do not show advice about init.defaultBranch under --verbose test-lib: reformat argument list in test_create_repo() submodule tests: use symbolic-ref --short to discover branch name test-lib functions: add --printf option to test_commit describe tests: convert setup to use test_commit test-lib functions: add an --annotated option to "test_commit" test-lib-functions: document test_commit --no-tag test-lib-functions: reword "test_commit --append" docs test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable test-lib: bring $remove_trash out of retirement
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r--t/test-lib-functions.sh62
1 files changed, 39 insertions, 23 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index b823c14027..f0448daa74 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>
@@ -1215,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