Submitted By:            Xi Ruoyao <xry111 at xry111.site>
Date:                    2024-01-21
Initial Package Version: 45.1
Upstream Status:         Applied
Origin:                  Upstream (MR 350)
Description:             Fixes test failures with dbusmock >= 0.30.0.

From 6e55c3cd64a49a446a3ba2f89b2fb16a67b21af1 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Sun, 14 Jan 2024 11:37:09 +0100
Subject: [PATCH] tests: Start and terminate D-Bus orderly

Start the dconf service after starting D-Bus, and ignore the
SIGTERM indirectly received when terminating the dedicated
D-Bus service.

Fixes tests/CI with recent python3-dbusmock present in F39.
---
 tests/gsdtestcase.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/tests/gsdtestcase.py b/tests/gsdtestcase.py
index 51f18250f..ee1307dfc 100644
--- a/tests/gsdtestcase.py
+++ b/tests/gsdtestcase.py
@@ -76,10 +76,6 @@ class GSDTestCase(X11SessionTestCase):
         os.environ['XDG_DATA_HOME'] = os.path.join(klass.workdir, 'data')
         os.environ['XDG_RUNTIME_DIR'] = os.path.join(klass.workdir, 'runtime')
 
-        # Make dconf discoverable (requires newer dbusmock API, is not needed otherwise)
-        if hasattr(klass, 'enable_service'):
-            klass.enable_service('ca.desrt.dconf')
-
         # Copy gschema file into XDG_DATA_HOME
         gschema_dir = os.path.join(os.environ['XDG_DATA_HOME'], 'glib-2.0', 'schemas')
         os.makedirs(gschema_dir)
@@ -92,6 +88,10 @@ class GSDTestCase(X11SessionTestCase):
         # Starts Xvfb and dbus busses
         X11SessionTestCase.setUpClass()
 
+        # Make dconf discoverable (requires newer dbusmock API, is not needed otherwise)
+        if hasattr(klass, 'enable_service'):
+            klass.enable_service('ca.desrt.dconf')
+
         klass.system_bus_con = klass.get_dbus(True)
         klass.session_bus_con = klass.get_dbus(False)
         klass.addClassCleanup(klass.system_bus_con.close)
@@ -116,6 +116,15 @@ class GSDTestCase(X11SessionTestCase):
             raise KeyboardInterrupt()
         signal.signal(signal.SIGTERM, r)
 
+    @classmethod
+    def tearDownClass(klass):
+        #if hasattr(klass, 'disable_service'):
+        #    klass.disable_service('ca.desrt.dconf')
+
+        signal.signal(signal.SIGTERM, signal.SIG_IGN)
+        X11SessionTestCase.tearDownClass()
+        signal.signal(signal.SIGTERM, signal.SIG_DFL)
+
     def setUp(self):
         self.daemon_death_expected = False
 
-- 
GitLab

