Re: [PATCH 10/11] t5570: make test "set -e" clean
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Mar 25, 2026, 07:16 UTC
- Message-ID
- <acOLt7GuLTpg_QYM@pks.im>
- In-Reply-To
- <20260325062114.2067946-11-gitster@pobox.com>
On Tue, Mar 24, 2026 at 11:21:13PM -0700, Junio C Hamano wrote:
Show 21 quoted lines
> diff --git a/t/lib-git-daemon.sh b/t/lib-git-daemon.sh
> index e62569222b..6850f08c1d 100644
> --- a/t/lib-git-daemon.sh
> +++ b/t/lib-git-daemon.sh
> @@ -86,13 +86,13 @@ stop_git_daemon() {
> # kill git-daemon child of git
> say >&3 "Stopping git daemon ..."
> kill "$GIT_DAEMON_PID"
> - wait "$GIT_DAEMON_PID" >&3 2>&4
> - ret=$?
> + ret=0
> + wait "$GIT_DAEMON_PID" >&3 2>&4 || ret=$?
> if ! test_match_signal 15 $ret
> then
> error "git daemon exited with status: $ret"
> fi
> - kill "$(cat "$GIT_DAEMON_PIDFILE")" 2>/dev/null
> + kill "$(cat "$GIT_DAEMON_PIDFILE")" 2>/dev/null || :
> GIT_DAEMON_PID=
> rm -f git_daemon_output "$GIT_DAEMON_PIDFILE"
> }This test actually made me pause a bit. In theory, you can use the function to verify that git-daemon(1) exits successfully because we do bubble up its exit code. So instead of silencing the error code, I simply added `|| :` to all callsites that don't care about it at all.
But in practice, that turned out to be every callsite, so that exercise may not be worth it.
Patrick