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 retirementmaint
commit
2019256717
|
@ -63,6 +63,7 @@ create_lib_submodule_repo () {
|
||||||
git init submodule_update_repo &&
|
git init submodule_update_repo &&
|
||||||
(
|
(
|
||||||
cd submodule_update_repo &&
|
cd submodule_update_repo &&
|
||||||
|
branch=$(git symbolic-ref --short HEAD) &&
|
||||||
echo "expect" >>.gitignore &&
|
echo "expect" >>.gitignore &&
|
||||||
echo "actual" >>.gitignore &&
|
echo "actual" >>.gitignore &&
|
||||||
echo "x" >file1 &&
|
echo "x" >file1 &&
|
||||||
|
@ -144,7 +145,7 @@ create_lib_submodule_repo () {
|
||||||
git checkout -b valid_sub1 &&
|
git checkout -b valid_sub1 &&
|
||||||
git revert HEAD &&
|
git revert HEAD &&
|
||||||
|
|
||||||
git checkout "${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}"
|
git checkout "$branch"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,10 +84,6 @@ _run_sub_test_lib_test_common () {
|
||||||
passing metrics
|
passing metrics
|
||||||
'
|
'
|
||||||
|
|
||||||
# Tell the framework that we are self-testing to make sure
|
|
||||||
# it yields a stable result.
|
|
||||||
GIT_TEST_FRAMEWORK_SELFTEST=t &&
|
|
||||||
|
|
||||||
# Point to the t/test-lib.sh, which isn't in ../ as usual
|
# Point to the t/test-lib.sh, which isn't in ../ as usual
|
||||||
. "\$TEST_DIRECTORY"/test-lib.sh
|
. "\$TEST_DIRECTORY"/test-lib.sh
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -65,9 +65,7 @@ test_expect_success 'parse errors in blobs are properly attributed' '
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'can parse blob ending with CR' '
|
test_expect_success 'can parse blob ending with CR' '
|
||||||
printf "[some]key = value\\r" >config &&
|
test_commit --printf CR config "[some]key = value\\r" &&
|
||||||
git add config &&
|
|
||||||
git commit -m CR &&
|
|
||||||
echo value >expect &&
|
echo value >expect &&
|
||||||
git config --blob=HEAD:config some.key >actual &&
|
git config --blob=HEAD:config some.key >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
|
|
|
@ -7,11 +7,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
test_expect_success setup '
|
test_expect_success setup '
|
||||||
test_commit A &&
|
test_commit --annotate A &&
|
||||||
git tag -f -a -m "annotated A" A &&
|
|
||||||
git checkout -b side &&
|
git checkout -b side &&
|
||||||
test_commit B &&
|
test_commit --annotate B &&
|
||||||
git tag -f -a -m "annotated B" B &&
|
|
||||||
git checkout main &&
|
git checkout main &&
|
||||||
test_commit C &&
|
test_commit C &&
|
||||||
git branch B A^0
|
git branch B A^0
|
||||||
|
|
|
@ -179,8 +179,7 @@ test_expect_success 'rerere and rerere forget (subdirectory)' '
|
||||||
|
|
||||||
test_expect_success 'rerere forget (binary)' '
|
test_expect_success 'rerere forget (binary)' '
|
||||||
git checkout -f side &&
|
git checkout -f side &&
|
||||||
printf "a\0c" >binary &&
|
test_commit --printf binary binary "a\0c" &&
|
||||||
git commit -a -m binary &&
|
|
||||||
test_must_fail git merge second &&
|
test_must_fail git merge second &&
|
||||||
git rerere forget binary
|
git rerere forget binary
|
||||||
'
|
'
|
||||||
|
|
|
@ -26,10 +26,8 @@ test_expect_success 'chmod' '
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'prepare binary file' '
|
test_expect_success 'prepare binary file' '
|
||||||
git commit -m rezrov &&
|
git commit -m one &&
|
||||||
printf "\00\01\02\03\04\05\06" >binbin &&
|
test_commit --printf two binbin "\00\01\02\03\04\05\06"
|
||||||
git add binbin &&
|
|
||||||
git commit -m binbin
|
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '--stat output after text chmod' '
|
test_expect_success '--stat output after text chmod' '
|
||||||
|
|
|
@ -26,12 +26,8 @@ EOF
|
||||||
chmod +x hexdump
|
chmod +x hexdump
|
||||||
|
|
||||||
test_expect_success 'setup binary file with history' '
|
test_expect_success 'setup binary file with history' '
|
||||||
printf "\\0\\n" >file &&
|
test_commit --printf one file "\\0\\n" &&
|
||||||
git add file &&
|
test_commit --printf --append two file "\\01\\n"
|
||||||
git commit -m one &&
|
|
||||||
printf "\\01\\n" >>file &&
|
|
||||||
git add file &&
|
|
||||||
git commit -m two
|
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'file is considered binary by porcelain' '
|
test_expect_success 'file is considered binary by porcelain' '
|
||||||
|
|
|
@ -5,7 +5,6 @@ test_description='remote push rejects are reported by client'
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
test_expect_success 'setup' '
|
test_expect_success 'setup' '
|
||||||
mkdir .git/hooks &&
|
|
||||||
write_script .git/hooks/update <<-\EOF &&
|
write_script .git/hooks/update <<-\EOF &&
|
||||||
exit 1
|
exit 1
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -20,8 +20,6 @@ test_expect_success 'setup' '
|
||||||
git checkout main
|
git checkout main
|
||||||
'
|
'
|
||||||
|
|
||||||
mkdir .git/hooks
|
|
||||||
|
|
||||||
cat >.git/hooks/post-rewrite <<EOF
|
cat >.git/hooks/post-rewrite <<EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
echo \$@ > "$TRASH_DIRECTORY"/post-rewrite.args
|
echo \$@ > "$TRASH_DIRECTORY"/post-rewrite.args
|
||||||
|
|
|
@ -5,7 +5,6 @@ test_description='remote messages are colorized on the client'
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
test_expect_success 'setup' '
|
test_expect_success 'setup' '
|
||||||
mkdir .git/hooks &&
|
|
||||||
write_script .git/hooks/update <<-\EOF &&
|
write_script .git/hooks/update <<-\EOF &&
|
||||||
echo error: error
|
echo error: error
|
||||||
echo ERROR: also highlighted
|
echo ERROR: also highlighted
|
||||||
|
|
|
@ -746,14 +746,8 @@ test_expect_success 'pull --rebase fails on corrupt HEAD' '
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'setup for detecting upstreamed changes' '
|
test_expect_success 'setup for detecting upstreamed changes' '
|
||||||
mkdir src &&
|
test_create_repo src &&
|
||||||
(
|
test_commit -C src --printf one stuff "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" &&
|
||||||
cd src &&
|
|
||||||
git init &&
|
|
||||||
printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff &&
|
|
||||||
git add stuff &&
|
|
||||||
git commit -m "Initial revision"
|
|
||||||
) &&
|
|
||||||
git clone src dst &&
|
git clone src dst &&
|
||||||
(
|
(
|
||||||
cd src &&
|
cd src &&
|
||||||
|
|
|
@ -31,64 +31,32 @@ check_describe () {
|
||||||
}
|
}
|
||||||
|
|
||||||
test_expect_success setup '
|
test_expect_success setup '
|
||||||
|
test_commit initial file one &&
|
||||||
|
test_commit second file two &&
|
||||||
|
test_commit third file three &&
|
||||||
|
test_commit --annotate A file A &&
|
||||||
|
test_commit c file c &&
|
||||||
|
|
||||||
test_tick &&
|
git reset --hard second &&
|
||||||
echo one >file && git add file && git commit -m initial &&
|
test_commit --annotate B side B &&
|
||||||
one=$(git rev-parse HEAD) &&
|
|
||||||
|
|
||||||
git describe --always HEAD &&
|
|
||||||
|
|
||||||
test_tick &&
|
|
||||||
echo two >file && git add file && git commit -m second &&
|
|
||||||
two=$(git rev-parse HEAD) &&
|
|
||||||
|
|
||||||
test_tick &&
|
|
||||||
echo three >file && git add file && git commit -m third &&
|
|
||||||
|
|
||||||
test_tick &&
|
|
||||||
echo A >file && git add file && git commit -m A &&
|
|
||||||
test_tick &&
|
|
||||||
git tag -a -m A A &&
|
|
||||||
|
|
||||||
test_tick &&
|
|
||||||
echo c >file && git add file && git commit -m c &&
|
|
||||||
test_tick &&
|
|
||||||
git tag c &&
|
|
||||||
|
|
||||||
git reset --hard $two &&
|
|
||||||
test_tick &&
|
|
||||||
echo B >side && git add side && git commit -m B &&
|
|
||||||
test_tick &&
|
|
||||||
git tag -a -m B B &&
|
|
||||||
|
|
||||||
test_tick &&
|
test_tick &&
|
||||||
git merge -m Merged c &&
|
git merge -m Merged c &&
|
||||||
merged=$(git rev-parse HEAD) &&
|
merged=$(git rev-parse HEAD) &&
|
||||||
|
|
||||||
git reset --hard $two &&
|
git reset --hard second &&
|
||||||
test_tick &&
|
test_commit --no-tag D another D &&
|
||||||
echo D >another && git add another && git commit -m D &&
|
|
||||||
test_tick &&
|
|
||||||
git tag -a -m D D &&
|
|
||||||
test_tick &&
|
test_tick &&
|
||||||
git tag -a -m R R &&
|
git tag -a -m R R &&
|
||||||
|
|
||||||
test_tick &&
|
test_commit e another DD &&
|
||||||
echo DD >another && git commit -a -m another &&
|
test_commit --no-tag "yet another" another DDD &&
|
||||||
|
|
||||||
test_tick &&
|
|
||||||
git tag e &&
|
|
||||||
|
|
||||||
test_tick &&
|
|
||||||
echo DDD >another && git commit -a -m "yet another" &&
|
|
||||||
|
|
||||||
test_tick &&
|
test_tick &&
|
||||||
git merge -m Merged $merged &&
|
git merge -m Merged $merged &&
|
||||||
|
|
||||||
test_tick &&
|
test_commit --no-tag x file
|
||||||
echo X >file && echo X >side && git add file side &&
|
|
||||||
git commit -m x
|
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
check_describe A-* HEAD
|
check_describe A-* HEAD
|
||||||
|
|
|
@ -172,12 +172,23 @@ debug () {
|
||||||
# --notick
|
# --notick
|
||||||
# Do not call test_tick before making a commit
|
# Do not call test_tick before making a commit
|
||||||
# --append
|
# --append
|
||||||
# Use "echo >>" instead of "echo >" when writing "<contents>" to
|
# Use ">>" instead of ">" when writing "<contents>" to "<file>"
|
||||||
# "<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
|
# --signoff
|
||||||
# Invoke "git commit" with --signoff
|
# Invoke "git commit" with --signoff
|
||||||
# --author <author>
|
# --author <author>
|
||||||
# Invoke "git commit" with --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
|
# This will commit a file with the given contents and the given commit
|
||||||
# message, and tag the resulting commit with the given tag name.
|
# message, and tag the resulting commit with the given tag name.
|
||||||
|
@ -186,17 +197,21 @@ debug () {
|
||||||
|
|
||||||
test_commit () {
|
test_commit () {
|
||||||
notick= &&
|
notick= &&
|
||||||
|
echo=echo &&
|
||||||
append= &&
|
append= &&
|
||||||
author= &&
|
author= &&
|
||||||
signoff= &&
|
signoff= &&
|
||||||
indir= &&
|
indir= &&
|
||||||
no_tag= &&
|
tag=light &&
|
||||||
while test $# != 0
|
while test $# != 0
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--notick)
|
--notick)
|
||||||
notick=yes
|
notick=yes
|
||||||
;;
|
;;
|
||||||
|
--printf)
|
||||||
|
echo=printf
|
||||||
|
;;
|
||||||
--append)
|
--append)
|
||||||
append=yes
|
append=yes
|
||||||
;;
|
;;
|
||||||
|
@ -218,7 +233,10 @@ test_commit () {
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--no-tag)
|
--no-tag)
|
||||||
no_tag=yes
|
tag=none
|
||||||
|
;;
|
||||||
|
--annotate)
|
||||||
|
tag=annotate
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
|
@ -230,9 +248,9 @@ test_commit () {
|
||||||
file=${2:-"$1.t"} &&
|
file=${2:-"$1.t"} &&
|
||||||
if test -n "$append"
|
if test -n "$append"
|
||||||
then
|
then
|
||||||
echo "${3-$1}" >>"$indir$file"
|
$echo "${3-$1}" >>"$indir$file"
|
||||||
else
|
else
|
||||||
echo "${3-$1}" >"$indir$file"
|
$echo "${3-$1}" >"$indir$file"
|
||||||
fi &&
|
fi &&
|
||||||
git ${indir:+ -C "$indir"} add "$file" &&
|
git ${indir:+ -C "$indir"} add "$file" &&
|
||||||
if test -z "$notick"
|
if test -z "$notick"
|
||||||
|
@ -242,10 +260,20 @@ test_commit () {
|
||||||
git ${indir:+ -C "$indir"} commit \
|
git ${indir:+ -C "$indir"} commit \
|
||||||
${author:+ --author "$author"} \
|
${author:+ --author "$author"} \
|
||||||
$signoff -m "$1" &&
|
$signoff -m "$1" &&
|
||||||
if test -z "$no_tag"
|
case "$tag" in
|
||||||
then
|
none)
|
||||||
|
;;
|
||||||
|
light)
|
||||||
git ${indir:+ -C "$indir"} tag "${4:-$1}"
|
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>
|
# Call test_merge with the arguments "<message> <commit>", where <commit>
|
||||||
|
@ -1215,22 +1243,10 @@ test_atexit () {
|
||||||
} && (exit \"\$eval_ret\"); eval_ret=\$?; $test_atexit_cleanup"
|
} && (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>
|
# Usage: test_create_repo <directory>
|
||||||
test_create_repo () {
|
test_create_repo () {
|
||||||
test "$#" = 1 ||
|
git init "$@"
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function helps on symlink challenged file systems when it is not
|
# This function helps on symlink challenged file systems when it is not
|
||||||
|
|
|
@ -64,6 +64,11 @@ then
|
||||||
export GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS
|
export GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Explicitly set the default branch name for testing, to avoid the
|
||||||
|
# transitory "git init" warning under --verbose.
|
||||||
|
: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master}
|
||||||
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# It appears that people try to run tests without building...
|
# It appears that people try to run tests without building...
|
||||||
"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null
|
"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null
|
||||||
|
@ -1172,7 +1177,7 @@ test_done () {
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$debug"
|
if test -z "$debug" && test -n "$remove_trash"
|
||||||
then
|
then
|
||||||
test -d "$TRASH_DIRECTORY" ||
|
test -d "$TRASH_DIRECTORY" ||
|
||||||
error "Tests passed but trash directory already removed before test cleanup; aborting"
|
error "Tests passed but trash directory already removed before test cleanup; aborting"
|
||||||
|
@ -1337,28 +1342,8 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test repository
|
# Are we running this test at all?
|
||||||
rm -fr "$TRASH_DIRECTORY" || {
|
remove_trash=
|
||||||
GIT_EXIT_OK=t
|
|
||||||
echo >&5 "FATAL: Cannot prepare test area"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
HOME="$TRASH_DIRECTORY"
|
|
||||||
GNUPGHOME="$HOME/gnupg-home-not-used"
|
|
||||||
export HOME GNUPGHOME
|
|
||||||
|
|
||||||
if test -z "$TEST_NO_CREATE_REPO"
|
|
||||||
then
|
|
||||||
test_create_repo "$TRASH_DIRECTORY"
|
|
||||||
else
|
|
||||||
mkdir -p "$TRASH_DIRECTORY"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use -P to resolve symlinks in our working directory so that the cwd
|
|
||||||
# in subprocesses like git equals our $PWD (for pathname comparisons).
|
|
||||||
cd -P "$TRASH_DIRECTORY" || exit 1
|
|
||||||
|
|
||||||
this_test=${0##*/}
|
this_test=${0##*/}
|
||||||
this_test=${this_test%%-*}
|
this_test=${this_test%%-*}
|
||||||
if match_pattern_list "$this_test" $GIT_SKIP_TESTS
|
if match_pattern_list "$this_test" $GIT_SKIP_TESTS
|
||||||
|
@ -1368,6 +1353,31 @@ then
|
||||||
test_done
|
test_done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Last-minute variable setup
|
||||||
|
HOME="$TRASH_DIRECTORY"
|
||||||
|
GNUPGHOME="$HOME/gnupg-home-not-used"
|
||||||
|
export HOME GNUPGHOME
|
||||||
|
|
||||||
|
# Test repository
|
||||||
|
rm -fr "$TRASH_DIRECTORY" || {
|
||||||
|
GIT_EXIT_OK=t
|
||||||
|
echo >&5 "FATAL: Cannot prepare test area"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_trash=t
|
||||||
|
if test -z "$TEST_NO_CREATE_REPO"
|
||||||
|
then
|
||||||
|
git init "$TRASH_DIRECTORY" >&3 2>&4 ||
|
||||||
|
error "cannot run git init"
|
||||||
|
else
|
||||||
|
mkdir -p "$TRASH_DIRECTORY"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use -P to resolve symlinks in our working directory so that the cwd
|
||||||
|
# in subprocesses like git equals our $PWD (for pathname comparisons).
|
||||||
|
cd -P "$TRASH_DIRECTORY" || exit 1
|
||||||
|
|
||||||
if test -n "$write_junit_xml"
|
if test -n "$write_junit_xml"
|
||||||
then
|
then
|
||||||
junit_xml_dir="$TEST_OUTPUT_DIRECTORY/out"
|
junit_xml_dir="$TEST_OUTPUT_DIRECTORY/out"
|
||||||
|
|
Loading…
Reference in New Issue