From: Jeff King <peff@peff.net>
To: Lucas Werkmeister <mail@lucaswerkmeister.de>
Cc: git@vger.kernel.org, Michael Haggerty <mhagger@alum.mit.edu>
Subject: Re: [PATCH 2/6] t/lib-git-daemon: record daemon log
Date: Thu, 25 Jan 2018 14:08:24 -0500 [thread overview]
Message-ID: <20180125190824.GA26309@sigill.intra.peff.net> (raw)
In-Reply-To: <38b41541-5758-d013-3d64-314eec7e31ed@lucaswerkmeister.de>
On Thu, Jan 25, 2018 at 12:56:47PM +0100, Lucas Werkmeister wrote:
> > Let's dump the log into a file, as well, so that future
> > tests can check the log. There are two subtleties worth
> > calling out here:
> >
> > - we replace "cat" with a subshell loop around "read" to
> > ensure that there's no buffering (so that tests can be
> > sure that after a request has been served, the matching
> > log entries will have made it to the file)
>
> POSIX specifies the -u option for that behavior, can’t you use that?
> (GNU coreutils’ cat ignores it, since writing without delay is
> apparently its default behavior already.)
Actually, this glosses over one other detail, which is that we'd also
need to replace "cat" with "tee" to keep output going to descriptor 4.
That's not strictly necessary (it's just for debugging output), so we
could drop that. But the shell loop seemed easy enough.
> > {
> > read line <&7
> > + echo "$line"
> > echo >&4 "$line"
> > - cat <&7 >&4 &
> > - } 7<git_daemon_output &&
> > + (
> > + while read line <&7
> > + do
> > + echo "$line"
> > + echo >&4 "$line"
> > + done
> > + ) &
> > + } 7<git_daemon_output >>"$TRASH_DIRECTORY/daemon.log" &&
> >
> > # Check expected output
> > if test x"$(expr "$line" : "\[[0-9]*\] \(.*\)")" != x"Ready to rumble"
> >
>
> read without -r clobbers backslashes, and echo may interpret escape
> sequences. To faithfully reproduce the output, it would be better to use
> read -r and printf '%s\n' "$line", I think. (However, it looks like the
> existing code already uses read+echo, so I guess you could also keep
> that pattern in this change and then fix it in a later one.)
Yeah. I doubt it matters much, since this is just inside our tests, and
we control the input. But it doesn't hurt to do it in the more robust
way. I'll re-roll this patch.
-Peff
next prev parent reply other threads:[~2018-01-25 19:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-25 0:54 [PATCH 0/6] off-by-one errors in git-daemon Jeff King
2018-01-25 0:55 ` [PATCH 1/6] t5570: use ls-remote instead of clone for interp tests Jeff King
2018-01-25 0:55 ` [PATCH 2/6] t/lib-git-daemon: record daemon log Jeff King
2018-01-25 11:56 ` Lucas Werkmeister
2018-01-25 19:08 ` Jeff King [this message]
2018-01-25 0:56 ` [PATCH 3/6] daemon: fix off-by-one in logging extended attributes Jeff King
2018-01-25 0:56 ` [PATCH 4/6] daemon: handle NULs in extended attribute string Jeff King
2018-01-25 0:58 ` [PATCH 5/6] t/lib-git-daemon: add network-protocol helpers Jeff King
2018-01-25 0:58 ` [PATCH 6/6] daemon: fix length computation in newline stripping Jeff King
2018-01-25 21:38 ` Eric Sunshine
2018-01-26 18:52 ` Jeff King
2018-01-25 18:46 ` [PATCH 0/6] off-by-one errors in git-daemon Junio C Hamano
2018-01-25 19:16 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180125190824.GA26309@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=mail@lucaswerkmeister.de \
--cc=mhagger@alum.mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).