git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: [PATCH v4 7/7] t/README: Document the do's and don'ts of tests
Date: Tue, 6 Jul 2010 12:50:08 +0000	[thread overview]
Message-ID: <AANLkTimvyxNq3GAnwNZJEm6U5Jn7TlaedLZk12O9g8xe@mail.gmail.com> (raw)
In-Reply-To: <7vaaq58hhb.fsf@alter.siamese.dyndns.org>

On Tue, Jul 6, 2010 at 02:35, Junio C Hamano <gitster@pobox.com> wrote:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> +Do's, don'ts & things to keep in mind
>> +-------------------------------------
>> +
>> +Here's a few examples of things you probably should and shouldn't do
>> +when writing tests.
>
> "Here are" perhaps?
>
>> +Do:
>> +
>> + - Put as much code as possible inside test_expect_success and other
>> +   assertions.
>> +
>> +   Even code that isn't a test per se, but merely some setup code
>> +   should be inside a test assertion if at all possible. Test scripts
>> +   should only have trivial code outside of their assertions.
>
> Let's make it even stronger; "should only have trivial" -> "shouldn't have
> any ... unless there is a good reason."
>
>> +Don't:
>> +
>> + - exit() within a <script> part.
>> +
>> +   The harness will catch this as a programming error of the test.
>> +   Use test_done instead if you need to stop the tests early (see
>> +   "Skipping tests" below).
>> +
>> + - Break the TAP output
>> +
>> +   The raw output from your test might be interpreted by a TAP
>> +   harness. You usually don't have to worry about that. TAP harnesses
>
> I'd recommend dropping "You usually...about that"  You do care, but the
> limitation may be not so severe.
>
>> +   will ignore everything they don't know about, but don't step on
>> +   their toes in these areas:
>> +
>> +   - Don't print lines like "$x..$y" where $x and $y are integers.
>> +
>> +   - Don't print lines that begin with "ok" or "not ok".
>> +
>> +   A TAP harness expect a line that begins with either "ok" and "not
>> +   ok" to signal a test passed or failed (and our harness already
>> +   produces such lines), so your script shouldn't emit such lines to
>> +   their output.
>> +
>> +   You can glean some further possible issues from the TAP grammar
>> +   (see http://search.cpan.org/perldoc?TAP::Parser::Grammar#TAP_Grammar)
>> +   but the best indication is to just run the tests with prove(1),
>> +   it'll complain if anything is amiss.
>> +
>> +Keep in mind:
>> +
>> + - That what you print to stderr and stdout is usually ignored
>> +
>> +   Inside <script> part, the standard output and standard error
>
> Splitting the above into two sentences (or a header and a body) makes it
> unclear that your "usually" comes from the earlier "Do Put as much code
> inside test_expect_success...".  I think you can simply drop "That what
> you print ... ignored".
>
> Everything else in the series looked good.  Thanks.

All of these rewordings (the "t/README: proposed rewording..." commit
in pu) look good.

    Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>

      parent reply	other threads:[~2010-07-06 12:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-02 14:59 [PATCH v4 0/7] Improvements for t/README Ævar Arnfjörð Bjarmason
2010-07-02 14:59 ` [PATCH v4 1/7] t/README: The trash is in 't/trash directory.$name' Ævar Arnfjörð Bjarmason
2010-07-02 14:59 ` [PATCH v4 2/7] t/README: Typo: paralell -> parallel Ævar Arnfjörð Bjarmason
2010-07-02 14:59 ` [PATCH v4 3/7] t/README: Document the prereq functions, and 3-arg test_* Ævar Arnfjörð Bjarmason
2010-07-02 14:59 ` [PATCH v4 4/7] t/README: Document test_external* Ævar Arnfjörð Bjarmason
2010-07-02 14:59 ` [PATCH v4 5/7] t/README: Document test_expect_code Ævar Arnfjörð Bjarmason
2010-07-02 14:59 ` [PATCH v4 6/7] t/README: Add a section about skipping tests Ævar Arnfjörð Bjarmason
2010-07-02 14:59 ` [PATCH v4 7/7] t/README: Document the do's and don'ts of tests Ævar Arnfjörð Bjarmason
2010-07-06  2:35   ` Junio C Hamano
2010-07-06  8:35     ` Jakub Narebski
2010-07-06 13:02       ` Ævar Arnfjörð Bjarmason
2010-07-06 13:19         ` Jakub Narebski
2010-07-06 12:50     ` Ævar Arnfjörð Bjarmason [this message]

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=AANLkTimvyxNq3GAnwNZJEm6U5Jn7TlaedLZk12O9g8xe@mail.gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --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).