[folks] tests: clear out various D-Bus-related variables



commit 13220546e01844d7b879dd11eb82a0254ab0108d
Author: Simon McVittie <simon mcvittie collabora co uk>
Date:   Fri Apr 5 14:06:09 2013 +0100

    tests: clear out various D-Bus-related variables
    
    The actual terminal in gnome-terminal 3.8 is an activatable service,
    so it has DBUS_STARTER_ADDRESS in its environment. telepathy-glib prefers
    DBUS_STARTER_ADDRESS over DBUS_SESSION_BUS_ADDRESS, but GTestDBus
    doesn't clear or set the former, only the latter; so we end up trying to
    use the real bus when run under a recent gnome-terminal.
    
    See also <https://bugs.freedesktop.org/show_bug.cgi?id=63119>.
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=697261
    Reviewed-by: Philip Withnall <philip tecnocode co uk>
    [added FIXME comment about #697348]
    Signed-off-by: Simon McVittie <simon mcvittie collabora co uk>

 tests/lib/test-case.vala    |   11 +++++++++++
 tests/tools/dbus-session.sh |    5 +++++
 2 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/tests/lib/test-case.vala b/tests/lib/test-case.vala
index a772eac..dddfa04 100644
--- a/tests/lib/test-case.vala
+++ b/tests/lib/test-case.vala
@@ -45,6 +45,12 @@ public abstract class Folks.TestCase : Object
        * and if not it's pointless: all we need is the local filesystem. */
       Environment.set_variable ("GIO_USE_VFS", "local", true);
 
+      /* If run from gnome-terminal 3.8 or a similar activatable service,
+       * forget the "starter bus" in favour of DBUS_SESSION_BUS_ADDRESS.
+       * FIXME: GTestDBus should do this for us (GNOME #697348). */
+      Environment.unset_variable ("DBUS_STARTER_ADDRESS");
+      Environment.unset_variable ("DBUS_STARTER_BUS_TYPE");
+
       LogAdaptor.set_up ();
       this._suite = new GLib.TestSuite (name);
 
@@ -207,11 +213,16 @@ public abstract class Folks.TestCase : Object
    */
   public virtual void private_bus_up ()
     {
+      Environment.unset_variable ("DBUS_SESSION_BUS_ADDRESS");
+      Environment.unset_variable ("DBUS_SESSION_BUS_PID");
+
       this.test_dbus = new GLib.TestDBus (GLib.TestDBusFlags.NONE);
       var test_dbus = (!) this.test_dbus;
 
       test_dbus.up ();
 
+      assert (Environment.get_variable ("DBUS_SESSION_BUS_ADDRESS") != null);
+
       /* Tell subprocesses that we're running in a private D-Bus
        * session, so certain operations that would otherwise be dangerous
        * are OK. */
diff --git a/tests/tools/dbus-session.sh b/tests/tools/dbus-session.sh
index 1f805bf..35c09d4 100644
--- a/tests/tools/dbus-session.sh
+++ b/tests/tools/dbus-session.sh
@@ -24,6 +24,11 @@ dbus_config_file=""
 # verbose: 0 for off and 1 for on
 #
 dbus_init () {
+    unset DBUS_SESSION_BUS_ADDRESS
+    unset DBUS_SESSION_BUS_PID
+    unset DBUS_STARTER_ADDRESS
+    unset DBUS_STARTER_BUS_TYPE
+
     exec 5> $dbus_me-$$.address
     exec 6> $dbus_me-$$.pid
     dbus_verbose=$1


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