All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 2/7] t3701: avoid depending on the TTY prerequisite
Date: Tue, 17 Dec 2019 00:53:38 -0500	[thread overview]
Message-ID: <20191217055338.GC2762303@coredump.intra.peff.net> (raw)
In-Reply-To: <20191216121859.GP6527@szeder.dev>

On Mon, Dec 16, 2019 at 01:18:59PM +0100, SZEDER Gábor wrote:

> > And we found exactly such a trick earlier already: when we added a test
> > case to verify that the main loop of `git add -i` is colored
> > appropriately. Let's use that trick instead of the TTY prerequisite.
> 
> It's much more interesting _what_ that trick is than when it was
> found.  Is it setting TERM=vt100, or is it setting both TERM=vt100 and
> GIT_PAGER_IN_USE=true?  I'm inclined to think the latter, but I'm not
> sure I interpreted the comment below right.

It's both. GIT_PAGER_IN_USE tells Git not to bother checking isatty(),
and then TERM=vt100 is necessary to override test-lib's TERM=dumb
specifically for the color code.

> In any case, there are a couple of tests in other test scripts that
> test color relying on the TTY prereq.  So maybe it would be worth to
> make this into a "global" helper function by adding it to
> 'test-lib-functions.sh', so we can drop a few more prereqs.
> 
> OTOH, some of those other tests have descriptions like:
> 
>   t3203-branch-output.sh:test_expect_success TTY '%(color) present with tty'
>   t7004-tag.sh:test_expect_success TTY '%(color) present with tty'
> 
> i.e. their description is specific about checking the behaviour with a
> tty, so I'm not entirely sure.

Hmm. I have mixed feelings on this. I do like the simplicity of avoiding
test_terminal (which is unportable and has also contributed to some
confusing behavior in the past[1]). But it also takes us further away from
a real-world setup.

That might be OK for the tests you quoted above, if we're OK with
assuming the equivalence of isatty() and GIT_PAGER_IN_USE for the color
code (though we'd probably want to make sure that's tested _somewhere_).

But it obviously would not work for test-terminal callers that are
checking the pager behavior. And I suspect it may create other oddities;
e.g., a script which calls a sub-command that looks at GIT_PAGER_IN_USE,
even though the sub-command's output is going to a pipe. Though one
could argue that's a bug[2] (that could be triggered by _actually_
sending the script's output to pager).

If we're going to get rid of test-terminal.pl (and I would be happy
enough to see it go), I'd rather we mock things up at the isatty()
level, something like what I showed in:

  https://lore.kernel.org/git/20190524062724.GC25694@sigill.intra.peff.net/

That gives us a more realistic setup, and we could reliably use it
everywhere that test-terminal is used.

-Peff

[1] I had issues a while back with test-terminal's stdin feature being
    racy:

      https://lore.kernel.org/git/20190520125016.GA13474@sigill.intra.peff.net/

[2] Long ago I had a patch to make PAGER_IN_USE more careful by making
    sure that our pipe is the same as the pager pipe. It did (and does)
    work, but it would need some portability adjustments. I never
    bothered to follow up because it really does seem to be a pretty
    unlikely setup in practice. But if you're curious:

      https://lore.kernel.org/git/20150810052353.GB15441@sigill.intra.peff.net/

-Peff

  reply	other threads:[~2019-12-17  5:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-06 13:08 [PATCH 0/7] add -i: close some regression test gaps Johannes Schindelin via GitGitGadget
2019-12-06 13:08 ` [PATCH 1/7] t3701: add a test for advanced split-hunk editing Johannes Schindelin via GitGitGadget
2019-12-06 13:08 ` [PATCH 2/7] t3701: avoid depending on the TTY prerequisite Johannes Schindelin via GitGitGadget
2019-12-16 12:18   ` SZEDER Gábor
2019-12-17  5:53     ` Jeff King [this message]
2019-12-06 13:08 ` [PATCH 3/7] t3701: add a test for the different `add -p` prompts Johannes Schindelin via GitGitGadget
2019-12-06 13:08 ` [PATCH 4/7] t3701: verify the shown messages when nothing can be added Johannes Schindelin via GitGitGadget
2019-12-06 13:08 ` [PATCH 5/7] t3701: verify that the diff.algorithm config setting is handled Johannes Schindelin via GitGitGadget
2019-12-06 13:08 ` [PATCH 6/7] git add -p: use non-zero exit code when the diff generation failed Johannes Schindelin via GitGitGadget
2019-12-06 20:48   ` Junio C Hamano
2019-12-06 13:08 ` [PATCH 7/7] apply --allow-overlap: fix a corner case Johannes Schindelin via GitGitGadget
2019-12-06 13:45   ` Junio C Hamano
2019-12-06 14:11     ` Johannes Schindelin
2019-12-06 16:40       ` Junio C Hamano
2019-12-06 17:56         ` Johannes Schindelin

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=20191217055338.GC2762303@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=szeder.dev@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.