git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 8/8] t/README: Document the dangers of printing "ok" / "not ok"

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 1, 2010, 17:16 UTC
Message-ID
<7vhbkj2kcr.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1277997004-29504-9-git-send-email-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
Show 13 quoted lines
> index 42a4c25..29f795e 100644
> --- a/t/README
> +++ b/t/README
> @@ -50,6 +50,12 @@ prove and other harnesses come with a lot of useful options. The
>      # Repeat until no more failures
>      $ prove -j 15 --state=failed,save ./t[0-9]*.sh
>  
> +The TAP support is completely incidental. A TAP harness is just a
> +program that interprets the "ok"/"not ok" (and some other strings) in
> +a special way. The only limitation this imposes is that you shouldn't
> +echo "ok" or "not ok" by yourself at the beginning of a line, that'll
> +confuse the TAP harness.
> +

I think the above is not suitable for the target audience of the section ("Running Tests"); they are not _writing_ tests.

This information (or an enhanced version of it) should come between "Source 'test-lib.sh'" that talks about what the harness gives, and "Skipping tests". Perhaps name that to "Test your stuff". An example...

    Test your stuff
    ---------------
    After sourcing test-lib.sh, you test the parts of the system using the
    test harness.  Your tests will be done in the <script> part of
    test_expect_success helper function, and the exit status of the last
    command in that <script> signals the success/failure of a test.
    You are not supposed to "exit" from the <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).
    Inside <script> part, the standard output and standard error streams
    are discarded, and the test harness only reports "ok" or "not ok" to
    the end user running the tests.  Under --verbose, they are shown to
    help debugging the tests.
    The output from the test suite is designed to be TAP compliant (see
    http://..... to learn more about TAP), to allow programs by other
    people to parse our output.  This further places restriction on what
    your tests can say to the standard output and standard error.  The TAP
    readers 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.

I suspect the last paragraph needs a bit more work. For example, don't you have some restriction not to say things like "1..43"???

Previous: Ævar Arnfjörð Bjarmason
Message 14 of 14 in “Improvements for t/README”
  1. 0/8 Improvements for t/READMEÆvar Arnfjörð Bjarmason, Jul 1, 2010
  2. 1/8 t/README: Tests are all +x, ./test, not sh ./testÆvar Arnfjörð Bjarmason, Jul 1, 2010
  3. Jeff KingJul 1, 2010
  4. 2/8 t/README: The trash is in 't/trash directory.$name'Ævar Arnfjörð Bjarmason, Jul 1, 2010
  5. Jeff KingJul 1, 2010
  6. 3/8 t/README: Typo: paralell -> parallelÆvar Arnfjörð Bjarmason, Jul 1, 2010
  7. 4/8 t/README: Document the prereq functions, and 3-arg test_*Ævar Arnfjörð Bjarmason, Jul 1, 2010
  8. Junio C HamanoJul 1, 2010
  9. 5/8 t/README: Document test_external*Ævar Arnfjörð Bjarmason, Jul 1, 2010
  10. Junio C HamanoJul 1, 2010
  11. 6/8 t/README: Document test_expect_codeÆvar Arnfjörð Bjarmason, Jul 1, 2010
  12. 7/8 t/README: Add a section about skipping testsÆvar Arnfjörð Bjarmason, Jul 1, 2010
  13. 8/8 t/README: Document the dangers of printing "ok" / "not ok"Ævar Arnfjörð Bjarmason, Jul 1, 2010
  14. Junio C HamanoJul 1, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.