Merge branch 'sg/test-atexit'
Test framework update to more robustly clean up leftover files and processes after tests are done. * sg/test-atexit: t9811-git-p4-label-import: fix pipeline negation git p4 test: disable '-x' tracing in the p4d watchdog loop git p4 test: simplify timeout handling git p4 test: clean up the p4d cleanup functions git p4 test: use 'test_atexit' to kill p4d and the watchdog process t0301-credential-cache: use 'test_atexit' to stop the credentials helper tests: use 'test_atexit' to stop httpd git-daemon: use 'test_atexit` to stop 'git-daemon' test-lib: introduce 'test_atexit' t/lib-git-daemon: make sure to kill the 'git-daemon' process test-lib: fix interrupt handling with 'dash' and '--verbose-log -x'
This commit is contained in:
commit
579b75ad95
20
t/README
20
t/README
@ -871,6 +871,26 @@ library for your script to use.
|
||||
...
|
||||
'
|
||||
|
||||
- test_atexit <script>
|
||||
|
||||
Prepend <script> to a list of commands to run unconditionally to
|
||||
clean up before the test script exits, e.g. to stop a daemon:
|
||||
|
||||
test_expect_success 'test git daemon' '
|
||||
git daemon &
|
||||
daemon_pid=$! &&
|
||||
test_atexit 'kill $daemon_pid' &&
|
||||
hello world
|
||||
'
|
||||
|
||||
The commands will be executed before the trash directory is removed,
|
||||
i.e. the atexit commands will still be able to access any pidfiles or
|
||||
socket files.
|
||||
|
||||
Note that these commands will be run even when a test script run
|
||||
with '--immediate' fails. Be careful with your atexit commands to
|
||||
minimize any changes to the failed state.
|
||||
|
||||
- test_write_lines <lines>
|
||||
|
||||
Write <lines> on standard output, one line per argument.
|
||||
|
@ -37,5 +37,4 @@ test_expect_success "fetch with $VERSION_B" '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
stop_git_daemon
|
||||
test_done
|
||||
|
@ -13,7 +13,6 @@
|
||||
#
|
||||
# test_expect_success ...
|
||||
#
|
||||
# stop_git_daemon
|
||||
# test_done
|
||||
|
||||
test_tristate GIT_TEST_GIT_DAEMON
|
||||
@ -31,10 +30,12 @@ fi
|
||||
test_set_port LIB_GIT_DAEMON_PORT
|
||||
|
||||
GIT_DAEMON_PID=
|
||||
GIT_DAEMON_PIDFILE="$PWD"/daemon.pid
|
||||
GIT_DAEMON_DOCUMENT_ROOT_PATH="$PWD"/repo
|
||||
GIT_DAEMON_HOST_PORT=127.0.0.1:$LIB_GIT_DAEMON_PORT
|
||||
GIT_DAEMON_URL=git://$GIT_DAEMON_HOST_PORT
|
||||
|
||||
registered_stop_git_daemon_atexit_handler=
|
||||
start_git_daemon() {
|
||||
if test -n "$GIT_DAEMON_PID"
|
||||
then
|
||||
@ -43,13 +44,19 @@ start_git_daemon() {
|
||||
|
||||
mkdir -p "$GIT_DAEMON_DOCUMENT_ROOT_PATH"
|
||||
|
||||
trap 'code=$?; stop_git_daemon; (exit $code); die' EXIT
|
||||
# One of the test scripts stops and then re-starts 'git daemon'.
|
||||
# Don't register and then run the same atexit handlers several times.
|
||||
if test -z "$registered_stop_git_daemon_atexit_handler"
|
||||
then
|
||||
test_atexit 'stop_git_daemon'
|
||||
registered_stop_git_daemon_atexit_handler=AlreadyDone
|
||||
fi
|
||||
|
||||
say >&3 "Starting git daemon ..."
|
||||
mkfifo git_daemon_output
|
||||
${LIB_GIT_DAEMON_COMMAND:-git daemon} \
|
||||
--listen=127.0.0.1 --port="$LIB_GIT_DAEMON_PORT" \
|
||||
--reuseaddr --verbose \
|
||||
--reuseaddr --verbose --pid-file="$GIT_DAEMON_PIDFILE" \
|
||||
--base-path="$GIT_DAEMON_DOCUMENT_ROOT_PATH" \
|
||||
"$@" "$GIT_DAEMON_DOCUMENT_ROOT_PATH" \
|
||||
>&3 2>git_daemon_output &
|
||||
@ -65,7 +72,7 @@ start_git_daemon() {
|
||||
then
|
||||
kill "$GIT_DAEMON_PID"
|
||||
wait "$GIT_DAEMON_PID"
|
||||
trap 'die' EXIT
|
||||
unset GIT_DAEMON_PID
|
||||
test_skip_or_die $GIT_TEST_GIT_DAEMON \
|
||||
"git daemon failed to start"
|
||||
fi
|
||||
@ -77,8 +84,6 @@ stop_git_daemon() {
|
||||
return
|
||||
fi
|
||||
|
||||
trap 'die' EXIT
|
||||
|
||||
# kill git-daemon child of git
|
||||
say >&3 "Stopping git daemon ..."
|
||||
kill "$GIT_DAEMON_PID"
|
||||
@ -88,8 +93,9 @@ stop_git_daemon() {
|
||||
then
|
||||
error "git daemon exited with status: $ret"
|
||||
fi
|
||||
kill "$(cat "$GIT_DAEMON_PIDFILE")" 2>/dev/null
|
||||
GIT_DAEMON_PID=
|
||||
rm -f git_daemon_output
|
||||
rm -f git_daemon_output "$GIT_DAEMON_PIDFILE"
|
||||
}
|
||||
|
||||
# A stripped-down version of a netcat client, that connects to a "host:port"
|
||||
|
@ -44,15 +44,6 @@ native_path () {
|
||||
echo "$path"
|
||||
}
|
||||
|
||||
# On Solaris the 'date +%s' function is not supported and therefore we
|
||||
# need this replacement.
|
||||
# Attention: This function is not safe again against time offset updates
|
||||
# at runtime (e.g. via NTP). The 'clock_gettime(CLOCK_MONOTONIC)'
|
||||
# function could fix that but it is not in Python until 3.3.
|
||||
time_in_seconds () {
|
||||
(cd / && "$PYTHON_PATH" -c 'import time; print(int(time.time()))')
|
||||
}
|
||||
|
||||
test_set_port P4DPORT
|
||||
|
||||
P4PORT=localhost:$P4DPORT
|
||||
@ -67,14 +58,9 @@ cli="$TRASH_DIRECTORY/cli"
|
||||
git="$TRASH_DIRECTORY/git"
|
||||
pidfile="$TRASH_DIRECTORY/p4d.pid"
|
||||
|
||||
# Sometimes "prove" seems to hang on exit because p4d is still running
|
||||
cleanup () {
|
||||
if test -f "$pidfile"
|
||||
then
|
||||
kill -9 $(cat "$pidfile") 2>/dev/null && exit 255
|
||||
fi
|
||||
stop_p4d_and_watchdog () {
|
||||
kill -9 $p4d_pid $watchdog_pid
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# git p4 submit generates a temp file, which will
|
||||
# not get cleaned up if the submission fails. Don't
|
||||
@ -82,7 +68,16 @@ trap cleanup EXIT
|
||||
TMPDIR="$TRASH_DIRECTORY"
|
||||
export TMPDIR
|
||||
|
||||
registered_stop_p4d_atexit_handler=
|
||||
start_p4d () {
|
||||
# One of the test scripts stops and then re-starts p4d.
|
||||
# Don't register and then run the same atexit handlers several times.
|
||||
if test -z "$registered_stop_p4d_atexit_handler"
|
||||
then
|
||||
test_atexit 'stop_p4d_and_watchdog'
|
||||
registered_stop_p4d_atexit_handler=AlreadyDone
|
||||
fi
|
||||
|
||||
mkdir -p "$db" "$cli" "$git" &&
|
||||
rm -f "$pidfile" &&
|
||||
(
|
||||
@ -92,6 +87,7 @@ start_p4d () {
|
||||
echo $! >"$pidfile"
|
||||
}
|
||||
) &&
|
||||
p4d_pid=$(cat "$pidfile")
|
||||
|
||||
# This gives p4d a long time to start up, as it can be
|
||||
# quite slow depending on the machine. Set this environment
|
||||
@ -99,18 +95,18 @@ start_p4d () {
|
||||
# an automated test setup. If the p4d process dies, that
|
||||
# will be caught with the "kill -0" check below.
|
||||
i=${P4D_START_PATIENCE:-300}
|
||||
pid=$(cat "$pidfile")
|
||||
|
||||
timeout=$(($(time_in_seconds) + $P4D_TIMEOUT))
|
||||
nr_tries_left=$P4D_TIMEOUT
|
||||
while true
|
||||
do
|
||||
if test $(time_in_seconds) -gt $timeout
|
||||
if test $nr_tries_left -eq 0
|
||||
then
|
||||
kill -9 $pid
|
||||
kill -9 $p4d_pid
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done &
|
||||
nr_tries_left=$(($nr_tries_left - 1))
|
||||
done 2>/dev/null 4>&2 &
|
||||
watchdog_pid=$!
|
||||
|
||||
ready=
|
||||
@ -123,7 +119,7 @@ start_p4d () {
|
||||
break
|
||||
fi
|
||||
# fail if p4d died
|
||||
kill -0 $pid 2>/dev/null || break
|
||||
kill -0 $p4d_pid 2>/dev/null || break
|
||||
echo waiting for p4d to start
|
||||
sleep 1
|
||||
i=$(( $i - 1 ))
|
||||
@ -163,29 +159,18 @@ p4_add_job () {
|
||||
}
|
||||
|
||||
retry_until_success () {
|
||||
timeout=$(($(time_in_seconds) + $RETRY_TIMEOUT))
|
||||
until "$@" 2>/dev/null || test $(time_in_seconds) -gt $timeout
|
||||
nr_tries_left=$RETRY_TIMEOUT
|
||||
until "$@" 2>/dev/null || test $nr_tries_left -eq 0
|
||||
do
|
||||
sleep 1
|
||||
nr_tries_left=$(($nr_tries_left - 1))
|
||||
done
|
||||
}
|
||||
|
||||
retry_until_fail () {
|
||||
timeout=$(($(time_in_seconds) + $RETRY_TIMEOUT))
|
||||
until ! "$@" 2>/dev/null || test $(time_in_seconds) -gt $timeout
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
kill_p4d () {
|
||||
pid=$(cat "$pidfile")
|
||||
retry_until_fail kill $pid
|
||||
retry_until_fail kill -9 $pid
|
||||
# complain if it would not die
|
||||
test_must_fail kill $pid >/dev/null 2>&1 &&
|
||||
rm -rf "$db" "$cli" "$pidfile" &&
|
||||
retry_until_fail kill -9 $watchdog_pid
|
||||
stop_and_cleanup_p4d () {
|
||||
kill -9 $p4d_pid $watchdog_pid
|
||||
wait $p4d_pid
|
||||
rm -rf "$db" "$cli" "$pidfile"
|
||||
}
|
||||
|
||||
cleanup_git () {
|
||||
|
@ -76,11 +76,6 @@ maybe_start_httpd () {
|
||||
LIB_HTTPD_SVN="$loc"
|
||||
start_httpd
|
||||
;;
|
||||
*)
|
||||
stop_httpd () {
|
||||
: noop
|
||||
}
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
#
|
||||
# test_expect_success ...
|
||||
#
|
||||
# stop_httpd
|
||||
# test_done
|
||||
#
|
||||
# Can be configured using the following variables.
|
||||
@ -176,7 +175,7 @@ prepare_httpd() {
|
||||
start_httpd() {
|
||||
prepare_httpd >&3 2>&4
|
||||
|
||||
trap 'code=$?; stop_httpd; (exit $code); die' EXIT
|
||||
test_atexit stop_httpd
|
||||
|
||||
"$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
|
||||
-f "$TEST_PATH/apache.conf" $HTTPD_PARA \
|
||||
@ -184,15 +183,12 @@ start_httpd() {
|
||||
>&3 2>&4
|
||||
if test $? -ne 0
|
||||
then
|
||||
trap 'die' EXIT
|
||||
cat "$HTTPD_ROOT_PATH"/error.log >&4 2>/dev/null
|
||||
test_skip_or_die $GIT_TEST_HTTPD "web server setup failed"
|
||||
fi
|
||||
}
|
||||
|
||||
stop_httpd() {
|
||||
trap 'die' EXIT
|
||||
|
||||
"$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
|
||||
-f "$TEST_PATH/apache.conf" $HTTPD_PARA -k stop
|
||||
}
|
||||
|
@ -825,6 +825,24 @@ test_expect_success 'tests clean up even on failures' "
|
||||
EOF
|
||||
"
|
||||
|
||||
test_expect_success 'test_atexit is run' "
|
||||
test_must_fail run_sub_test_lib_test \
|
||||
atexit-cleanup 'Run atexit commands' -i <<-\\EOF &&
|
||||
test_expect_success 'tests clean up even after a failure' '
|
||||
> ../../clean-atexit &&
|
||||
test_atexit rm ../../clean-atexit &&
|
||||
> ../../also-clean-atexit &&
|
||||
test_atexit rm ../../also-clean-atexit &&
|
||||
> ../../dont-clean-atexit &&
|
||||
(exit 1)
|
||||
'
|
||||
test_done
|
||||
EOF
|
||||
test_path_is_file dont-clean-atexit &&
|
||||
test_path_is_missing clean-atexit &&
|
||||
test_path_is_missing also-clean-atexit
|
||||
"
|
||||
|
||||
test_expect_success 'test_oid setup' '
|
||||
test_oid_init
|
||||
'
|
||||
|
@ -10,7 +10,7 @@ test -z "$NO_UNIX_SOCKETS" || {
|
||||
}
|
||||
|
||||
# don't leave a stale daemon running
|
||||
trap 'code=$?; git credential-cache exit; (exit $code); die' EXIT
|
||||
test_atexit 'git credential-cache exit'
|
||||
|
||||
# test that the daemon works with no special setup
|
||||
helper_test cache
|
||||
@ -108,9 +108,4 @@ test_expect_success SYMLINKS 'use user socket if user directory is a symlink to
|
||||
|
||||
helper_test_timeout cache --timeout=1
|
||||
|
||||
# we can't rely on our "trap" above working after test_done,
|
||||
# as test_done will delete the trash directory containing
|
||||
# our socket, leaving us with no way to access the daemon.
|
||||
git credential-cache exit
|
||||
|
||||
test_done
|
||||
|
@ -518,6 +518,4 @@ test_expect_success 'fetching of missing objects from an HTTP server' '
|
||||
git verify-pack --verbose "$IDX" | grep "$HASH"
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -920,7 +920,4 @@ test_expect_success 'fetch with --filter=blob:limit=0 and HTTP' '
|
||||
fetch_filter_blob_limit_zero "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server"
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
|
||||
test_done
|
||||
|
@ -978,6 +978,4 @@ test_expect_success '--negotiation-tip limits "have" lines sent with HTTP protoc
|
||||
check_negotiation_tip
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -255,6 +255,4 @@ test_expect_success 'shallow fetches check connectivity before writing shallow f
|
||||
git -C client fsck
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -149,5 +149,4 @@ test_expect_success 'fetching deepen' '
|
||||
)
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
test_done
|
||||
|
@ -176,6 +176,4 @@ test_expect_failure 'push to password-protected repository (no user in URL)' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -383,5 +383,4 @@ test_expect_success 'colorize errors/hints' '
|
||||
test_i18ngrep ! "^hint: " decoded
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
test_done
|
||||
|
@ -90,5 +90,4 @@ EOF
|
||||
)
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
test_done
|
||||
|
@ -278,6 +278,4 @@ test_expect_success 'push options keep quoted characters intact (http)' '
|
||||
test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git/hooks/pre-receive.push_options
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -424,5 +424,4 @@ test_expect_success 'fetching via http alternates works' '
|
||||
git -c http.followredirects=true clone "$HTTPD_URL/dumb/alt-child.git"
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
test_done
|
||||
|
@ -469,5 +469,4 @@ test_expect_success 'server-side error detected' '
|
||||
grep "server-side error" actual
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
test_done
|
||||
|
@ -132,5 +132,4 @@ test_expect_success 'server request log matches test results' '
|
||||
check_access_log exp
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
test_done
|
||||
|
@ -198,5 +198,4 @@ test_expect_success FAKENC 'hostname interpolation works after LF-stripping' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
stop_git_daemon
|
||||
test_done
|
||||
|
@ -23,6 +23,4 @@ test_expect_success 'failure in git-upload-pack is shown' '
|
||||
grep "< HTTP/1.1 500 Intentional Breakage" curl_log
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -733,6 +733,4 @@ test_expect_success 'partial clone using HTTP' '
|
||||
partial_clone "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server"
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -331,6 +331,4 @@ test_expect_success 'when partial cloning, tolerate server not sending target of
|
||||
! test -e "$HTTPD_ROOT_PATH/one-time-sed"
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -292,6 +292,4 @@ test_expect_success 'push with http:// using protocol v1' '
|
||||
grep "git< version 1" log
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -687,6 +687,4 @@ test_expect_success 'when server does not send "ready", expect FLUSH' '
|
||||
test_i18ngrep "expected no other sections to be sent after no .ready." err
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -257,8 +257,6 @@ test_expect_success 'server loses a ref - ref in want' '
|
||||
test_i18ngrep "fatal: remote error: unknown ref refs/heads/raster" err
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
REPO="$(pwd)/repo"
|
||||
LOCAL_PRISTINE="$(pwd)/local_pristine"
|
||||
|
||||
|
@ -34,5 +34,4 @@ test_expect_success 'http can be limited to from-user' '
|
||||
clone "$HTTPD_URL/smart-redir-perm/repo.git" redir.git
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
test_done
|
||||
|
@ -120,6 +120,4 @@ test_expect_success !MINGW,!UTF8_NFD_TO_NFC 'svn.pathnameencoding=cp932 rename o
|
||||
git svn dcommit
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -87,6 +87,4 @@ test_expect_success 'test dcommit to trailing_dotlock branch' '
|
||||
)
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -74,6 +74,4 @@ test_expect_success 'test clone -s with unescaped space' '
|
||||
)
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -26,6 +26,4 @@ test_expect_success 'clone trunk with "-r HEAD"' '
|
||||
( cd g && git rev-parse --symbolic --verify HEAD )
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
|
||||
test_done
|
||||
|
@ -326,8 +326,4 @@ test_expect_success 'submit from worktree' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -151,7 +151,7 @@ test_expect_success 'import depot, branch detection, branchList branch definitio
|
||||
'
|
||||
|
||||
test_expect_success 'restart p4d' '
|
||||
kill_p4d &&
|
||||
stop_and_cleanup_p4d &&
|
||||
start_p4d
|
||||
'
|
||||
|
||||
@ -505,7 +505,7 @@ test_expect_success 'use-client-spec detect-branches skips files in branches' '
|
||||
'
|
||||
|
||||
test_expect_success 'restart p4d' '
|
||||
kill_p4d &&
|
||||
stop_and_cleanup_p4d &&
|
||||
start_p4d
|
||||
'
|
||||
|
||||
@ -610,8 +610,4 @@ test_expect_success 'Update a file in git side and submit to P4 using client vie
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -333,8 +333,4 @@ test_expect_success SYMLINKS 'empty symlink target' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -105,8 +105,4 @@ test_expect_success 'branch with shell char' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -108,8 +108,4 @@ test_expect_failure 'two labels on the same changelist' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -98,8 +98,4 @@ test_expect_success 'no config, edited' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -300,9 +300,4 @@ test_expect_success 'use --git-dir option and GIT_DIR' '
|
||||
test_path_is_file "$git"/cli_file2.t
|
||||
'
|
||||
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -593,8 +593,4 @@ test_expect_success 'update a shelve involving moved and copied files' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -83,8 +83,4 @@ test_expect_success SYMLINKS 'p4 client root symlink should stay symbolic' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -836,8 +836,4 @@ test_expect_success 'quotes on both sides' '
|
||||
git_verify "cdir 1/file11" "cdir 1/file12"
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -360,8 +360,4 @@ test_expect_failure 'Add keywords in git which do not match the default p4 value
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -191,7 +191,7 @@ test_expect_success 'tag that cannot be exported' '
|
||||
(
|
||||
cd "$cli" &&
|
||||
p4 sync ... &&
|
||||
!(p4 labels | grep GIT_TAG_ON_A_BRANCH)
|
||||
! p4 labels | grep GIT_TAG_ON_A_BRANCH
|
||||
)
|
||||
'
|
||||
|
||||
@ -259,9 +259,4 @@ test_expect_success 'importing labels with missing revisions' '
|
||||
)
|
||||
'
|
||||
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -211,8 +211,4 @@ test_expect_success 'wildcard files requiring keyword scrub' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -138,8 +138,4 @@ test_expect_success 'not preserving user with mixed authorship' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -242,8 +242,4 @@ test_expect_success P4D_HAVE_CONFIGURABLE_RUN_MOVE_ALLOW \
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -422,8 +422,4 @@ test_expect_success 'cleanup chmod after submit cancel' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -138,8 +138,4 @@ test_expect_failure 'move with lock taken' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -64,8 +64,4 @@ test_expect_success 'clone, then sync with exclude' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -146,8 +146,4 @@ test_expect_success 'Clone repo with self-sizing block size' '
|
||||
test_line_count \> 10 log
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -53,8 +53,4 @@ test_expect_failure 'Clone UC repo with lc name' '
|
||||
test_must_fail git p4 clone //depot/uc/...
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -31,8 +31,4 @@ test_expect_success 'EDITOR with options' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -193,8 +193,4 @@ test_expect_success 'Add a new file and clone path with new file (ignorecase)' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -67,8 +67,4 @@ test_expect_success 'Delete iso8859-1 encoded paths and clone' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -185,8 +185,4 @@ test_expect_success 'Run git p4 submit in repo configured with large file system
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -287,8 +287,4 @@ test_expect_success 'Add big files to repo and store files in LFS based on compr
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -43,8 +43,4 @@ test_expect_failure 'clone depot with invalid UTF-16 file in non-verbose mode' '
|
||||
git p4 clone --dest="$git" //depot
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -127,8 +127,4 @@ test_expect_success 'Clone repo subdir with all history' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -59,8 +59,4 @@ test_expect_success SYMLINKS 'change symbolic link to file' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -54,8 +54,4 @@ test_expect_success 'Clone repo root path with all history' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -92,8 +92,4 @@ test_expect_success 'check log message of changelist with more jobs' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -36,8 +36,4 @@ test_expect_success 'symlinked directory' '
|
||||
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -96,8 +96,4 @@ test_expect_success 'submit description with extra info lines from verbose p4 ch
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -174,8 +174,5 @@ test_expect_success 'unshelve specifying the origin' '
|
||||
test_path_is_file file_to_shelve
|
||||
)
|
||||
'
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -45,9 +45,4 @@ test_expect_success 'ticket logged out' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
|
||||
test_done
|
||||
|
@ -943,6 +943,34 @@ test_when_finished () {
|
||||
} && (exit \"\$eval_ret\"); eval_ret=\$?; $test_cleanup"
|
||||
}
|
||||
|
||||
# This function can be used to schedule some commands to be run
|
||||
# unconditionally at the end of the test script, e.g. to stop a daemon:
|
||||
#
|
||||
# test_expect_success 'test git daemon' '
|
||||
# git daemon &
|
||||
# daemon_pid=$! &&
|
||||
# test_atexit 'kill $daemon_pid' &&
|
||||
# hello world
|
||||
# '
|
||||
#
|
||||
# The commands will be executed before the trash directory is removed,
|
||||
# i.e. the atexit commands will still be able to access any pidfiles or
|
||||
# socket files.
|
||||
#
|
||||
# Note that these commands will be run even when a test script run
|
||||
# with '--immediate' fails. Be careful with your atexit commands to
|
||||
# minimize any changes to the failed state.
|
||||
|
||||
test_atexit () {
|
||||
# We cannot detect when we are in a subshell in general, but by
|
||||
# doing so on Bash is better than nothing (the test will
|
||||
# silently pass on other shells).
|
||||
test "${BASH_SUBSHELL-0}" = 0 ||
|
||||
error "bug in test script: test_atexit does nothing in a subshell"
|
||||
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.
|
||||
# Usage: test_create_repo <directory>
|
||||
test_create_repo () {
|
||||
|
@ -634,6 +634,10 @@ test_external_has_tap=0
|
||||
|
||||
die () {
|
||||
code=$?
|
||||
# This is responsible for running the atexit commands even when a
|
||||
# test script run with '--immediate' fails, or when the user hits
|
||||
# ctrl-C, i.e. when 'test_done' is not invoked at all.
|
||||
test_atexit_handler || code=$?
|
||||
if test -n "$GIT_EXIT_OK"
|
||||
then
|
||||
exit $code
|
||||
@ -645,7 +649,10 @@ die () {
|
||||
|
||||
GIT_EXIT_OK=
|
||||
trap 'die' EXIT
|
||||
trap 'exit $?' INT TERM HUP
|
||||
# Disable '-x' tracing, because with some shells, notably dash, it
|
||||
# prevents running the cleanup commands when a test script run with
|
||||
# '--verbose-log -x' is interrupted.
|
||||
trap '{ code=$?; set +x; } 2>/dev/null; exit $code' INT TERM HUP
|
||||
|
||||
# The user-facing functions are loaded from a separate file so that
|
||||
# test_perf subshells can have them too
|
||||
@ -1056,9 +1063,28 @@ write_junit_xml_testcase () {
|
||||
junit_have_testcase=t
|
||||
}
|
||||
|
||||
test_atexit_cleanup=:
|
||||
test_atexit_handler () {
|
||||
# In a succeeding test script 'test_atexit_handler' is invoked
|
||||
# twice: first from 'test_done', then from 'die' in the trap on
|
||||
# EXIT.
|
||||
# This condition and resetting 'test_atexit_cleanup' below makes
|
||||
# sure that the registered cleanup commands are run only once.
|
||||
test : != "$test_atexit_cleanup" || return 0
|
||||
|
||||
setup_malloc_check
|
||||
test_eval_ "$test_atexit_cleanup"
|
||||
test_atexit_cleanup=:
|
||||
teardown_malloc_check
|
||||
}
|
||||
|
||||
test_done () {
|
||||
GIT_EXIT_OK=t
|
||||
|
||||
# Run the atexit commands _before_ the trash directory is
|
||||
# removed, so the commands can access pidfiles and socket files.
|
||||
test_atexit_handler
|
||||
|
||||
if test -n "$write_junit_xml" && test -n "$junit_xml_path"
|
||||
then
|
||||
test -n "$junit_have_testcase" || {
|
||||
|
Loading…
Reference in New Issue
Block a user