]> asedeno.scripts.mit.edu Git - git.git/blobdiff - t/test-lib.sh
Merge branch 'js/rebase-i-rerere'
[git.git] / t / test-lib.sh
index 66efcdaacd72c0242a567830ea9a4cf95fc0860d..90b6844d00c3cb288c23488923b98a7276eb83e8 100644 (file)
@@ -60,14 +60,12 @@ esac
 # . ./test-lib.sh
 
 [ "x$TERM" != "xdumb" ] &&
+       [ -t 1 ] &&
        tput bold >/dev/null 2>&1 &&
        tput setaf 1 >/dev/null 2>&1 &&
        tput sgr0 >/dev/null 2>&1 &&
        color=t
 
-test "${test_description}" != "" ||
-error "Test script did not set test_description."
-
 while test "$#" -ne 0
 do
        case "$1" in
@@ -76,10 +74,11 @@ do
        -i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate)
                immediate=t; shift ;;
        -h|--h|--he|--hel|--help)
-               echo "$test_description"
-               exit 0 ;;
+               help=t; shift ;;
        -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
                verbose=t; shift ;;
+       -q|--q|--qu|--qui|--quie|--quiet)
+               quiet=t; shift ;;
        --no-color)
            color=; shift ;;
        --no-python)
@@ -97,7 +96,7 @@ if test -n "$color"; then
                        skip)  tput bold; tput setaf 2;; # bold green
                        pass)  tput setaf 2;;            # green
                        info)  tput setaf 3;;            # brown
-                       *);;
+                       *) test -n "$quiet" && return;;
                esac
                shift
                echo "* $*"
@@ -105,6 +104,7 @@ if test -n "$color"; then
        }
 else
        say_color() {
+               test -z "$1" && test -n "$quiet" && return
                shift
                echo "* $*"
        }
@@ -120,6 +120,15 @@ say () {
        say_color info "$*"
 }
 
+test "${test_description}" != "" ||
+error "Test script did not set test_description."
+
+if test "$help" = "t"
+then
+       echo "$test_description"
+       exit 0
+fi
+
 exec 5>&1
 if test "$verbose" = "t"
 then