git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Zero King" <l2dy@macports.org>,
	"Git Mailing List" <git@vger.kernel.org>
Subject: Re: [PATCH 8/8] t0012: test "-h" with builtins
Date: Wed, 14 Jun 2017 06:03:52 -0400	[thread overview]
Message-ID: <20170614100352.ebkvlntpcpug3hax@sigill.intra.peff.net> (raw)
In-Reply-To: <20170613230803.GP133952@aiede.mtv.corp.google.com>

On Tue, Jun 13, 2017 at 04:08:03PM -0700, Jonathan Nieder wrote:

> > +test_expect_success 'generate builtin list' '
> > +	git --list-builtins >builtins
> > +'
> > +
> > +while read builtin
> > +do
> > +	test_expect_success "$builtin can handle -h" '
> > +		test_expect_code 129 git $builtin -h >output 2>&1 &&
> > +		test_i18ngrep usage output
> > +	'
> > +done <builtins
> 
> I love this.  A few thoughts:
> 
> - I think the "generate builtin list" test should be marked as setup
>   so people know it can't be skipped.  I'll send a followup to do that.
> 
> - By the same token, if "generate builtin list" fails then these
>   commands afterward would fail in an unpleasant way.  Fortunately
>   that's straightforward to fix, too.

Be my guest if you want, but I don't think either of those is actually
worth spending any time on. It's a nice convenience when tests are
independent, but ultimately if any single test fails, the results of all
tests after it must be suspect. There are too many hidden dependencies
to treat it any other way.

So I have no problem with skipping tests while debugging for a quicker
turnaround, with the knowledge that what you're seeing _might_ be
slightly invalidated. But I don't think it's worth dumping developer
time into trying to make each block independent. That's what individual
scripts are for.

(I also think it's particularly worthless for this script; the whole
thing runs in ~500ms on my machine. It takes longer to type
GIT_TEST_SKIP).

> - This checks both stdout and stderr to verify that the usage appears
>   somewhere.  I would have expected commands to be consistent ---
>   should they always send usage to stdout, since the user requested it,
>   or to stderr, since that's what we have done historically?
> 
>   So I understand why this test is agnostic about that but I suspect
>   it's pointing to some inconsistency that could be fixed independently.

The difference is between parse-option's usage_with_options() and
usage(). The former sends "-h" to stdout and errors to stderr, which I
think is sensible. The latter only knows about stderr.

I think it would be reasonable to have follow the parse-options strategy
consistently. It will definitely take some tweaking, though. There are
lots of commands that respect "-h" only by hitting some default
unhandled case. So you'll not only have to have a stdout analog for
usage(), but you'll have to teach each command when to use each.

> - Do we plan to translate the "usage:" prefix some day?  I could go
>   both ways --- on one hand, having a predictable error:/usage:/fatal:
>   prefix may make life easier for e.g. GUI authors trying to show
>   different kinds of error messages in different ways, but on the other
>   hand, always using English for the prefix may be unfriendly to non
>   English speakers.
> 
>   In the past I had assumed it would never be translated but now I'm
>   not so sure.  What do you think?

I don't have an opinion either way. I know we don't translate it now,
but it has been discussed. I figured it couldn't hurt to use i18ngrep to
future-proof it.

> - Should we have something like this for non-builtins, too?

That would be nice, though you'll probably need some cooperation from
the Makefile to get the list. I was specifically worried about catching
the particular setup_git_directory() interaction with builtins here, so
it seemed like a good stopping point.

But as a general rule, making sure that everything responds sensibly to
"-h" seems like a good thing.

-Peff

  reply	other threads:[~2017-06-14 10:03 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-29 11:45 [Bug] setup_git_env called without repository Zero King
2017-05-29 13:01 ` Ævar Arnfjörð Bjarmason
2017-05-29 15:32   ` Jeff King
2017-05-30  5:09     ` [PATCH 0/8] consistent "-h" handling in builtins Jeff King
2017-05-30  5:11       ` [PATCH 1/8] am: handle "-h" argument earlier Jeff King
2017-05-30  5:43         ` Junio C Hamano
2017-05-30  5:12       ` [PATCH 2/8] credential: handle invalid arguments earlier Jeff King
2017-05-30  5:13       ` [PATCH 3/8] upload-archive: handle "-h" option early Jeff King
2017-05-30  5:15       ` [PATCH 4/8] remote-{ext,fd}: print usage message on invalid arguments Jeff King
2017-05-30  5:16       ` [PATCH 5/8] submodule--helper: show usage for "-h" Jeff King
2017-05-30  5:17       ` [PATCH 6/8] version: convert to parse-options Jeff King
2017-05-30 20:45         ` [PATCH 6.5?/8] version: move --build-options to a test helper Ævar Arnfjörð Bjarmason
2017-05-30 21:05           ` Jeff King
2017-05-31 15:27             ` Johannes Schindelin
2017-05-31 15:31               ` Jeff King
2017-05-31 15:46                 ` Johannes Schindelin
2017-05-31 17:51                   ` Ævar Arnfjörð Bjarmason
2017-05-31 21:06                     ` Jeff King
2017-05-30  5:18       ` [PATCH 7/8] git: add hidden --list-builtins option Jeff King
2017-05-30  5:19       ` [PATCH 8/8] t0012: test "-h" with builtins Jeff King
2017-05-30  6:03         ` Junio C Hamano
2017-05-30  6:05           ` Jeff King
2017-05-30  6:08             ` Junio C Hamano
2017-05-30  6:15               ` Jeff King
2017-05-30 13:23                 ` Junio C Hamano
2017-05-30 15:27                   ` Jeff King
2017-05-30 15:44                     ` Jeff King
2017-05-30 22:39                       ` Junio C Hamano
2017-06-01  4:17                     ` Junio C Hamano
2017-06-01  5:35                       ` Jeff King
2017-06-01  5:42                       ` Junio C Hamano
2017-06-01  5:54                         ` Junio C Hamano
2017-06-01  6:25                           ` Jeff King
2017-06-01  7:51                             ` Junio C Hamano
2017-06-01  6:10                         ` Jeff King
2017-06-13 23:08         ` Jonathan Nieder
2017-06-14 10:03           ` Jeff King [this message]
2017-05-30  5:52       ` [PATCH 0/8] consistent "-h" handling in builtins Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170614100352.ebkvlntpcpug3hax@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=l2dy@macports.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).