summaryrefslogtreecommitdiff
path: root/t/test-lib.sh
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2010-04-14 19:38:07 -0500
committerJunio C Hamano <gitster@pobox.com>2010-04-14 17:56:53 -0700
commitfdf1bc48caa008c7f285db3323498f25a7758879 (patch)
tree3af17c4e749659e778c8017d5353ceb1c77d4434 /t/test-lib.sh
parentf78683f3a85ca16ae16e1180703d3280b272f45d (diff)
downloadgit-fdf1bc48caa008c7f285db3323498f25a7758879.tar.gz
t7006: guard cleanup with test_expect_success
Most of these tests are removing files, environment variables, and configuration that might interfere outside the test. Putting these clean-up commands in the test (in the same spirit as v1.7.1-rc0~59, 2010-03-20) means that errors during setup will be caught quickly and non-error text will be suppressed without -v. While at it, apply some other minor fixes: - do not rely on the shell to export variables defined with the same command as a function call - avoid whitespace immediately after the > redirection operator, for consistency with the style of other tests Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib.sh')
-rw-r--r--t/test-lib.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh
index a0e396a952..a596f2aa02 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -512,6 +512,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:
#