]> asedeno.scripts.mit.edu Git - git.git/blobdiff - t/test-lib.sh
Merge branch 'mh/maint-http-proxy-fix'
[git.git] / t / test-lib.sh
index 83889c4f4690d30fd2d5e969d5d445dfb47ad579..87a5ea4a6a54d712c0973cd9b8090c3ec83fb828 100644 (file)
@@ -80,7 +80,7 @@ do
        -q|--q|--qu|--qui|--quie|--quiet)
                quiet=t; shift ;;
        --no-color)
-           color=; shift ;;
+               color=; shift ;;
        --no-python)
                # noop now...
                shift ;;
@@ -142,7 +142,12 @@ test_count=0
 test_fixed=0
 test_broken=0
 
-trap 'echo >&5 "FATAL: Unexpected exit with code $?"; exit 1' exit
+die () {
+       echo >&5 "FATAL: Unexpected exit with code $?"
+       exit 1
+}
+
+trap 'die' exit
 
 test_tick () {
        if test -z "${test_tick+set}"
@@ -270,6 +275,23 @@ test_expect_code () {
        echo >&3 ""
 }
 
+# This is not among top-level (test_expect_success | test_expect_failure)
+# but is a prefix that can be used in the test script, like:
+#
+#      test_expect_success 'complain and die' '
+#           do something &&
+#           do something else &&
+#          test_must_fail git checkout ../outerspace
+#      '
+#
+# Writing this as "! git checkout ../outerspace" is wrong, because
+# the failure could be due to a segv.  We want a controlled failure.
+
+test_must_fail () {
+       "$@"
+       test $? -gt 0 -a $? -le 128
+}
+
 # Most tests can use the created repository, but some may need to create more.
 # Usage: test_create_repo <directory>
 test_create_repo () {
@@ -342,6 +364,8 @@ if ! test -x ../test-chmtime; then
        exit 1
 fi
 
+. ../GIT-BUILD-OPTIONS
+
 # Test repository
 test=trash
 rm -fr "$test"