diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-05-08 08:38:22 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-05-08 08:38:22 +0100 |
commit | 9b26cf8238a7d432fe96a50a75008aa6bce110da (patch) | |
tree | 230e34ea1265333a06e8a25963cef48c5ab7a2b7 | |
parent | 0872782255fdbaeda64311a298664597e59ba94f (diff) | |
download | dbus-python-9b26cf8238a7d432fe96a50a75008aa6bce110da.tar.gz |
Add support for skipping tests, and use it
Now that Python 2.6 isn't a supported version in Debian, it doesn't
get a gi module, but we can still get some minimal test coverage.
-rw-r--r-- | test/cross-test-client.py | 5 | ||||
-rw-r--r-- | test/cross-test-server.py | 5 | ||||
-rwxr-xr-x | test/run-test.sh | 37 | ||||
-rwxr-xr-x | test/run-with-tmp-session-bus.sh | 14 | ||||
-rwxr-xr-x | test/test-client.py | 6 | ||||
-rw-r--r-- | test/test-p2p.py | 5 | ||||
-rw-r--r-- | test/test-signals.py | 5 |
7 files changed, 62 insertions, 15 deletions
diff --git a/test/cross-test-client.py b/test/cross-test-client.py index 75c4119..f42e785 100644 --- a/test/cross-test-client.py +++ b/test/cross-test-client.py @@ -23,7 +23,10 @@ from __future__ import print_function, unicode_literals import logging -from gi.repository import GObject as gobject +try: + from gi.repository import GObject as gobject +except ImportError: + raise SystemExit(77) from dbus import ( Array, Boolean, Byte, ByteArray, Double, Int16, Int32, Int64, diff --git a/test/cross-test-server.py b/test/cross-test-server.py index 4098120..4b9ba92 100644 --- a/test/cross-test-server.py +++ b/test/cross-test-server.py @@ -23,7 +23,10 @@ from __future__ import print_function import logging -from gi.repository import GObject as gobject +try: + from gi.repository import GObject as gobject +except ImportError: + raise SystemExit(77) import dbus.glib from dbus import SessionBus diff --git a/test/run-test.sh b/test/run-test.sh index 76bd075..2daecbd 100755 --- a/test/run-test.sh +++ b/test/run-test.sh @@ -26,6 +26,8 @@ export DBUS_FATAL_WARNINGS=1 ulimit -c unlimited +skipped= + function die() { if ! test -z "$DBUS_SESSION_BUS_PID" ; then @@ -97,13 +99,19 @@ echo "running cross-test (for better diagnostics use mjj29's dbus-test)" $PYTHON "$DBUS_TOP_SRCDIR"/test/cross-test-server.py > "$DBUS_TOP_BUILDDIR"/test/cross-server.log& sleep 1 $PYTHON "$DBUS_TOP_SRCDIR"/test/cross-test-client.py > "$DBUS_TOP_BUILDDIR"/test/cross-client.log +e=$? -if grep . "$DBUS_TOP_BUILDDIR"/test/cross-client.log >/dev/null; then +if test $e = 77; then + : # skipped +elif grep . "$DBUS_TOP_BUILDDIR"/test/cross-client.log >/dev/null; then : # OK else die "cross-test client produced no output" fi -if grep . "$DBUS_TOP_BUILDDIR"/test/cross-server.log >/dev/null; then + +if test $e = 77; then + : # skipped +elif grep . "$DBUS_TOP_BUILDDIR"/test/cross-server.log >/dev/null; then : # OK else die "cross-test server produced no output" @@ -120,16 +128,27 @@ else echo " - cross-test server reported no untested functions" fi -echo "running test-client.py" -$PYTHON "$DBUS_TOP_SRCDIR"/test/test-client.py || die "test-client.py failed" -echo "running test-signals.py" -$PYTHON "$DBUS_TOP_SRCDIR"/test/test-signals.py || die "test-signals.py failed" - -echo "running test-p2p.py" -$PYTHON "$DBUS_TOP_SRCDIR"/test/test-p2p.py || die "... failed" +for script in test-client.py test-signals.py test-p2p.py; do + echo "running ${script}" + $PYTHON "$DBUS_TOP_SRCDIR"/test/${script} + e=$? + case "$e" in + (77) + echo "SKIP: ${script} not run, dependencies missing?" + skipped=1 + ;; + (0) + echo "PASS: ${script}" + ;; + (*) + die "${script} failed" + esac +done rm -f "$DBUS_TOP_BUILDDIR"/test/test-service.log rm -f "$DBUS_TOP_BUILDDIR"/test/cross-client.log rm -f "$DBUS_TOP_BUILDDIR"/test/cross-server.log rm -f "$DBUS_TOP_BUILDDIR"/test/monitor.log + +if test -n $skipped; then exit 77; fi exit 0 diff --git a/test/run-with-tmp-session-bus.sh b/test/run-with-tmp-session-bus.sh index 11cd856..48f48b0 100755 --- a/test/run-with-tmp-session-bus.sh +++ b/test/run-with-tmp-session-bus.sh @@ -63,7 +63,19 @@ echo "Started bus pid $DBUS_SESSION_BUS_PID at $DBUS_SESSION_BUS_ADDRESS" >&2 # Execute wrapped script echo "Running: $WRAPPED_SCRIPT $*" >&2 -"$WRAPPED_SCRIPT" "$@" || die "script \"$WRAPPED_SCRIPT\" failed" +"$WRAPPED_SCRIPT" "$@" +e=$? + +case "$e" in + (77) + echo "script \"$WRAPPED_SCRIPT\" skipped" >&2 + ;; + (0) + ;; + (*) + die "script \"$WRAPPED_SCRIPT\" failed" + ;; +esac kill -TERM "$DBUS_SESSION_BUS_PID" \ || die "Message bus vanished! should not have happened" \ diff --git a/test/test-client.py b/test/test-client.py index c73fb4e..1c8d7b4 100755 --- a/test/test-client.py +++ b/test/test-client.py @@ -39,7 +39,11 @@ import dbus.glib import dbus.service from dbus._compat import is_py2, is_py3 -from gi.repository import GObject as gobject + +try: + from gi.repository import GObject as gobject +except ImportError: + raise SystemExit(77) logging.basicConfig() diff --git a/test/test-p2p.py b/test/test-p2p.py index 772c4ba..c029c34 100644 --- a/test/test-p2p.py +++ b/test/test-p2p.py @@ -36,8 +36,11 @@ import dbus.glib import dbus.service from dbus._compat import is_py2 -from gi.repository import GObject as gobject +try: + from gi.repository import GObject as gobject +except ImportError: + raise SystemExit(77) logging.basicConfig() logging.getLogger().setLevel(1) diff --git a/test/test-signals.py b/test/test-signals.py index 3dab2ce..dd9e348 100644 --- a/test/test-signals.py +++ b/test/test-signals.py @@ -36,8 +36,11 @@ import dbus import _dbus_bindings import dbus.glib import dbus.service -from gi.repository import GObject as gobject +try: + from gi.repository import GObject as gobject +except ImportError: + raise SystemExit(77) logging.basicConfig() logging.getLogger().setLevel(1) |