test: caution on our version of 'yes'
authorJunio C Hamano <gitster@pobox.com>
Sat, 9 Feb 2019 18:25:26 +0000 (10:25 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 Feb 2019 20:31:19 +0000 (12:31 -0800)
During a review of a patch, we noticed that we use our own imitation
of 'yes' with the limit of 99 lines. It is very tempting to lift this
arbitrary limit, but the limit is there for a reason.

Add an in-code comment to prevent future developers from wasting
their time.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/README
t/test-lib.sh
index 1326fd7505fde3a9e34fef1e197623c8d409d6ff..f4e1a82657e05671201765622d6600ba8367204e 100644 (file)
--- a/t/README
+++ b/t/README
@@ -927,6 +927,15 @@ library for your script to use.
    test_oid_init or test_oid_cache.  Providing an unknown key is an
    error.
 
+ - yes [<string>]
+
+   This is often seen in modern UNIX but some platforms lack it, so
+   the test harness overrides the platform implementation with a
+   more limited one.  Use this only when feeding a handful lines of
+   output to the downstream---unlike the real version, it generates
+   only up to 99 lines.
+
+
 Prerequisites
 -------------
 
index 42b1a0aa7f0b8f5b06735293089f640b7f228f62..541a37f4c0a92bd498deaba5e47f5dcd29ea12be 100644 (file)
@@ -1313,7 +1313,11 @@ then
        fi
 fi
 
-# Provide an implementation of the 'yes' utility
+# Provide an implementation of the 'yes' utility; the upper bound
+# limit is there to help Windows that cannot stop this loop from
+# wasting cycles when the downstream stops reading, so do not be
+# tempted to turn it into an infinite loop. cf. 6129c930 ("test-lib:
+# limit the output of the yes utility", 2016-02-02)
 yes () {
        if test $# = 0
        then