[GTK] run-gtk-tests should use the driver environment for checking the accessibility bus
authorclopez@igalia.com <clopez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Aug 2016 16:36:29 +0000 (16:36 +0000)
committerclopez@igalia.com <clopez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Aug 2016 16:36:29 +0000 (16:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=161149

Reviewed by Carlos Garcia Campos.

Add a new function for waiting for the accesibility bus. It sets
the test environment variables before starting the GLib mainloop.
And restores the previous environment after it has finished.
It also adds a timeout (5 seconds) to abort in case it has not
been able to detect the accesibility bus before the timeout expires.

* Scripts/run-gtk-tests:
(TestRunner):
(TestRunner._wait_for_accessibility_bus):
(TestRunner._wait_for_accessibility_bus.timeout_accessibility_bus):
(TestRunner._start_accessibility_daemons):
(TestRunner._get_tests_from_google_test_suite): Run this command also with the driver test environment.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205017 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/run-gtk-tests

index ab05c05..f86470e 100644 (file)
@@ -1,3 +1,23 @@
+2016-08-26  Carlos Alberto Lopez Perez  <clopez@igalia.com>
+
+        [GTK] run-gtk-tests should use the driver environment for checking the accessibility bus
+        https://bugs.webkit.org/show_bug.cgi?id=161149
+
+        Reviewed by Carlos Garcia Campos.
+
+        Add a new function for waiting for the accesibility bus. It sets
+        the test environment variables before starting the GLib mainloop.
+        And restores the previous environment after it has finished.
+        It also adds a timeout (5 seconds) to abort in case it has not
+        been able to detect the accesibility bus before the timeout expires.
+
+        * Scripts/run-gtk-tests:
+        (TestRunner):
+        (TestRunner._wait_for_accessibility_bus):
+        (TestRunner._wait_for_accessibility_bus.timeout_accessibility_bus):
+        (TestRunner._start_accessibility_daemons):
+        (TestRunner._get_tests_from_google_test_suite): Run this command also with the driver test environment.
+
 2016-08-26  Per Arne Vollan  <pvollan@apple.com>
 
         [Win] Warning fix.
index b198c13..b8811ba 100755 (executable)
@@ -153,6 +153,28 @@ class TestRunner:
 
         return None
 
+    def _wait_for_accessibility_bus(self):
+        def timeout_accessibility_bus():
+            self._accessibility_bus_found = False
+            sys.stderr.write("Timeout waiting for the accesibility bus.\n")
+            sys.stderr.flush()
+            loop.quit()
+        # Backup current environment, and temporally set the test one.
+        oldenv = dict(os.environ)
+        os.environ.clear()
+        os.environ.update(self._test_env)
+        # We spin a main loop until the bus name appears on DBus.
+        self._accessibility_bus_found = True
+        loop = GLib.MainLoop()
+        Gio.bus_watch_name(Gio.BusType.SESSION, 'org.a11y.Bus', Gio.BusNameWatcherFlags.NONE,
+                           lambda *args: loop.quit(), None)
+        GLib.timeout_add_seconds(5, timeout_accessibility_bus)
+        loop.run()
+        # Restore previous environment.
+        os.environ.clear()
+        os.environ.update(oldenv)
+        return self._accessibility_bus_found
+
     def _start_accessibility_daemons(self):
         spi_bus_launcher_path = self._lookup_atspi2_binary('at-spi-bus-launcher')
         spi_registryd_path = self._lookup_atspi2_binary('at-spi2-registryd')
@@ -166,12 +188,11 @@ class TestRunner:
             sys.stderr.flush()
             return False
 
-        # We need to wait until the SPI bus is launched before trying to start the SPI
-        # registry, so we spin a main loop until the bus name appears on DBus.
-        loop = GLib.MainLoop()
-        Gio.bus_watch_name(Gio.BusType.SESSION, 'org.a11y.Bus', Gio.BusNameWatcherFlags.NONE,
-                           lambda *args: loop.quit(), None)
-        loop.run()
+        # We need to wait until the SPI bus is launched before trying to start the SPI registry.
+        if not self._wait_for_accessibility_bus():
+            sys.stderr.write("Failed checking the accessibility bus within D-Bus\n")
+            sys.stderr.flush()
+            return False
 
         try:
             self._spi_registryd = subprocess.Popen([spi_registryd_path], env=self._test_env)
@@ -330,7 +351,7 @@ class TestRunner:
 
     def _get_tests_from_google_test_suite(self, test_program):
         try:
-            output = subprocess.check_output([test_program, '--gtest_list_tests'])
+            output = subprocess.check_output([test_program, '--gtest_list_tests'], env=self._test_env)
         except subprocess.CalledProcessError:
             sys.stderr.write("ERROR: could not list available tests for binary %s.\n" % (test_program))
             sys.stderr.flush()