summaryrefslogtreecommitdiff
path: root/t/test-lib.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/test-lib.sh')
-rw-r--r--t/test-lib.sh30
1 files changed, 29 insertions, 1 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 7422bba..367f053 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -75,7 +75,6 @@ export GIT_MERGE_VERBOSITY
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
export EDITOR
-GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
# Protect ourselves from common misconfiguration to export
# CDPATH into the environment
@@ -473,6 +472,9 @@ test_external () {
# Announce the script to reduce confusion about the
# test output that follows.
say_color "" " run $test_count: $descr ($*)"
+ # Export TEST_DIRECTORY, TRASH_DIRECTORY and GIT_TEST_LONG
+ # to be able to use them in script
+ export TEST_DIRECTORY TRASH_DIRECTORY GIT_TEST_LONG
# Run command; redirect its stderr to &4 as in
# test_run_, but keep its stdout on our stdout even in
# non-verbose mode.
@@ -530,6 +532,22 @@ test_must_fail () {
test $? -gt 0 -a $? -le 129 -o $? -gt 192
}
+# Similar to test_must_fail, but tolerates success, too. This is
+# meant to be used in contexts like:
+#
+# test_expect_success 'some command works without configuration' '
+# test_might_fail git config --unset all.configuration &&
+# do something
+# '
+#
+# Writing "git config --unset all.configuration || :" would be wrong,
+# because we want to notice if it fails due to segv.
+
+test_might_fail () {
+ "$@"
+ test $? -ge 0 -a $? -le 129 -o $? -gt 192
+}
+
# test_cmp is a helper function to compare actual and expected output.
# You can use it like:
#
@@ -721,6 +739,16 @@ export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOB
. ../GIT-BUILD-OPTIONS
+if test -z "$GIT_TEST_CMP"
+then
+ if test -n "$GIT_TEST_CMP_USE_COPIED_CONTEXT"
+ then
+ GIT_TEST_CMP="$DIFF -c"
+ else
+ GIT_TEST_CMP="$DIFF -u"
+ fi
+fi
+
GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
export GITPERLLIB
test -d ../templates/blt || {