From 91dde680a1ec49d23d04e0da5fa4854b30b12540 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 3 Jun 2013 15:23:46 +0100 Subject: [PATCH 2/2] 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. --- .gitignore | 1 + tests/twisted/Makefile.am | 40 +++++++++------ tests/twisted/run-tests.sh.in | 109 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+), 16 deletions(-) create mode 100644 tests/twisted/run-tests.sh.in diff --git a/.gitignore b/.gitignore index 3a3d303..051b569 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ src/*-enumtypes.[ch] /m4/lt*.m4 /missing /stamp-h1 +/test-driver Makefile.in Makefile diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index a0b30d6..896da4b 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -17,25 +17,21 @@ TWISTED_TESTS = \ voip/add-remove-content.py \ $(NULL) -TESTS = +CHECK_TWISTED_SLEEP=0 +TESTS = run-tests.sh TESTS_ENVIRONMENT = \ - PYTHONPATH=@abs_top_srcdir@/tests/twisted::@abs_top_builddir@/tests/twisted - -check-local: check-coding-style check-twisted + RAKIA_TEST_UNINSTALLED=1 \ + RAKIA_ABS_TOP_SRCDIR=@abs_top_srcdir@ \ + RAKIA_ABS_TOP_BUILDDIR=@abs_top_builddir@ \ + RAKIA_TEST_SINGLE_INSTANCE=1 \ + CHECK_TWISTED_SLEEP=$(CHECK_TWISTED_SLEEP) \ + TWISTED_TESTS="$(TWISTED_TESTS)" \ + $(NULL) -CHECK_TWISTED_SLEEP=0 +check-local: check-coding-style -check-twisted: - $(MAKE) -C tools - rm -f tools/rakia-testing.log - sh $(srcdir)/tools/with-session-bus.sh \ - --config-file=tools/tmp-session-bus.conf \ - --sleep=$(CHECK_TWISTED_SLEEP) \ - -- $(MAKE) check-TESTS \ - TESTS="$(TWISTED_TESTS)" \ - TESTS_ENVIRONMENT="$(TESTS_ENVIRONMENT) $(PYTHON)" 2>&1 | \ - fgrep -v -e DeprecationWarning -e DigestAuthorizer +check-twisted: check-TESTS if ENABLE_DEBUG DEBUGGING_PYBOOL = True @@ -49,7 +45,19 @@ config.py: Makefile echo "DEBUGGING = $(DEBUGGING_PYBOOL)"; \ } > $@ -BUILT_SOURCES = config.py +BUILT_SOURCES = \ + config.py \ + run-tests.sh \ + $(NULL) + +run-tests.sh: run-tests.sh.in Makefile + $(MAKE) -C tools + $(AM_V_GEN)sed \ + -e 's![@]rakiatestsdir[@]!/FIXME!' \ + -e 's![@]TEST_PYTHON[@]!$(PYTHON)!' \ + < $< > $@.tmp && \ + chmod +x $@.tmp && \ + mv $@.tmp $@ EXTRA_DIST = \ $(TWISTED_TESTS) \ diff --git a/tests/twisted/run-tests.sh.in b/tests/twisted/run-tests.sh.in new file mode 100644 index 0000000..e31b39d --- /dev/null +++ b/tests/twisted/run-tests.sh.in @@ -0,0 +1,109 @@ +#!/bin/sh + +rakiatestsdir="@rakiatestsdir@" +TEST_PYTHON="@TEST_PYTHON@" + +if test "x$RAKIA_TEST_UNINSTALLED" = x; then + echo "The Rakia tests cannot be installed yet" >&2 + exit 1 + + # for later... + + script_fullname=`readlink -e "${rakiatestsdir}/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="${rakiatestsdir}" + test_build="${rakiatestsdir}" + config_file="${rakiatestsdir}/twisted/tools/installed-tmp-session-bus.conf" + + PYTHONPATH="${rakiatestsdir}/twisted" + export PYTHONPATH +else + if test -z "$RAKIA_ABS_TOP_SRCDIR"; then + echo "RAKIA_ABS_TOP_SRCDIR must be set" >&2 + exit 1 + fi + if test -z "$RAKIA_ABS_TOP_BUILDDIR"; then + echo "RAKIA_ABS_TOP_BUILDDIR must be set" >&2 + exit 1 + fi + + test_src="${RAKIA_ABS_TOP_SRCDIR}/tests" + test_build="${RAKIA_ABS_TOP_BUILDDIR}/tests" + config_file="${test_build}/twisted/tools/tmp-session-bus.conf" + + 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/rakia-twisted-tests.list) +fi + +case "$RAKIA_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 + RAKIA_TEST_SINGLE_INSTANCE=inner + export RAKIA_TEST_SINGLE_INSTANCE + exec sh "${test_src}/twisted/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 "$RAKIA_TEST_SINGLE_INSTANCE" in + (inner) + ${TEST_PYTHON} -u "${test_src}/twisted/$i" + ;; + (*) + sh "${test_src}/twisted/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