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.sh50
1 files changed, 39 insertions, 11 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 8a274fb..64390d7 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -578,7 +578,7 @@ test_external () {
test_external_without_stderr () {
# The temporary file has no (and must have no) security
# implications.
- tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi
+ tmp=${TMPDIR:-/tmp}
stderr="$tmp/git-external-stderr.$$.tmp"
test_external "$@" 4> "$stderr"
[ -f "$stderr" ] || error "Internal error: $stderr disappeared."
@@ -731,12 +731,11 @@ test_expect_code () {
exit_code=$?
if test $exit_code = $want_code
then
- echo >&2 "test_expect_code: command exited with $exit_code: $*"
return 0
- else
- echo >&2 "test_expect_code: command exited with $exit_code, we wanted $want_code $*"
- return 1
fi
+
+ echo >&2 "test_expect_code: command exited with $exit_code, we wanted $want_code $*"
+ return 1
}
# test_cmp is a helper function to compare actual and expected output.
@@ -804,12 +803,14 @@ test_done () {
mkdir -p "$test_results_dir"
test_results_path="$test_results_dir/${0%.sh}-$$.counts"
- echo "total $test_count" >> $test_results_path
- echo "success $test_success" >> $test_results_path
- echo "fixed $test_fixed" >> $test_results_path
- echo "broken $test_broken" >> $test_results_path
- echo "failed $test_failure" >> $test_results_path
- echo "" >> $test_results_path
+ cat >>"$test_results_path" <<-EOF
+ total $test_count
+ success $test_success
+ fixed $test_fixed
+ broken $test_broken
+ failed $test_failure
+
+ EOF
fi
if test "$test_fixed" != 0
@@ -1070,6 +1071,7 @@ esac
test -z "$NO_PERL" && test_set_prereq PERL
test -z "$NO_PYTHON" && test_set_prereq PYTHON
+test -n "$USE_LIBPCRE" && test_set_prereq LIBPCRE
# Can we rely on git's output in the C locale?
if test -n "$GETTEXT_POISON"
@@ -1080,6 +1082,32 @@ else
test_set_prereq C_LOCALE_OUTPUT
fi
+# Use this instead of test_cmp to compare files that contain expected and
+# actual output from git commands that can be translated. When running
+# under GETTEXT_POISON this pretends that the command produced expected
+# results.
+test_i18ncmp () {
+ test -n "$GETTEXT_POISON" || test_cmp "$@"
+}
+
+# Use this instead of "grep expected-string actual" to see if the
+# output from a git command that can be translated either contains an
+# expected string, or does not contain an unwanted one. When running
+# under GETTEXT_POISON this pretends that the command produced expected
+# results.
+test_i18ngrep () {
+ if test -n "$GETTEXT_POISON"
+ then
+ : # pretend success
+ elif test "x!" = "x$1"
+ then
+ shift
+ ! grep "$@"
+ else
+ grep "$@"
+ fi
+}
+
# test whether the filesystem supports symbolic links
ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
rm -f y