summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-05-12 09:56:11 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-05-12 09:56:11 +0100
commit7caf8119a9e2f81a120275d3995957a1fe00dfb5 (patch)
tree04718ec1003c001a4e7d99ab7de8eda760cfce66
parent17b093f724af367c932631c495be07252924b929 (diff)
downloadtelepathy-haze-7caf8119a9e2f81a120275d3995957a1fe00dfb5.tar.gz
Sync run-test.sh with Idle's, and add environment variables from exec-with-log.sh
-rw-r--r--tests/twisted/run-test.sh.in121
1 files changed, 109 insertions, 12 deletions
diff --git a/tests/twisted/run-test.sh.in b/tests/twisted/run-test.sh.in
index 296ede3..c0a3284 100644
--- a/tests/twisted/run-test.sh.in
+++ b/tests/twisted/run-test.sh.in
@@ -1,9 +1,25 @@
#!/bin/sh
+# This script assumes that it is run in a temporary directory where it can
+# create and delete subdirectories for files, logs, etc., but other users
+# cannot write (for instance, /tmp is unsuitable, but
+# the directory created by `mktemp -d /tmp/test.XXXXXXXXXX` is fine).
+#
+# During "make check" or "make installcheck" it runs in
+# ${top_builddir}/tests/twisted.
+#
+# During installed testing, the test environment must run it in a
+# suitable location.
+
+set -e
+
+CHECK_TWISTED_CURDIR="`pwd`"
+export CHECK_TWISTED_CURDIR
+
if test "x$CHECK_TWISTED_UNINSTALLED" = x; then
script_fullname=`readlink -e "@twistedtestsdir@/run-test.sh"`
if [ `readlink -e "$0"` != "$script_fullname" ] ; then
- echo "This script is meant to be installed at $script_fullname" >&2
+ echo "Bail out! This script is meant to be installed at $script_fullname"
exit 1
fi
@@ -16,11 +32,11 @@ if test "x$CHECK_TWISTED_UNINSTALLED" = x; then
export PYTHONPATH
else
if ! test -d "$G_TEST_SRCDIR"; then
- echo "G_TEST_SRCDIR must be set and absolute" >&2
+ echo "Bail out! G_TEST_SRCDIR must be set and absolute"
exit 1
fi
if ! test -d "$G_TEST_BUILDDIR"; then
- echo "G_TEST_BUILDDIR must be set and absolute" >&2
+ echo "Bail out! G_TEST_BUILDDIR must be set and absolute"
exit 1
fi
@@ -30,33 +46,114 @@ fi
config_file="${G_TEST_BUILDDIR}/tools/tmp-session-bus.conf"
+# Use international English messages for testing
+LC_ALL=C
+export LC_ALL
+
+# Avoid using a non-trivial GSettings backend
+GSETTINGS_BACKEND=memory
+export GSETTINGS_BACKEND
+
+# Avoid libpurple doing "clever" things
+unset KDE_FULL_SESSION
+unset KDEDIR
+unset KDEDIRS
+unset GNOME_DESKTOP_SESSION_ID
+
+HAZE_DEBUG=all
+export HAZE_DEBUG
+
+G_MESSAGES_DEBUG=all
+export G_MESSAGES_DEBUG
+
+XDG_CONFIG_DIRS="${G_TEST_SRCDIR}"
+export XDG_CONFIG_DIRS
+
if [ -n "$1" ] ; then
list="$1"
else
list=$(cat "${G_TEST_BUILDDIR}"/twisted-tests.list)
fi
-any_failed=0
+n=0
for i in $list ; do
- echo "Testing $i ..."
+ n=$(( $n + 1 ))
+done
+
+echo "1..$n"
+
+i=0
+n_failed=0
+for t in $list ; do
+ i=$(( $i + 1 ))
+ echo "# Testing $i/$n: $t ..."
+
+ tmp="${CHECK_TWISTED_CURDIR}/tmp-`echo $t | tr ./ __`"
+ rm -fr "$tmp"
+ mkdir "$tmp"
+
+ CHECK_TWISTED_LOG_DIR="${tmp}"
+ export CHECK_TWISTED_LOG_DIR
+ XDG_CONFIG_HOME="${tmp}/config"
+ export XDG_CONFIG_HOME
+ XDG_DATA_HOME="${tmp}/localshare"
+ export XDG_DATA_HOME
+ XDG_DATA_DIRS="${tmp}/share:${G_TEST_SRCDIR}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
+ export XDG_DATA_DIRS
+ XDG_CACHE_HOME="${tmp}/cache"
+ export XDG_CACHE_HOME
+ XDG_CACHE_DIR="${tmp}/cache"
+ export XDG_CACHE_DIR
+ HAZE_LOGFILE="${tmp}/cm.log"
+ export HAZE_LOGFILE
+
+ CHECK_TWISTED_VERBOSE=1
+ export CHECK_TWISTED_VERBOSE
+
+ e=0
sh "${G_TEST_SRCDIR}/tools/with-session-bus.sh" \
${CHECK_TWISTED_SLEEP} \
--config-file="${config_file}" \
-- \
- @TEST_PYTHON@ -u "${G_TEST_SRCDIR}/$i"
- e=$?
+ @TEST_PYTHON@ -u "${G_TEST_SRCDIR}/$t" \
+ > "$tmp"/test.log 2>&1 || e=$?
case "$e" in
(0)
- echo "PASS: $i"
+ echo "ok $i - $t"
+ if test -z "$CHECK_TWISTED_KEEP_TEMP"; then
+ rm -fr "$tmp"
+ fi
;;
(77)
- echo "SKIP: $i"
+ echo "ok $i # SKIP $t"
+ (
+ cd $tmp && for x in *.log; do
+ echo "# ===== log file: $x ====="
+ sed 's/^/# /' "$x"
+ done
+ echo "# ===== end of log files for $t ====="
+ )
+ if test -z "$CHECK_TWISTED_KEEP_TEMP"; then
+ rm -fr "$tmp"
+ fi
;;
(*)
- any_failed=1
- echo "FAIL: $i ($e)"
+ n_failed=$(( $n_failed + 1 ))
+ echo "not ok $i - $t ($e)"
+ (
+ cd $tmp && for x in *.log; do
+ echo "# ===== log file: $x ====="
+ sed 's/^/# /' "$x"
+ done
+ echo "# ===== end of log files for $t ====="
+ )
;;
esac
done
-exit $any_failed
+if test $n_failed != 0; then
+ echo "# Tests run: $n; tests failed: $n_failed"
+ exit 1
+else
+ exit 0
+fi