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

[PATCH 4/4] t/README: Update "Skipping tests" to align with best practices

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 27, 2010, 21:14 UTC
Message-ID
<1280265254-19642-6-git-send-email-avarab@gmail.com>
In-Reply-To
<1280265254-19642-1-git-send-email-avarab@gmail.com>

The example I initially added to "Skipping tests" wasn't very good. We'd rather skip tests using the three-arg prereq form to the test_* functions, not bail out with a skip message.

Change the documentation to reflect that, but retain the bailout example under a disclaimer which explains that it's probably not a good idea to use it.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/README |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/t/README b/t/README
index 0d1183c..12b714b 100644
--- a/t/README
+++ b/t/README
@@ -307,9 +307,21 @@ Keep in mind:
 Skipping tests
 --------------
 
-If you need to skip all the remaining tests you should set skip_all
-and immediately call test_done. The string you give to skip_all will
-be used as an explanation for why the test was skipped. for instance:
+If you need to skip tests you should do so be using the three-arg form
+of the test_* functions (see the "Test harness library" section
+below), e.g.:
+
+    test_expect_success PERL 'I need Perl' "
+        '$PERL_PATH' -e 'hlagh() if unf_unf()'
+    "
+
+The advantage of skipping tests like this is that platforms that don't
+have the PERL and other optional dependencies get an indication of how
+many tests they're missing.
+
+If the test code is too hairy for that (i.e. does a lot of setup work
+outside test assertions) you can also skip all remaining tests by
+setting skip_all and immediately call test_done:
 
 	if ! test_have_prereq PERL
 	then
@@ -317,6 +329,9 @@ be used as an explanation for why the test was skipped. for instance:
 	    test_done
 	fi
 
+The string you give to skip_all will be used as an explanation for why
+the test was skipped.
+
 End with test_done
 ------------------
 
-- 
1.7.0.4
Previous: Ævar Arnfjörð Bjarmason
Message 8 of 8 in “Skip tests using 3-arg test_*”
  1. 0/4 Skip tests using 3-arg test_*Ævar Arnfjörð Bjarmason, Jul 27, 2010
  2. 1/4 tests: implicitly skip SYMLINKS tests using <prereq>Ævar Arnfjörð Bjarmason, Jul 27, 2010
  3. Jonathan NiederJul 27, 2010
  4. 1/4 t: implicitly skip SYMLINKS tests using <prereq>Ævar Arnfjörð Bjarmason, Jul 27, 2010
  5. Sverre RabbelierJul 27, 2010
  6. 2/4 t/t5800-remote-helpers.sh: Skip with prereq on python <2.4Ævar Arnfjörð Bjarmason, Jul 27, 2010
  7. 3/4 t/t7800-difftool.sh: Skip with prereq on no PERLÆvar Arnfjörð Bjarmason, Jul 27, 2010
  8. 4/4 t/README: Update "Skipping tests" to align with best practicesÆvar Arnfjörð Bjarmason, Jul 27, 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.