diff --git a/t/test-lib.sh b/t/test-lib.sh
index dad1437fa49596cf6f36b40b1ab18b008620a246..a5b8d03db0fc88c42e38cdde13a6cd2b14c06581 100644 (file)
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
valgrind=t; verbose=t; shift ;;
--tee)
shift ;; # was handled already
valgrind=t; verbose=t; shift ;;
--tee)
shift ;; # was handled already
+ --root=*)
+ root=$(expr "z$1" : 'z[^=]*=\(.*\)')
+ shift ;;
*)
*)
- break ;;
+ echo "error: unknown test option '$1'" >&2; exit 1 ;;
esac
done
esac
done
error () {
say_color error "error: $*"
error () {
say_color error "error: $*"
- trap - EXIT
+ GIT_EXIT_OK=t
exit 1
}
exit 1
}
test_success=0
die () {
test_success=0
die () {
- echo >&5 "FATAL: Unexpected exit with code $?"
- exit 1
+ code=$?
+ if test -n "$GIT_EXIT_OK"
+ then
+ exit $code
+ else
+ echo >&5 "FATAL: Unexpected exit with code $code"
+ exit 1
+ fi
}
}
+GIT_EXIT_OK=
trap 'die' EXIT
# The semantics of the editor variables are that of invoking
trap 'die' EXIT
# The semantics of the editor variables are that of invoking
say_color error "FAIL $test_count: $1"
shift
echo "$@" | sed -e 's/^/ /'
say_color error "FAIL $test_count: $1"
shift
echo "$@" | sed -e 's/^/ /'
- test "$immediate" = "" || { trap - EXIT; exit 1; }
+ test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
}
test_known_broken_ok_ () {
}
test_known_broken_ok_ () {
then
test_known_broken_ok_ "$1"
else
then
test_known_broken_ok_ "$1"
else
- test_known_broken_failure_ "$1"
+ test_known_broken_failure_ "$1"
fi
fi
echo >&3 ""
fi
fi
echo >&3 ""
}
test_done () {
}
test_done () {
- trap - EXIT
+ GIT_EXIT_OK=t
test_results_dir="$TEST_DIRECTORY/test-results"
mkdir -p "$test_results_dir"
test_results_path="$test_results_dir/${0%.sh}-$$"
test_results_dir="$TEST_DIRECTORY/test-results"
mkdir -p "$test_results_dir"
test_results_path="$test_results_dir/${0%.sh}-$$"
# Test repository
test="trash directory.$(basename "$0" .sh)"
# Test repository
test="trash directory.$(basename "$0" .sh)"
-test ! -z "$debug" || remove_trash="$TEST_DIRECTORY/$test"
+test -n "$root" && test="$root/$test"
+case "$test" in
+/*) TRASH_DIRECTORY="$test" ;;
+ *) TRASH_DIRECTORY="$TEST_DIRECTORY/$test" ;;
+esac
+test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY
rm -fr "$test" || {
rm -fr "$test" || {
- trap - EXIT
+ GIT_EXIT_OK=t
echo >&5 "FATAL: Cannot prepare test area"
exit 1
}
echo >&5 "FATAL: Cannot prepare test area"
exit 1
}