git-p4: add failing test for "git-p4: respect excluded paths when detecting branches"
[gitweb.git] / t / test-lib.sh
index 42b1a0aa7f0b8f5b06735293089f640b7f228f62..562c57e6858b79aff074fcb7ab8c65fa2f110bc0 100644 (file)
@@ -147,10 +147,28 @@ do
        --stress)
                stress=t ;;
        --stress=*)
+               echo "error: --stress does not accept an argument: '$opt'" >&2
+               echo "did you mean --stress-jobs=${opt#*=} or --stress-limit=${opt#*=}?" >&2
+               exit 1
+               ;;
+       --stress-jobs=*)
+               stress=t;
                stress=${opt#--*=}
                case "$stress" in
-               *[^0-9]*|0*|"")
-                       echo "error: --stress=<N> requires the number of jobs to run" >&2
+               *[!0-9]*|0*|"")
+                       echo "error: --stress-jobs=<N> requires the number of jobs to run" >&2
+                       exit 1
+                       ;;
+               *)      # Good.
+                       ;;
+               esac
+               ;;
+       --stress-limit=*)
+               stress=t;
+               stress_limit=${opt#--*=}
+               case "$stress_limit" in
+               *[!0-9]*|0*|"")
+                       echo "error: --stress-limit=<N> requires the number of repetitions" >&2
                        exit 1
                        ;;
                *)      # Good.
@@ -242,8 +260,10 @@ then
                                exit 1
                        ' TERM INT
 
-                       cnt=0
-                       while ! test -e "$stressfail"
+                       cnt=1
+                       while ! test -e "$stressfail" &&
+                             { test -z "$stress_limit" ||
+                               test $cnt -le $stress_limit ; }
                        do
                                $TEST_SHELL_PATH "$0" "$@" >"$TEST_RESULTS_BASE.stress-$job_nr.out" 2>&1 &
                                test_pid=$!
@@ -266,6 +286,7 @@ then
 
        if test -f "$stressfail"
        then
+               stress_exit=1
                echo "Log(s) of failed test run(s):"
                for failed_job_nr in $(sort -n "$stressfail")
                do
@@ -1313,7 +1334,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