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

[PATCH 4/8] t/README: Document the prereq functions, and 3-arg test_*

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 1, 2010, 15:10 UTC
Message-ID
<1277997004-29504-5-git-send-email-avarab@gmail.com>
In-Reply-To
<1277997004-29504-1-git-send-email-avarab@gmail.com>

There was no documentation for the test_set_prereq and test_have_prereq functions, or the three-arg form of test_expect_success and test_expect_failure.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/README |   37 ++++++++++++++++++++++++++++++++++---
 1 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/t/README b/t/README
index 0998bfb..67f8f30 100644
--- a/t/README
+++ b/t/README
@@ -246,9 +246,9 @@ Test harness library
 There are a handful helper functions defined in the test harness
 library for your script to use.
 
- - test_expect_success <message> <script>
+ - test_expect_success [<prereq>] <message> <script>
 
-   This takes two strings as parameter, and evaluates the
+   Usually takes two strings as parameter, and evaluates the
    <script>.  If it yields success, test is considered
    successful.  <message> should state what it is testing.
 
@@ -257,8 +257,15 @@ library for your script to use.
 	test_expect_success \
 	    'git-write-tree should be able to write an empty tree.' \
 	    'tree=$(git-write-tree)'
+        
+   If you supply three parameters the first will be taken to be a
+   prerequisite, see the test_set_prereq and test_have_prereq
+   documentation below:
 
- - test_expect_failure <message> <script>
+	test_expect_success TTY 'git --paginate rev-list uses a pager' \
+	    ' ... '
+
+ - test_expect_failure [<prereq>] <message> <script>
 
    This is NOT the opposite of test_expect_success, but is used
    to mark a test that demonstrates a known breakage.  Unlike
@@ -266,6 +273,9 @@ library for your script to use.
    success and "FAIL" on failure, this will say "FIXED" on
    success and "still broken" on failure.  Failures from these
    tests won't cause -i (immediate) to stop.
+   
+   Like test_expect_success this function can optionally use a three
+   argument invocation with a prerequisite as the first argument.
 
  - test_debug <script>
 
@@ -299,6 +309,27 @@ library for your script to use.
    Merges the given rev using the given message.  Like test_commit,
    creates a tag and calls test_tick before committing.
 
+ - test_set_prereq SOME_PREREQ
+ 
+   Set a test prerequisite to be used later with test_have_prereq. The
+   test-lib will set some prerequisites for you, e.g. PERL and PYTHON
+   which are derived from ./GIT-BUILD-OPTIONS (grep test_set_prereq
+   test-lib.sh for more). Others you can set yourself and use later
+   with either test_have_prereq directly, or the three argument
+   invocation of test_expect_success and test_expect_failure.
+   
+ - test_have_prereq SOME PREREQ
+
+   Check if we have a prerequisite previously set with
+   test_set_prereq. The most common use of this directly is to skip
+   all the tests if we don't have some essential prerequisite:
+ 
+	if ! test_have_prereq PERL
+	then
+	    skip_all='skipping perl interface tests, perl not available'
+	    test_done
+	fi
+
 Tips for Writing Tests
 ----------------------
 
-- 
1.7.1.251.g92a7
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 7 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.