[folks/tchaik/56-dbus-glib-dep] Only require dbus-glib if needed at buildtime



commit 6330ed031110b73d591ecd1bcbf11dedbca8bea0
Author: Martin Blanchard <tchaik gmx com>
Date:   Sun May 26 20:30:36 2019 +0200

    Only require dbus-glib if needed at buildtime
    
    https://gitlab.gnome.org/GNOME/folks/issues/56

 meson.build                            |  2 +-
 tests/lib/meson.build                  |  1 -
 tests/lib/telepathy/meson.build        |  2 ++
 tests/lib/telepathy/test-case-helper.c | 36 ++++++++++++++++++++++++++++++++++
 tests/lib/telepathy/test-case.vala     | 20 +++++++++----------
 tests/lib/test-case-helper.c           | 13 ------------
 tests/lib/test-case.vala               | 20 -------------------
 7 files changed, 48 insertions(+), 46 deletions(-)
---
diff --git a/meson.build b/meson.build
index 1fd2e348..4c420aca 100644
--- a/meson.build
+++ b/meson.build
@@ -70,7 +70,6 @@ min_eds_version = '3.13.90'
 valac = meson.get_compiler('vala')
 cc = meson.get_compiler('c')
 
-dbus_glib_dep = dependency('dbus-glib-1') # FIXME: get rid of this when our dependencies stop using dbus-1 
(GNOME#696177)
 gee_dep = dependency('gee-0.8')
 gio_dep = dependency('gio-2.0')
 glib_dep = dependency('glib-2.0', version: '>=' + min_glib_version)
@@ -85,6 +84,7 @@ if docs_enabled
 endif
 
 if telepathy_backend_enabled
+  dbus_glib_dep = dependency('dbus-glib-1')  # FIXME: Drop this, see GNOME/folks#24
   telepathy_glib_dep = dependency('telepathy-glib', version: '>= 0.19.9')
 
   if zeitgeist_enabled
diff --git a/tests/lib/meson.build b/tests/lib/meson.build
index 0c3cafea..b61c7db7 100644
--- a/tests/lib/meson.build
+++ b/tests/lib/meson.build
@@ -11,7 +11,6 @@ libfolks_test_sources = [
 
 libfolks_test_deps = [
   build_conf_dep,
-  dbus_glib_dep,
   libfolks_dep,
   folks_test_dbus,
   posix_dep,
diff --git a/tests/lib/telepathy/meson.build b/tests/lib/telepathy/meson.build
index 285267ee..e21a55be 100644
--- a/tests/lib/telepathy/meson.build
+++ b/tests/lib/telepathy/meson.build
@@ -1,9 +1,11 @@
 telepathy_test_lib_sources = [
+  'test-case-helper.c',
   'test-case.vala',
 ]
 
 telepathy_test_lib_deps = [
   common_test_lib_deps,
+  dbus_glib_dep,
   telepathy_test_contactlist_dep,
   telepathy_backendlib_dep,
   libkeyfile_test_dep,
diff --git a/tests/lib/telepathy/test-case-helper.c b/tests/lib/telepathy/test-case-helper.c
new file mode 100644
index 00000000..573a392e
--- /dev/null
+++ b/tests/lib/telepathy/test-case-helper.c
@@ -0,0 +1,36 @@
+ /* test-case-helper.c
+ *
+ * Copyright © 2013 Intel Corporation
+ * Copyright © 2015 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Simon McVittie <simon mcvittie collabora co uk>
+ */
+
+#include <dbus/dbus.h>
+
+void
+_tpf_test_test_case_dbus_1_set_no_exit_on_disconnect (void)
+{
+  DBusConnection *conn = dbus_bus_get (DBUS_BUS_SESSION, NULL);
+
+  if (conn != NULL)
+    {
+      dbus_connection_set_exit_on_disconnect (conn, FALSE);
+      dbus_connection_unref (conn);
+    }
+}
diff --git a/tests/lib/telepathy/test-case.vala b/tests/lib/telepathy/test-case.vala
index 7256e637..d00505fc 100644
--- a/tests/lib/telepathy/test-case.vala
+++ b/tests/lib/telepathy/test-case.vala
@@ -107,17 +107,6 @@ public class TpfTest.TestCase : Folks.TestCase
       this.create_tp_backend ();
     }
 
-  /**
-   * This test does use libdbus, via telepathy-glib.
-   */
-  public override bool uses_dbus_1
-    {
-      get
-        {
-          return true;
-        }
-    }
-
   /**
    * Virtual method to create the keyfile backend. Currently called by
    * the constructor (once per process), but might move into set_up() later.
@@ -229,6 +218,15 @@ public class TpfTest.TestCase : Folks.TestCase
 
       base.tear_down ();
     }
+
+  internal extern static void _dbus_1_set_no_exit_on_disconnect ();
+
+  public override void final_tear_down ()
+    {
+      TestCase._dbus_1_set_no_exit_on_disconnect ();
+
+      base.final_tear_down ();
+    }
 }
 
 /**
diff --git a/tests/lib/test-case-helper.c b/tests/lib/test-case-helper.c
index a4bdb7cf..33445377 100644
--- a/tests/lib/test-case-helper.c
+++ b/tests/lib/test-case-helper.c
@@ -25,7 +25,6 @@
 
 #include <glib.h>
 #include <glib-object.h>
-#include <dbus/dbus.h>
 
 typedef struct {
     gpointer self;
@@ -105,15 +104,3 @@ folks_test_case_add_test_helper (FolksTestCase *self,
       folks_test_case_weak_method_test,
       folks_test_case_weak_method_teardown);
 }
-
-void
-_folks_test_case_dbus_1_set_no_exit_on_disconnect (void)
-{
-  DBusConnection *conn = dbus_bus_get (DBUS_BUS_SESSION, NULL);
-
-  if (conn != NULL)
-    {
-      dbus_connection_set_exit_on_disconnect (conn, FALSE);
-      dbus_connection_unref (conn);
-    }
-}
diff --git a/tests/lib/test-case.vala b/tests/lib/test-case.vala
index 86510b9b..d4d3bdd2 100644
--- a/tests/lib/test-case.vala
+++ b/tests/lib/test-case.vala
@@ -275,21 +275,6 @@ public abstract class Folks.TestCase : Object
    */
   public Folks.TestDBus? test_system_dbus = null;
 
-  /**
-   * If true, libraries involved in this test use dbus-1 (or dbus-glib-1)
-   * so we need to turn off its exit-on-disconnect feature.
-   *
-   * FIXME: when our dependencies stop needing this, this whole feature
-   * can be removed (GNOME#696177).
-   */
-  public virtual bool uses_dbus_1
-    {
-      get
-        {
-          return false;
-        }
-    }
-
   /**
    * Start the temporary D-Bus session.
    *
@@ -381,8 +366,6 @@ public abstract class Folks.TestCase : Object
       /* assert (TestUtils.main_context_is_empty ()); */
     }
 
-  internal extern static void _dbus_1_set_no_exit_on_disconnect ();
-
   /**
    * Clean up after all tests. If you have more than one test case, this
    * will be called once, the last time only. It should undo the
@@ -398,9 +381,6 @@ public abstract class Folks.TestCase : Object
     {
       TestCase.in_final_tear_down = true;
 
-      if (this.uses_dbus_1)
-        TestCase._dbus_1_set_no_exit_on_disconnect ();
-
       /* FIXME: The EDS tests randomly fail due to race conditions in tearing
        * down the GTestDBus. So avoid that completely, because I’m sick of not
        * being able to release while waiting for a solution to be hammered out


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]