]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/test-lib.sh
use build-time SHELL_PATH in test scripts
[thirdparty/git.git] / t / test-lib.sh
index 83889c4f4690d30fd2d5e969d5d445dfb47ad579..68efda44928fdd119a6e052557a9833cf3d2c13a 100644 (file)
@@ -270,6 +270,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 +359,8 @@ if ! test -x ../test-chmtime; then
        exit 1
 fi
 
+. ../GIT-BUILD-OPTIONS
+
 # Test repository
 test=trash
 rm -fr "$test"