tests: clear out various D-Bus-related variables
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 5 Apr 2013 13:06:09 +0000 (14:06 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 5 Apr 2013 13:06:09 +0000 (14:06 +0100)
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
tests/tools/dbus-session.sh

index a772eac..dddfa04 100644 (file)
@@ -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. */
index 1f805bf..35c09d4 100644 (file)
@@ -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