From 64893fe6bc61c3409a348cf36d16004a8802161b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 4 Jun 2013 12:19:29 +0100 Subject: [PATCH 4/4] Adapt tests to be compatible with Automake 1.13 Instead of (ab)using the check-TESTS target and the TESTS_ENVIRONMENT variable, we now run the tests from a shell script similar to the one in telepathy-gabble. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65290 --- .gitignore | 2 + tests/twisted/Makefile.am | 28 +++++++---- tests/twisted/run-tests.sh.in | 111 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+), 10 deletions(-) create mode 100644 tests/twisted/run-tests.sh.in diff --git a/.gitignore b/.gitignore index 1776590..635a496 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ Makefile Makefile.in _gen aclocal.m4 +/build-aux/test-driver config.guess config.log config.status @@ -35,6 +36,7 @@ tags /tests/org.freedesktop.Telepathy.ConnectionManager.haze.service /tests/tmp-session-bus.conf /tests/twisted/config.py +/tests/twisted/run-tests.sh /telepathy-haze*.tar.gz* /telepathy-haze*/ diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index 2b92404..d11db47 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -25,18 +25,15 @@ TWISTED_TESTS = \ TESTS = -TESTS_ENVIRONMENT = \ - PYTHONPATH=@abs_top_srcdir@/tests/twisted:@abs_top_builddir@/tests/twisted - check-local: check-twisted -check-twisted: +check-twisted: $(BUILT_SOURCES) rm -f ../haze-testing.log - sh $(top_srcdir)/tools/with-session-bus.sh \ - --config-file=$(top_builddir)/tests/tmp-session-bus.conf \ - -- $(MAKE) check-TESTS \ - TESTS="$(TWISTED_TESTS)" \ - TESTS_ENVIRONMENT="$(TESTS_ENVIRONMENT) $(TEST_PYTHON)" + HAZE_TEST_UNINSTALLED=1 \ + HAZE_ABS_TOP_SRCDIR=@abs_top_srcdir@ \ + HAZE_ABS_TOP_BUILDDIR=@abs_top_builddir@ \ + HAZE_TEST_SINGLE_INSTANCE=1 \ + sh ./run-tests.sh "$(TWISTED_TESTS)" EXTRA_DIST = \ $(TWISTED_TESTS) \ @@ -57,6 +54,17 @@ config.py: Makefile echo "MEDIA_ENABLED = $(MEDIA_ENABLED_PYBOOL)"; \ } > $@ -BUILT_SOURCES = config.py +BUILT_SOURCES = \ + config.py \ + run-tests.sh \ + $(NULL) + +run-tests.sh: run-tests.sh.in Makefile + $(AM_V_GEN)sed \ + -e 's![@]hazetestsdir[@]!/FIXME!' \ + -e 's![@]TEST_PYTHON[@]!$(PYTHON)!' \ + < $< > $@.tmp && \ + chmod +x $@.tmp && \ + mv $@.tmp $@ CLEANFILES = *.pyc */*.pyc config.py diff --git a/tests/twisted/run-tests.sh.in b/tests/twisted/run-tests.sh.in new file mode 100644 index 0000000..53fc901 --- /dev/null +++ b/tests/twisted/run-tests.sh.in @@ -0,0 +1,111 @@ +#!/bin/sh + +hazetestsdir="@hazetestsdir@" +TEST_PYTHON="@TEST_PYTHON@" + +if test "x$HAZE_TEST_UNINSTALLED" = x; then + echo "The Haze tests cannot be installed yet" >&2 + exit 1 + + # for later... + + script_fullname=`readlink -e "${hazetestsdir}/twisted/run-tests.sh"` + if [ `readlink -e "$0"` != "$script_fullname" ] ; then + echo "This script is meant to be installed at $script_fullname" >&2 + exit 1 + fi + + test_src="${hazetestsdir}" + test_build="${hazetestsdir}" + config_file="${hazetestsdir}/installed-tmp-session-bus.conf" + tools="${hazetestsdir}/tools" + + PYTHONPATH="${hazetestsdir}/twisted" + export PYTHONPATH +else + if test -z "$HAZE_ABS_TOP_SRCDIR"; then + echo "HAZE_ABS_TOP_SRCDIR must be set" >&2 + exit 1 + fi + if test -z "$HAZE_ABS_TOP_BUILDDIR"; then + echo "HAZE_ABS_TOP_BUILDDIR must be set" >&2 + exit 1 + fi + + test_src="${HAZE_ABS_TOP_SRCDIR}/tests" + test_build="${HAZE_ABS_TOP_BUILDDIR}/tests" + config_file="${test_build}/tmp-session-bus.conf" + tools="${HAZE_ABS_TOP_SRCDIR}/tools" + + PYTHONPATH="${test_src}/twisted:${test_build}/twisted" + export PYTHONPATH +fi + +if [ -z $CHECK_TWISTED_SLEEP ]; then + CHECK_TWISTED_SLEEP=0 +fi + +if [ -n "$1" ] ; then + list="$1" +elif [ -n "$TWISTED_TESTS" ]; then + list="$TWISTED_TESTS" +else + list=$(cat "${test_build}"/twisted/haze-twisted-tests.list) +fi + +case "$HAZE_TEST_SINGLE_INSTANCE" in + (inner) + # already re-executed under a temporary session bus + test -n "$DBUS_SESSION_BUS_ADDRESS" || exit 2 + ;; + (1) + # re-exec self under a temporary session bus + HAZE_TEST_SINGLE_INSTANCE=inner + export HAZE_TEST_SINGLE_INSTANCE + exec sh "${tools}/with-session-bus.sh" \ + --sleep=${CHECK_TWISTED_SLEEP} \ + --config-file="${config_file}" \ + -- \ + ${test_build}/twisted/run-tests.sh "$list" + echo "exec failed" >&2 + exit 1 + ;; + (*) + # empty or 0: we're going to run each test under its own session bus + ;; +esac + +any_failed=0 +for i in $list ; do + echo "Testing $i ..." + + case "$HAZE_TEST_SINGLE_INSTANCE" in + (inner) + ${TEST_PYTHON} -u "${test_src}/twisted/$i" + ;; + (*) + sh "${tools}/with-session-bus.sh" \ + --sleep=${CHECK_TWISTED_SLEEP} \ + --config-file="${config_file}" \ + -- \ + ${TEST_PYTHON} -u "${test_src}/twisted/$i" + ;; + esac + + e=$? + case "$e" in + (0) + echo "PASS: $i" + ;; + (77) + echo "SKIP: $i" + ;; + (*) + any_failed=1 + echo "FAIL: $i ($e)" + ;; + esac +done + +exit $any_failed + -- 1.7.10.4