]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
Skip a test if dbus-run-session cannot be run (bsc#1160306)
authorMartin Vidner <mvidner@suse.cz>
Wed, 8 Jan 2020 12:16:15 +0000 (13:16 +0100)
committerMartin Vidner <mvidner@suse.cz>
Wed, 8 Jan 2020 12:45:37 +0000 (13:45 +0100)
Fedora 30 has a different dbus implementation

zypp-plugin/testsuite/1-happy.test
zypp-plugin/testsuite/2-malformed-xml.test
zypp-plugin/testsuite/3-invalid-xml.test
zypp-plugin/testsuite/4-badjson.test
zypp-plugin/testsuite/Makefile.am
zypp-plugin/testsuite/test-helper.sh

index c4622c2e185cbf78d74acded6d35c98412e3f5be..fec0c8be5e88261a8a402874631aa9327a91b829 100755 (executable)
@@ -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/
index bbe03f2e07fea5c6f10bd424d6ea06c2833050d5..114b06e948545638a686cff4ccf5205438a01752 100755 (executable)
@@ -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"
index 8e18a17ec75caaa6a2aab926880794f80b02cfdd..de98fa66b01a3514d23febdcdb10e8eddced993d 100755 (executable)
@@ -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"
index 317240546eec993af76003acd301ae282c59a644..f4171b11acf88c68b03eac0ec9d7e75578c28e3a 100755 (executable)
@@ -4,6 +4,8 @@ set -u
 
 . test-helper.sh
 
+dbus_session_setup  || { echo "1..0 # SKIP"; exit; }
+
 # http://testanything.org/
 echo 1..2
 
index 3978f33efb4b3298d3afecb99865ae92f04068c6..ba7523c39522872fb9435bd7086bceb5354dd1c9 100644 (file)
@@ -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
index 03d532546e3d21cc5dd2a10c421e28b920cd6247..89461f670ce135a6f25f3f37c2b3c06593e7063f 100644 (file)
@@ -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