Re: [PATCH v3 1/2] t: add a test helper for getting hostname
On Tue, Mar 19, 2024 at 01:31:06PM -0700, Junio C Hamano wrote:
Show 22 quoted lines
> > diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
> > index 18fe1c25e6a0..613c766e2bb4 100755
> > --- a/t/t6500-gc.sh
> > +++ b/t/t6500-gc.sh
> > @@ -395,7 +395,6 @@ test_expect_success 'background auto gc respects lock for all operations' '
> >
> > # now fake a concurrent gc that holds the lock; we can use our
> > # shell pid so that it looks valid.
> > - hostname=$(hostname || echo unknown) &&
> > shell_pid=$$ &&
> > if test_have_prereq MINGW && test -f /proc/$shell_pid/winpid
> > then
> > @@ -404,7 +403,7 @@ test_expect_success 'background auto gc respects lock for all operations' '
> > # the Windows PID in this case.
> > shell_pid=$(cat /proc/$shell_pid/winpid)
> > fi &&
> > - printf "%d %s" "$shell_pid" "$hostname" >.git/gc.pid &&
> > + printf "%d %s" "$shell_pid" "$(test-tool xgethostname)" >.git/gc.pid &&
>
> We should replace the "hostname || echo unknown" in the original,
> instead of doing this change, as it loses the exit status from the
> "test-tool xgethostname" command.
I think you need to lose the exit status. Or alternatively do:
hostname=$(test-tool xgethostname || echo unknown)
See my other reply.
-Peff