{"thread":{"id":"24264","subject":"[PATCH v4 0/7] Improvements for t/README","startedAt":"2010-07-02T14:59:42Z","lastAt":"2010-07-06T13:19:50Z","messageCount":13,"participants":["Ævar Arnfjörð Bjarmason","Junio C Hamano","Jakub Narebski"],"isPatch":true,"patchVersion":4,"patchTotal":7},"messages":[{"id":"144682","messageId":"1278082789-19872-1-git-send-email-avarab@gmail.com","threadId":"24264","inReplyTo":null,"subject":"[PATCH v4 0/7] Improvements for t/README","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-02T14:59:42Z","receivedAt":"2010-07-02T14:59:42Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Since last time:\n\n * Dropped the s[sh ./][./] patch\n * Typo fix: gleam -> glean\n\nHere's the diff since v3:\n    \n    diff --git a/t/README b/t/README\n    index 4d0526d..e481657 100644\n    --- a/t/README\n    +++ b/t/README\n    @@ -55 +55 @@ You can also run each test individually from command line, like this:\n    -    $ ./t3010-ls-files-killed-modified.sh\n    +    $ sh ./t3010-ls-files-killed-modified.sh\n    @@ -297 +297 @@ Don't:\n    -   You can gleam some further possible issues from the TAP grammar\n    +   You can glean some further possible issues from the TAP grammar\n\nÆvar Arnfjörð Bjarmason (7):\n  t/README: The trash is in 't/trash directory.$name'\n  t/README: Typo: paralell -> parallel\n  t/README: Document the prereq functions, and 3-arg test_*\n  t/README: Document test_external*\n  t/README: Document test_expect_code\n  t/README: Add a section about skipping tests\n  t/README: Document the do's and don'ts of tests\n\n t/README |  170 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---\n 1 files changed, 163 insertions(+), 7 deletions(-)\n"},{"id":"144683","messageId":"1278082789-19872-2-git-send-email-avarab@gmail.com","threadId":"24264","inReplyTo":"1278082789-19872-1-git-send-email-avarab@gmail.com","subject":"[PATCH v4 1/7] t/README: The trash is in 't/trash directory.$name'","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-02T14:59:43Z","receivedAt":"2010-07-02T14:59:43Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There's a unique trash directory for each test, not a single directory\nas the previous documentation suggested.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/README |    7 ++++---\n 1 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/t/README b/t/README\nindex aa4ed28..cad6fde 100644\n--- a/t/README\n+++ b/t/README\n@@ -221,9 +221,10 @@ This test harness library does the following things:\n  - If the script is invoked with command line argument --help\n    (or -h), it shows the test_description and exits.\n \n- - Creates an empty test directory with an empty .git/objects\n-   database and chdir(2) into it.  This directory is 't/trash directory'\n-   if you must know, but I do not think you care.\n+ - Creates an empty test directory with an empty .git/objects database\n+   and chdir(2) into it.  This directory is 't/trash\n+   directory.$test_name_without_dotsh', with t/ subject to change by\n+   the --root option documented above.\n \n  - Defines standard test helper functions for your scripts to\n    use.  These functions are designed to make all scripts behave\n-- \n1.7.1.251.g92a7\n"},{"id":"144685","messageId":"1278082789-19872-3-git-send-email-avarab@gmail.com","threadId":"24264","inReplyTo":"1278082789-19872-1-git-send-email-avarab@gmail.com","subject":"[PATCH v4 2/7] t/README: Typo: paralell -> parallel","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-02T14:59:44Z","receivedAt":"2010-07-02T14:59:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/README |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/README b/t/README\nindex cad6fde..a7312fa 100644\n--- a/t/README\n+++ b/t/README\n@@ -33,7 +33,7 @@ the tests.\n     ok 3 - plain bare\n \n Since the tests all output TAP (see http://testanything.org) they can\n-be run with any TAP harness. Here's an example of paralell testing\n+be run with any TAP harness. Here's an example of parallel testing\n powered by a recent version of prove(1):\n \n     $ prove --timer --jobs 15 ./t[0-9]*.sh\n-- \n1.7.1.251.g92a7\n"},{"id":"144684","messageId":"1278082789-19872-4-git-send-email-avarab@gmail.com","threadId":"24264","inReplyTo":"1278082789-19872-1-git-send-email-avarab@gmail.com","subject":"[PATCH v4 3/7] t/README: Document the prereq functions, and 3-arg test_*","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-02T14:59:45Z","receivedAt":"2010-07-02T14:59:45Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There was no documentation for the test_set_prereq and\ntest_have_prereq functions, or the three-arg form of\ntest_expect_success and test_expect_failure.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/README |   37 ++++++++++++++++++++++++++++++++++---\n 1 files changed, 34 insertions(+), 3 deletions(-)\n\ndiff --git a/t/README b/t/README\nindex a7312fa..c1fd092 100644\n--- a/t/README\n+++ b/t/README\n@@ -246,9 +246,9 @@ Test harness library\n There are a handful helper functions defined in the test harness\n library for your script to use.\n \n- - test_expect_success <message> <script>\n+ - test_expect_success [<prereq>] <message> <script>\n \n-   This takes two strings as parameter, and evaluates the\n+   Usually takes two strings as parameter, and evaluates the\n    <script>.  If it yields success, test is considered\n    successful.  <message> should state what it is testing.\n \n@@ -258,7 +258,14 @@ library for your script to use.\n \t    'git-write-tree should be able to write an empty tree.' \\\n \t    'tree=$(git-write-tree)'\n \n- - test_expect_failure <message> <script>\n+   If you supply three parameters the first will be taken to be a\n+   prerequisite, see the test_set_prereq and test_have_prereq\n+   documentation below:\n+\n+\ttest_expect_success TTY 'git --paginate rev-list uses a pager' \\\n+\t    ' ... '\n+\n+ - test_expect_failure [<prereq>] <message> <script>\n \n    This is NOT the opposite of test_expect_success, but is used\n    to mark a test that demonstrates a known breakage.  Unlike\n@@ -267,6 +274,9 @@ library for your script to use.\n    success and \"still broken\" on failure.  Failures from these\n    tests won't cause -i (immediate) to stop.\n \n+   Like test_expect_success this function can optionally use a three\n+   argument invocation with a prerequisite as the first argument.\n+\n  - test_debug <script>\n \n    This takes a single argument, <script>, and evaluates it only\n@@ -299,6 +309,27 @@ library for your script to use.\n    Merges the given rev using the given message.  Like test_commit,\n    creates a tag and calls test_tick before committing.\n \n+ - test_set_prereq SOME_PREREQ\n+\n+   Set a test prerequisite to be used later with test_have_prereq. The\n+   test-lib will set some prerequisites for you, e.g. PERL and PYTHON\n+   which are derived from ./GIT-BUILD-OPTIONS (grep test_set_prereq\n+   test-lib.sh for more). Others you can set yourself and use later\n+   with either test_have_prereq directly, or the three argument\n+   invocation of test_expect_success and test_expect_failure.\n+\n+ - test_have_prereq SOME PREREQ\n+\n+   Check if we have a prerequisite previously set with\n+   test_set_prereq. The most common use of this directly is to skip\n+   all the tests if we don't have some essential prerequisite:\n+\n+\tif ! test_have_prereq PERL\n+\tthen\n+\t    skip_all='skipping perl interface tests, perl not available'\n+\t    test_done\n+\tfi\n+\n Tips for Writing Tests\n ----------------------\n \n-- \n1.7.1.251.g92a7\n"},{"id":"144686","messageId":"1278082789-19872-5-git-send-email-avarab@gmail.com","threadId":"24264","inReplyTo":"1278082789-19872-1-git-send-email-avarab@gmail.com","subject":"[PATCH v4 4/7] t/README: Document test_external*","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-02T14:59:46Z","receivedAt":"2010-07-02T14:59:46Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There was do documentation for the test_external_without_stderr and\ntest_external functions.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/README |   27 +++++++++++++++++++++++++++\n 1 files changed, 27 insertions(+), 0 deletions(-)\n\ndiff --git a/t/README b/t/README\nindex c1fd092..b40403d 100644\n--- a/t/README\n+++ b/t/README\n@@ -330,6 +330,33 @@ library for your script to use.\n \t    test_done\n \tfi\n \n+ - test_external [<prereq>] <message> <external> <script>\n+\n+   Execute a <script> with an <external> interpreter (like perl). This\n+   was added for tests like t9700-perl-git.sh which do most of their\n+   work in an external test script.\n+\n+\ttest_external \\\n+\t    'GitwebCache::*FileCache*' \\\n+\t    \"$PERL_PATH\" \"$TEST_DIRECTORY\"/t9503/test_cache_interface.pl\n+\n+   If the test is outputting its own TAP you should set the\n+   test_external_has_tap variable somewhere before calling the first\n+   test_external* function. See t9700-perl-git.sh for an example.\n+\n+\t# The external test will outputs its own plan\n+\ttest_external_has_tap=1\n+\n+ - test_external_without_stderr [<prereq>] <message> <external> <script>\n+\n+   Like test_external but fail if there's any output on stderr,\n+   instead of checking the exit code.\n+\n+\ttest_external_without_stderr \\\n+\t    'Perl API' \\\n+\t    \"$PERL_PATH\" \"$TEST_DIRECTORY\"/t9700/test.pl\n+\n+\n Tips for Writing Tests\n ----------------------\n \n-- \n1.7.1.251.g92a7\n"},{"id":"144689","messageId":"1278082789-19872-6-git-send-email-avarab@gmail.com","threadId":"24264","inReplyTo":"1278082789-19872-1-git-send-email-avarab@gmail.com","subject":"[PATCH v4 5/7] t/README: Document test_expect_code","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-02T14:59:47Z","receivedAt":"2010-07-02T14:59:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"test_expect_code (which was introduced in d3bfdb75) never had any\ndocumentation.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/README |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/t/README b/t/README\nindex b40403d..04ad927 100644\n--- a/t/README\n+++ b/t/README\n@@ -277,6 +277,13 @@ library for your script to use.\n    Like test_expect_success this function can optionally use a three\n    argument invocation with a prerequisite as the first argument.\n \n+ - test_expect_code [<prereq>] <code> <message> <script>\n+\n+   Analogous to test_expect_success, but pass the test if it exits\n+   with a given exit <code>\n+\n+ test_expect_code 1 'Merge with d/f conflicts' 'git merge \"merge msg\" B master'\n+\n  - test_debug <script>\n \n    This takes a single argument, <script>, and evaluates it only\n-- \n1.7.1.251.g92a7\n"},{"id":"144687","messageId":"1278082789-19872-7-git-send-email-avarab@gmail.com","threadId":"24264","inReplyTo":"1278082789-19872-1-git-send-email-avarab@gmail.com","subject":"[PATCH v4 6/7] t/README: Add a section about skipping tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-02T14:59:48Z","receivedAt":"2010-07-02T14:59:48Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/README |   12 ++++++++++++\n 1 files changed, 12 insertions(+), 0 deletions(-)\n\ndiff --git a/t/README b/t/README\nindex 04ad927..4079635 100644\n--- a/t/README\n+++ b/t/README\n@@ -231,6 +231,18 @@ This test harness library does the following things:\n    consistently when command line arguments --verbose (or -v),\n    --debug (or -d), and --immediate (or -i) is given.\n \n+Skipping tests\n+--------------\n+\n+If you need to skip all the remaining tests you should set skip_all\n+and immediately call test_done. The string you give to skip_all will\n+be used as an explanation for why the test was skipped. for instance:\n+\n+\tif ! test_have_prereq PERL\n+\tthen\n+\t    skip_all='skipping perl interface tests, perl not available'\n+\t    test_done\n+\tfi\n \n End with test_done\n ------------------\n-- \n1.7.1.251.g92a7\n"},{"id":"144688","messageId":"1278082789-19872-8-git-send-email-avarab@gmail.com","threadId":"24264","inReplyTo":"1278082789-19872-1-git-send-email-avarab@gmail.com","subject":"[PATCH v4 7/7] t/README: Document the do's and don'ts of tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-02T14:59:49Z","receivedAt":"2010-07-02T14:59:49Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a \"Do's, don'ts & things to keep in mind\" subsection to the\n\"Writing Tests\" documentation. Much of this is based on Junio C\nHamano's \"Test your stuff\" section in\n<7vhbkj2kcr.fsf@alter.siamese.dyndns.org>.\n\nI turned it into a list of do's and don'ts to make it easier to skim\nit, and integrated my note that a TAP harness will get confused if you\nprint \"ok\" or \"not ok\" at the beginning of a line.\n\nThad had to be fixed in 335f87871fe5aa6b3fd55b2b4e80f16fe9681483 when\nTAP support was introduced.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/README |   78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 78 insertions(+), 0 deletions(-)\n\ndiff --git a/t/README b/t/README\nindex 4079635..e481657 100644\n--- a/t/README\n+++ b/t/README\n@@ -231,6 +231,84 @@ This test harness library does the following things:\n    consistently when command line arguments --verbose (or -v),\n    --debug (or -d), and --immediate (or -i) is given.\n \n+Do's, don'ts & things to keep in mind\n+-------------------------------------\n+\n+Here's a few examples of things you probably should and shouldn't do\n+when writing tests.\n+\n+Do:\n+\n+ - Put as much code as possible inside test_expect_success and other\n+   assertions.\n+\n+   Even code that isn't a test per se, but merely some setup code\n+   should be inside a test assertion if at all possible. Test scripts\n+   should only have trivial code outside of their assertions.\n+\n+ - Chain your test assertions\n+\n+   Write test code like this:\n+\n+\tgit merge foo &&\n+\tgit push bar &&\n+\ttest ...\n+\n+   Instead of:\n+\n+\tgit merge hla\n+\tgit push gh\n+\ttest ...\n+\n+   That way all of the commands in your tests will succeed or fail. If\n+   you must ignore the return value of something (e.g. the return\n+   value of export is unportable) it's best to indicate so explicitly\n+   with a semicolon:\n+\n+\texport HLAGH;\n+\tgit merge hla &&\n+\tgit push gh &&\n+\ttest ...\n+\n+Don't:\n+\n+ - exit() within a <script> part.\n+\n+   The harness will catch this as a programming error of the test.\n+   Use test_done instead if you need to stop the tests early (see\n+   \"Skipping tests\" below).\n+\n+ - Break the TAP output\n+\n+   The raw output from your test might be interpreted by a TAP\n+   harness. You usually don't have to worry about that. TAP harnesses\n+   will ignore everything they don't know about, but don't step on\n+   their toes in these areas:\n+\n+   - Don't print lines like \"$x..$y\" where $x and $y are integers.\n+\n+   - Don't print lines that begin with \"ok\" or \"not ok\".\n+\n+   A TAP harness expect a line that begins with either \"ok\" and \"not\n+   ok\" to signal a test passed or failed (and our harness already\n+   produces such lines), so your script shouldn't emit such lines to\n+   their output.\n+\n+   You can glean some further possible issues from the TAP grammar\n+   (see http://search.cpan.org/perldoc?TAP::Parser::Grammar#TAP_Grammar)\n+   but the best indication is to just run the tests with prove(1),\n+   it'll complain if anything is amiss.\n+\n+Keep in mind:\n+\n+ - That what you print to stderr and stdout is usually ignored\n+\n+   Inside <script> part, the standard output and standard error\n+   streams are discarded, and the test harness only reports \"ok\" or\n+   \"not ok\" to the end user running the tests. Under --verbose, they\n+   are shown to help debugging the tests.\n+\n+\n Skipping tests\n --------------\n \n-- \n1.7.1.251.g92a7\n"},{"id":"144860","messageId":"7vaaq58hhb.fsf@alter.siamese.dyndns.org","threadId":"24264","inReplyTo":"1278082789-19872-8-git-send-email-avarab@gmail.com","subject":"Re: [PATCH v4 7/7] t/README: Document the do's and don'ts of tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-07-06T02:35:44Z","receivedAt":"2010-07-06T02:35:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> +Do's, don'ts & things to keep in mind\n> +-------------------------------------\n> +\n> +Here's a few examples of things you probably should and shouldn't do\n> +when writing tests.\n\n\"Here are\" perhaps?\n\n> +Do:\n> +\n> + - Put as much code as possible inside test_expect_success and other\n> +   assertions.\n> +\n> +   Even code that isn't a test per se, but merely some setup code\n> +   should be inside a test assertion if at all possible. Test scripts\n> +   should only have trivial code outside of their assertions.\n\nLet's make it even stronger; \"should only have trivial\" -> \"shouldn't have\nany ... unless there is a good reason.\"\n\n> +Don't:\n> +\n> + - exit() within a <script> part.\n> +\n> +   The harness will catch this as a programming error of the test.\n> +   Use test_done instead if you need to stop the tests early (see\n> +   \"Skipping tests\" below).\n> +\n> + - Break the TAP output\n> +\n> +   The raw output from your test might be interpreted by a TAP\n> +   harness. You usually don't have to worry about that. TAP harnesses\n\nI'd recommend dropping \"You usually...about that\"  You do care, but the\nlimitation may be not so severe.\n\n> +   will ignore everything they don't know about, but don't step on\n> +   their toes in these areas:\n> +\n> +   - Don't print lines like \"$x..$y\" where $x and $y are integers.\n> +\n> +   - Don't print lines that begin with \"ok\" or \"not ok\".\n> +\n> +   A TAP harness expect a line that begins with either \"ok\" and \"not\n> +   ok\" to signal a test passed or failed (and our harness already\n> +   produces such lines), so your script shouldn't emit such lines to\n> +   their output.\n> +\n> +   You can glean some further possible issues from the TAP grammar\n> +   (see http://search.cpan.org/perldoc?TAP::Parser::Grammar#TAP_Grammar)\n> +   but the best indication is to just run the tests with prove(1),\n> +   it'll complain if anything is amiss.\n> +\n> +Keep in mind:\n> +\n> + - That what you print to stderr and stdout is usually ignored\n> +\n> +   Inside <script> part, the standard output and standard error\n\nSplitting the above into two sentences (or a header and a body) makes it\nunclear that your \"usually\" comes from the earlier \"Do Put as much code\ninside test_expect_success...\".  I think you can simply drop \"That what\nyou print ... ignored\".\n\nEverything else in the series looked good.  Thanks.\n"},{"id":"144889","messageId":"m3sk3xm2jr.fsf@localhost.localdomain","threadId":"24264","inReplyTo":"7vaaq58hhb.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v4 7/7] t/README: Document the do's and don'ts of tests","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-07-06T08:35:33Z","receivedAt":"2010-07-06T08:35:33Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n> \n> > +Do:\n> > +\n> > + - Put as much code as possible inside test_expect_success and other\n> > +   assertions.\n> > +\n> > +   Even code that isn't a test per se, but merely some setup code\n> > +   should be inside a test assertion if at all possible. Test scripts\n> > +   should only have trivial code outside of their assertions.\n> \n> Let's make it even stronger; \"should only have trivial\" -> \"shouldn't have\n> any ... unless there is a good reason.\"\n\nI think that the only thing that can and *should* be put outside\ntest_expect_* is creating helper file: test vectors ('expect' files),\nconfiguration files, files that are to be arguments to commands, etc.\nIs it covered by \"there is a good reason\"?  Isn't it too severe?\n\nThere probably should be description when to put creating such files\nin test script, and when to put them as pre-made files in tXXXX/\nsubdirectory (non US-ASCII is one reason to put it as pre-made file).\n \n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"144902","messageId":"AANLkTimvyxNq3GAnwNZJEm6U5Jn7TlaedLZk12O9g8xe@mail.gmail.com","threadId":"24264","inReplyTo":"7vaaq58hhb.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v4 7/7] t/README: Document the do's and don'ts of tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-06T12:50:08Z","receivedAt":"2010-07-06T12:50:08Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Tue, Jul 6, 2010 at 02:35, Junio C Hamano <gitster@pobox.com> wrote:\n> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n>\n>> +Do's, don'ts & things to keep in mind\n>> +-------------------------------------\n>> +\n>> +Here's a few examples of things you probably should and shouldn't do\n>> +when writing tests.\n>\n> \"Here are\" perhaps?\n>\n>> +Do:\n>> +\n>> + - Put as much code as possible inside test_expect_success and other\n>> +   assertions.\n>> +\n>> +   Even code that isn't a test per se, but merely some setup code\n>> +   should be inside a test assertion if at all possible. Test scripts\n>> +   should only have trivial code outside of their assertions.\n>\n> Let's make it even stronger; \"should only have trivial\" -> \"shouldn't have\n> any ... unless there is a good reason.\"\n>\n>> +Don't:\n>> +\n>> + - exit() within a <script> part.\n>> +\n>> +   The harness will catch this as a programming error of the test.\n>> +   Use test_done instead if you need to stop the tests early (see\n>> +   \"Skipping tests\" below).\n>> +\n>> + - Break the TAP output\n>> +\n>> +   The raw output from your test might be interpreted by a TAP\n>> +   harness. You usually don't have to worry about that. TAP harnesses\n>\n> I'd recommend dropping \"You usually...about that\"  You do care, but the\n> limitation may be not so severe.\n>\n>> +   will ignore everything they don't know about, but don't step on\n>> +   their toes in these areas:\n>> +\n>> +   - Don't print lines like \"$x..$y\" where $x and $y are integers.\n>> +\n>> +   - Don't print lines that begin with \"ok\" or \"not ok\".\n>> +\n>> +   A TAP harness expect a line that begins with either \"ok\" and \"not\n>> +   ok\" to signal a test passed or failed (and our harness already\n>> +   produces such lines), so your script shouldn't emit such lines to\n>> +   their output.\n>> +\n>> +   You can glean some further possible issues from the TAP grammar\n>> +   (see http://search.cpan.org/perldoc?TAP::Parser::Grammar#TAP_Grammar)\n>> +   but the best indication is to just run the tests with prove(1),\n>> +   it'll complain if anything is amiss.\n>> +\n>> +Keep in mind:\n>> +\n>> + - That what you print to stderr and stdout is usually ignored\n>> +\n>> +   Inside <script> part, the standard output and standard error\n>\n> Splitting the above into two sentences (or a header and a body) makes it\n> unclear that your \"usually\" comes from the earlier \"Do Put as much code\n> inside test_expect_success...\".  I think you can simply drop \"That what\n> you print ... ignored\".\n>\n> Everything else in the series looked good.  Thanks.\n\nAll of these rewordings (the \"t/README: proposed rewording...\" commit\nin pu) look good.\n\n    Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n"},{"id":"144903","messageId":"AANLkTikFOAWINvKINvPbbrqBNlmjDcn7uJVQ7doVbhem@mail.gmail.com","threadId":"24264","inReplyTo":"m3sk3xm2jr.fsf@localhost.localdomain","subject":"Re: [PATCH v4 7/7] t/README: Document the do's and don'ts of tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-06T13:02:22Z","receivedAt":"2010-07-06T13:02:22Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Tue, Jul 6, 2010 at 08:35, Jakub Narebski <jnareb@gmail.com> wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n>>\n>> > +Do:\n>> > +\n>> > + - Put as much code as possible inside test_expect_success and other\n>> > +   assertions.\n>> > +\n>> > +   Even code that isn't a test per se, but merely some setup code\n>> > +   should be inside a test assertion if at all possible. Test scripts\n>> > +   should only have trivial code outside of their assertions.\n>>\n>> Let's make it even stronger; \"should only have trivial\" -> \"shouldn't have\n>> any ... unless there is a good reason.\"\n>\n> I think that the only thing that can and *should* be put outside\n> test_expect_* is creating helper file: test vectors ('expect' files),\n> configuration files, files that are to be arguments to commands, etc.\n> Is it covered by \"there is a good reason\"?  Isn't it too severe?\n\nPersonally I'd put `.. >expect && .. >actual && test_cmp' inside\ntest_expect_* too if they're only going to be used by that test, but\noutside them at the top of the file if they're files that are used by\nmultiple tests for the duration of the test run.\n\n> There probably should be description when to put creating such files\n> in test script, and when to put them as pre-made files in tXXXX/\n> subdirectory (non US-ASCII is one reason to put it as pre-made file).\n\nI don't know which one would be preferrable. We have a lot of things\nin t/t*/* that could be generated by a test, and vice-versa.\n"},{"id":"144904","messageId":"201007061519.51632.jnareb@gmail.com","threadId":"24264","inReplyTo":"AANLkTikFOAWINvKINvPbbrqBNlmjDcn7uJVQ7doVbhem@mail.gmail.com","subject":"Re: [PATCH v4 7/7] t/README: Document the do's and don'ts of tests","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-07-06T13:19:50Z","receivedAt":"2010-07-06T13:19:50Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Tue, 6 Jul 2010, Ævar Arnfjörð Bjarmason wrote:\n> On Tue, Jul 6, 2010 at 08:35, Jakub Narebski <jnareb@gmail.com> wrote:\n>> Junio C Hamano <gitster@pobox.com> writes:\n>>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n>>>\n>>>> +Do:\n>>>> +\n>>>> + - Put as much code as possible inside test_expect_success and other\n>>>> +   assertions.\n>>>> +\n>>>> +   Even code that isn't a test per se, but merely some setup code\n>>>> +   should be inside a test assertion if at all possible. Test scripts\n>>>> +   should only have trivial code outside of their assertions.\n>>>\n>>> Let's make it even stronger; \"should only have trivial\" -> \"shouldn't have\n>>> any ... unless there is a good reason.\"\n>>\n>> I think that the only thing that can and *should* be put outside\n>> test_expect_* is creating helper file: test vectors ('expect' files),\n>> configuration files, files that are to be arguments to commands, etc.\n>> Is it covered by \"there is a good reason\"?  Isn't it too severe?\n> \n> Personally I'd put `..>expect && ..>actual && test_cmp' inside\n> test_expect_* too if they're only going to be used by that test, but\n> outside them at the top of the file if they're files that are used by\n> multiple tests for the duration of the test run.\n\nI agree with putting e.g. `echo \"sth\" >expect` inside test_expect_*.\nIt is also obvious that `.. >actual` should be inside test_expect_*.\n\nWhat I was thinking about was generating larger files, by using e.g.\n\n  cat >expected <<\\EOF\n  \n  ...\n  EOF\n\nPutting them inside test_expect_* would make it IMHO less clear, less\nreadable.\n\n\nSidenote: we should probably describe <<\\EOF vs <<EOF here-docs and\nwhen to use one or another in t/README.\n\n>> There probably should be description when to put creating such files\n>> in test script, and when to put them as pre-made files in tXXXX/\n>> subdirectory (non US-ASCII is one reason to put it as pre-made file).\n> \n> I don't know which one would be preferrable. We have a lot of things\n> in t/t*/* that could be generated by a test, and vice-versa.\n\nProbably because those tests were written by diferent people, and there\nwere no clear policy / guidelines description in t/README :-)\n\n\nThanks a lot for your work!\n\n-- \nJakub Narebski\nPoland\n"}]}