[pygobject] setup.py: use dbus-run-session for tests if available



commit 4b315835f7006655fe9fa23c02ec6096478114e5
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Tue Feb 6 18:32:13 2018 +0100

    setup.py: use dbus-run-session for tests if available
    
    Like we do with "make check"

 setup.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/setup.py b/setup.py
index 0b174303..5d064914 100755
--- a/setup.py
+++ b/setup.py
@@ -449,18 +449,26 @@ class test(Command):
 
         env = os.environ.copy()
         env.pop("MSYSTEM", None)
-        # TODO: set up a temp bus, disable until then
-        env["DBUS_SESSION_BUS_ADDRESS"] = ""
+
+        pre_args = []
+        try:
+            subprocess.check_call(["dbus-run-session", "--", "true"])
+        except (EnvironmentError, subprocess.CalledProcessError):
+            # Spawning a bus failed, disable dbus instead of inheriting
+            # the user one
+            env["DBUS_SESSION_BUS_ADDRESS"] = ""
+        else:
+            pre_args = ["dbus-run-session", "--"]
 
         tests_dir = os.path.join(get_script_dir(), "tests")
-        subprocess.check_call([
+        subprocess.check_call(pre_args + [
             sys.executable,
             os.path.join(tests_dir, "runtests.py"),
         ], env=env)
 
         if not env.get("TEST_NAMES"):
             env["TEST_NAMES"] = "compat_test_pygtk"
-            subprocess.check_call([
+            subprocess.check_call(pre_args + [
                 sys.executable,
                 os.path.join(tests_dir, "runtests.py"),
             ], env=env)


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