git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Felipe Contreras <felipe.contreras@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH 6/5] t9001: check send-email behavior with implicit sender
Date: Wed, 28 Nov 2012 12:42:41 -0800	[thread overview]
Message-ID: <7vpq2xtq66.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20121128201713.GA9249@sigill.intra.peff.net> (Jeff King's message of "Wed, 28 Nov 2012 15:17:13 -0500")

Jeff King <peff@peff.net> writes:

> On Wed, Nov 28, 2012 at 03:06:26PM -0500, Jeff King wrote:
>
>> Here's a cleaned up version that makes it more obvious the commands are
>> the same (it also fixes a few minor whitespace problems on the
>> indentation, which you can see from the quoting above).
>
> I wondered how painful it would be to actually run the command and then
> conditionally check the results inside the test. I ended up with this:
> ...
> which does work, though it is less nice that the protections and nice
> syntax of "test_must_fail" must be abandoned (unless we want to do
> something horrible like 'test_must_fail sh -c "exit $exit_code"'.
> I could go either way.

A change along that line did cross my mind, and I agree that it does
clarify that we are testing the same command produces an expected
result, the expectation may be different depending on external
conditions, and we can figure out what the expected values are
before running the test.  I do not think we use such a pattern in
very many places, though.

The differences in "expected results" are generally not limited to
the final outcome in $? (e.g. your "else" side not just checks $?
indicates an error, but makes sure that we got an expected error
message), which means that the if statement at the end has to be
there in some form anyway, which in turn means that a new test
helper function to abstract this pattern out further would not
buy us very much (either it would be too complex and bug prone to
implement, or it would be too simplistic and limited).

I'd prefer to leave these as two separate tests for now like your
previous patch.  People interested in consolidating/simplifying can
first audit the existing tests to find other instances of this
pattern to see if it is worth doing, and then come up with an
abstraction to be shared among them.

Thanks.

  reply	other threads:[~2012-11-28 20:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-28 18:25 [PATCH 0/5] jk/send-email-sender-prompt loose ends Jeff King
2012-11-28 18:25 ` [PATCH 1/5] test-lib: allow negation of prerequisites Jeff King
2012-11-28 18:26 ` [PATCH 2/5] t7502: factor out autoident prerequisite Jeff King
2012-11-28 18:26 ` [PATCH 3/5] ident: make user_ident_explicitly_given static Jeff King
2012-11-28 18:26 ` [PATCH 4/5] ident: keep separate "explicit" flags for author and committer Jeff King
2012-11-28 18:26 ` [PATCH 5/5] t: add tests for "git var" Jeff King
2012-11-28 18:42 ` [PATCH 6/5] t9001: check send-email behavior with implicit sender Jeff King
2012-11-28 18:55   ` Junio C Hamano
2012-11-28 20:06     ` Jeff King
2012-11-28 20:17       ` Jeff King
2012-11-28 20:42         ` Junio C Hamano [this message]
2012-11-28 21:37 ` [PATCH 0/5] jk/send-email-sender-prompt loose ends Felipe Contreras

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=7vpq2xtq66.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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).