[next] telepathy-idle: Make run-test.sh more like the one in Gabble ( next-tests branch)

Simon McVittie smcv at kemper.freedesktop.org
Mon Apr 7 09:05:00 PDT 2014


Module: telepathy-idle
Branch: next
Commit: 73a463d71eb61c937b52b1a57a87e8651f073f9d
URL:    http://cgit.freedesktop.org/telepathy/telepathy-idle/commit/?id=73a463d71eb61c937b52b1a57a87e8651f073f9d

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Wed Apr  2 19:01:58 2014 +0100

Make run-test.sh more like the one in Gabble (next-tests branch)

* output TAP format to stdout
* set XDG_CONFIG_*, XDG_DATA_*, XDG_CACHE_HOME
* output IDLE_DEBUG=all and CHECK_TWISTED_VERBOSE logs on failure

---

 tests/twisted/run-test.sh.in            |  102 +++++++++++++++++++++++++++----
 tests/twisted/tools/exec-with-log.sh.in |    7 ++-
 2 files changed, 96 insertions(+), 13 deletions(-)

diff --git a/tests/twisted/run-test.sh.in b/tests/twisted/run-test.sh.in
index 4325527..0004ab3 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,6 +46,12 @@ fi
 
 config_file="${G_TEST_BUILDDIR}/tools/tmp-session-bus.conf"
 
+IDLE_DEBUG=all
+export IDLE_DEBUG
+
+XDG_CONFIG_DIRS="${G_TEST_SRCDIR}"
+export XDG_CONFIG_DIRS
+
 # Turn off anti-flooding to hurry the tests up (without this,
 # channels/join-muc-channel-bouncer.py will time out, and the rest
 # will be really slow)
@@ -42,27 +64,83 @@ 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
+
+  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
diff --git a/tests/twisted/tools/exec-with-log.sh.in b/tests/twisted/tools/exec-with-log.sh.in
index e858e1c..6cad211 100644
--- a/tests/twisted/tools/exec-with-log.sh.in
+++ b/tests/twisted/tools/exec-with-log.sh.in
@@ -2,11 +2,16 @@
 
 cd "@abs_top_builddir@/tests/twisted/tools"
 
+if test -z "$CHECK_TWISTED_LOG_DIR"; then
+        echo "CHECK_TWISTED_LOG_DIR must be set"
+        exit 1
+fi
+
 export IDLE_DEBUG=all
 G_MESSAGES_DEBUG=all
 export G_MESSAGES_DEBUG
 ulimit -c unlimited
-exec >> idle-testing.log 2>&1
+exec > "${CHECK_TWISTED_LOG_DIR}/idle-testing.log" 2>&1
 
 if test -n "$IDLE_TEST_VALGRIND"; then
         export G_DEBUG=${G_DEBUG:+"${G_DEBUG},"}gc-friendly



More information about the telepathy-commits mailing list