From: Martin Vidner Date: Wed, 8 Jan 2020 12:16:15 +0000 (+0100) Subject: Skip a test if dbus-run-session cannot be run (bsc#1160306) X-Git-Tag: v0.8.8^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8c6e1d9cd9399b6b425fe73dc4f91a99efe6033;p=thirdparty%2Fsnapper.git Skip a test if dbus-run-session cannot be run (bsc#1160306) Fedora 30 has a different dbus implementation --- diff --git a/zypp-plugin/testsuite/1-happy.test b/zypp-plugin/testsuite/1-happy.test index c4622c2e..fec0c8be 100755 --- a/zypp-plugin/testsuite/1-happy.test +++ b/zypp-plugin/testsuite/1-happy.test @@ -4,6 +4,7 @@ set -u . test-helper.sh +dbus_session_setup || { echo "1..0 # SKIP"; exit; } mock_snapperd_setup || { echo "1..0 # SKIP"; exit; } # http://testanything.org/ diff --git a/zypp-plugin/testsuite/2-malformed-xml.test b/zypp-plugin/testsuite/2-malformed-xml.test index bbe03f2e..114b06e9 100755 --- a/zypp-plugin/testsuite/2-malformed-xml.test +++ b/zypp-plugin/testsuite/2-malformed-xml.test @@ -2,11 +2,13 @@ set -e set -u +. test-helper.sh + +dbus_session_setup || { echo "1..0 # SKIP"; exit; } + # http://testanything.org/ echo 1..1 -. test-helper.sh - TEST="1 - It complains about malformed XML in config file" STDERR=$(test_empty_messages | runit zypp-plugin-malformed.conf 2>&1 >/dev/null || :) echo "$STDERR" diff --git a/zypp-plugin/testsuite/3-invalid-xml.test b/zypp-plugin/testsuite/3-invalid-xml.test index 8e18a17e..de98fa66 100755 --- a/zypp-plugin/testsuite/3-invalid-xml.test +++ b/zypp-plugin/testsuite/3-invalid-xml.test @@ -2,11 +2,13 @@ set -e set -u +. test-helper.sh + +dbus_session_setup || { echo "1..0 # SKIP"; exit; } + # http://testanything.org/ echo 1..1 -. test-helper.sh - TEST="1 - It complains about invalid XML in config file" STDERR=$(test_pre_post_snapshots | runit zypp-plugin-invalid.conf 2>&1 >/dev/null || :) echo "$STDERR" diff --git a/zypp-plugin/testsuite/4-badjson.test b/zypp-plugin/testsuite/4-badjson.test index 31724054..f4171b11 100755 --- a/zypp-plugin/testsuite/4-badjson.test +++ b/zypp-plugin/testsuite/4-badjson.test @@ -4,6 +4,8 @@ set -u . test-helper.sh +dbus_session_setup || { echo "1..0 # SKIP"; exit; } + # http://testanything.org/ echo 1..2 diff --git a/zypp-plugin/testsuite/Makefile.am b/zypp-plugin/testsuite/Makefile.am index 3978f33e..ba7523c3 100644 --- a/zypp-plugin/testsuite/Makefile.am +++ b/zypp-plugin/testsuite/Makefile.am @@ -1,5 +1,5 @@ if HAVE_ZYPP -TEST_LOG_DRIVER = dbus-run-session -- $(SHELL) tap-driver.sh +TEST_LOG_DRIVER = $(SHELL) tap-driver.sh check_SCRIPTS = 1-happy.test 2-malformed-xml.test 3-invalid-xml.test 4-badjson.test 99-shell.test noinst_SCRIPTS = mock-snapperd test-helper.sh diff --git a/zypp-plugin/testsuite/test-helper.sh b/zypp-plugin/testsuite/test-helper.sh index 03d53254..89461f67 100644 --- a/zypp-plugin/testsuite/test-helper.sh +++ b/zypp-plugin/testsuite/test-helper.sh @@ -63,6 +63,19 @@ test_pre_del_snapshots() { stomp_message PLUGINEND "" "" } +# snapper needs a DBus connection even if it ends up not using it :-/ +dbus_session_setup() { + if [ -z "${DBUS_SESSION_BUS_ADDRESS-}" ]; then + if ! type -P dbus-run-session >/dev/null; then + echo "dbus-run-session cannot be run, skipping test" + return 77 + else + echo "Restarting test with dbus-run-session" + exec dbus-run-session -- "$0" + fi + fi +} + mock_snapperd_setup() { MOCKDEP=(ruby -e "require 'dbus'") if ! "${MOCKDEP[@]}"; then