[WPE][GTK] Port API test harness to Python3
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: http://svn.webkit.org/repository/webkit/trunk@263743 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 74ea627..d998e67 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -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
diff --git a/Tools/Scripts/run-gtk-tests b/Tools/Scripts/run-gtk-tests
index d39748f..1623980 100755
--- a/Tools/Scripts/run-gtk-tests
+++ b/Tools/Scripts/run-gtk-tests
@@ -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 @@
# 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 @@
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)
diff --git a/Tools/glib/api_test_runner.py b/Tools/glib/api_test_runner.py
index 64a179a..e345a2c 100755
--- a/Tools/glib/api_test_runner.py
+++ b/Tools/glib/api_test_runner.py
@@ -180,13 +180,13 @@
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:
diff --git a/Tools/glib/glib_test_runner.py b/Tools/glib/glib_test_runner.py
index c0e3206..c826897 100644
--- a/Tools/glib/glib_test_runner.py
+++ b/Tools/glib/glib_test_runner.py
@@ -132,7 +132,7 @@
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 @@
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
diff --git a/Tools/jhbuild/jhbuildutils.py b/Tools/jhbuild/jhbuildutils.py
index fd4faea..c2e0818 100644
--- a/Tools/jhbuild/jhbuildutils.py
+++ b/Tools/jhbuild/jhbuildutils.py
@@ -2,7 +2,11 @@
import glob
import os.path
import sys
-import __builtin__
+try:
+ import __builtin__
+except ImportError:
+ import builtins
+ __builtin__ = builtins
top_level_dir = None