[WPE][GTK] Port API test harness to Python3
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jun 2020 12:09:28 +0000 (12:09 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jun 2020 12:09:28 +0000 (12:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=213784

Patch by Philippe Normand <pnormand@igalia.com> on 2020-06-30
Reviewed by Carlos Alberto Lopez Perez.

At least now the import chain starting from run-gtk-tests succeeds when the host Python
version is 3. Within the SDK the harness is still executed under Python2 though, for now.

* Scripts/run-gtk-tests:
(GtkTestRunner._setup_testing_environment):
* glib/api_test_runner.py:
(TestRunner._run_test_qt):
* glib/glib_test_runner.py:
(GLibTestRunner._read_from_pipe):
(GLibTestRunner._read_from_stderr):
* jhbuild/jhbuildutils.py:

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

Tools/ChangeLog
Tools/Scripts/run-gtk-tests
Tools/glib/api_test_runner.py
Tools/glib/glib_test_runner.py
Tools/jhbuild/jhbuildutils.py

index 74ea627..d998e67 100644 (file)
@@ -1,3 +1,22 @@
+2020-06-30  Philippe Normand  <pnormand@igalia.com>
+
+        [WPE][GTK] Port API test harness to Python3
+        https://bugs.webkit.org/show_bug.cgi?id=213784
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        At least now the import chain starting from run-gtk-tests succeeds when the host Python
+        version is 3. Within the SDK the harness is still executed under Python2 though, for now.
+
+        * Scripts/run-gtk-tests:
+        (GtkTestRunner._setup_testing_environment):
+        * glib/api_test_runner.py:
+        (TestRunner._run_test_qt):
+        * glib/glib_test_runner.py:
+        (GLibTestRunner._read_from_pipe):
+        (GLibTestRunner._read_from_stderr):
+        * jhbuild/jhbuildutils.py:
+
 2020-06-30  Jonathan Bedard  <jbedard@apple.com>
 
         [webkitperl] nativeArchitecture() needs to support remote devices
index d39748f..1623980 100755 (executable)
@@ -17,6 +17,7 @@
 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 # Boston, MA 02110-1301, USA.
 
+from __future__ import print_function
 import logging
 import subprocess
 import os
@@ -109,7 +110,7 @@ class GtkTestRunner(TestRunner):
 
         # If we cannot start the accessibility daemons, we can just skip the accessibility tests.
         if not self._start_accessibility_daemons():
-            print "Could not start accessibility bus, so disabling TestWebKitAccessibility"
+            print("Could not start accessibility bus, so disabling TestWebKitAccessibility")
             self._disabled_tests.append("WebKit2Gtk/TestWebKitAccessibility")
 
     def _tear_down_testing_environment(self):
@@ -131,10 +132,10 @@ class GtkTestRunner(TestRunner):
 if __name__ == "__main__":
     flatpakutils.run_in_sandbox_if_available(sys.argv)
     if not flatpakutils.is_sandboxed() and not jhbuildutils.enter_jhbuild_environment_if_available("gtk"):
-        print '***'
-        print '*** Warning: jhbuild environment not present and not running in flatpak.'
-        print '*** Run update-webkitgtk-libs or update-webkit-flatpak before build-webkit to ensure proper testing..'
-        print '***'
+        print('***')
+        print('*** Warning: jhbuild environment not present and not running in flatpak.')
+        print('*** Run update-webkitgtk-libs or update-webkit-flatpak before build-webkit to ensure proper testing..')
+        print('***')
 
     option_parser = optparse.OptionParser(usage='usage: %prog [options] [test...]')
     add_options(option_parser)
index 64a179a..e345a2c 100755 (executable)
@@ -180,13 +180,13 @@ class TestRunner(object):
         try:
             output = subprocess.check_output([test_program, ], stderr=subprocess.STDOUT,
                                              env=env, timeout=self._options.timeout)
-        except subprocess.CalledProcessError, exc:
+        except subprocess.CalledProcessError as exc:
             print(exc.output)
             if exc.returncode > 0:
                 result = "FAIL"
             elif exc.returncode < 0:
                 result = "CRASH"
-        except subprocess.TimeoutExpired, exp:
+        except subprocess.TimeoutExpired as exp:
             result = "TIMEOUT"
             print(exp.output)
         else:
index c0e3206..c826897 100644 (file)
@@ -132,7 +132,7 @@ class GLibTestRunner(object):
         while read_set:
             try:
                 rlist, _, _ = select.select(read_set, [], [])
-            except select.error, e:
+            except select.error as e:
                 if e.args[0] == errno.EINTR:
                     continue
                 raise
@@ -153,7 +153,7 @@ class GLibTestRunner(object):
         while True:
             try:
                 rlist, _, _ = select.select(read_set, [], [], 0)
-            except select.error, e:
+            except select.error as e:
                 if e.args[0] == errno.EINTR:
                     continue
                 raise
index fd4faea..c2e0818 100644 (file)
@@ -2,7 +2,11 @@ import gettext
 import glob
 import os.path
 import sys
-import __builtin__
+try:
+    import __builtin__
+except ImportError:
+    import builtins
+    __builtin__ = builtins
 
 top_level_dir = None