Python 3: Add support in webkitpy.port
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2019 21:56:56 +0000 (21:56 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2019 21:56:56 +0000 (21:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203489

Reviewed by Dewei Zhu.

* Scripts/test-webkitpy-python3: Add webkitpy.port.
* Scripts/webkitpy/common/newstringio.py: Removed.
* Scripts/webkitpy/common/newstringio_unittest.py: Removed.
* Scripts/webkitpy/common/system/executive_mock.py:
(MockProcess.__init__): Ensure that stdout and stderr are byte arrays.
* Scripts/webkitpy/common/version.py:
(Version.__hash__): Add hash function for Version objects.
* Scripts/webkitpy/port/base.py:
(Port.default_baseline_search_path): Convert list to map.
(Port.diff_text): Decode for the native string type.
(Port.skipped_perf_tests): Convert filter to list.
(Port._run_script): No need to decode strings in Python 3, even if decode_output is set.
(Port.diff_text.to_raw_bytes): Deleted.
* Scripts/webkitpy/port/base_unittest.py:
(cmp): Add cmp function for Python 3 comparisons.
(PortTest.test_diff_text): Do not escape spaces.
(PortTest.test_parse_reftest_list): Write to test file explicitly.
* Scripts/webkitpy/port/builders_unittest.py: Use full import path.
* Scripts/webkitpy/port/config_standalone.py: script_dir was refering to Tools,
not Tools/Scripts.
* Scripts/webkitpy/port/config_unittest.py: Use full import path.
* Scripts/webkitpy/port/darwin.py:
(DarwinPort.show_results_html_file): Use os.devnull directly.
* Scripts/webkitpy/port/driver_unittest.py:
(DriverTest.test_read_base64_block): Explicitly compare against byte array.
(DriverTest.test_setup_environ_base_vars): Convert iterators to lists.
* Scripts/webkitpy/port/factory.py:
(PortFactory.get.in): Imports need to use the full import path.
* Scripts/webkitpy/port/gtk.py:
(GtkPort.default_baseline_search_path): Convert map to list.
* Scripts/webkitpy/port/leakdetector.py:
(LeakDetector._parse_leaks_output): Search byte array with byte array.
* Scripts/webkitpy/port/leakdetector_valgrind.py:
(ValgrindError.__str__): Split byte array with byte array.
(ValgrindError.error_hash): Correct regex.
(LeakDetectorValgrind._parse_leaks_output): Convert bytes to string.
(LeakDetectorValgrind.parse_and_print_leaks_detail): Standardize Python 2 and 3 sorting order.
* Scripts/webkitpy/port/leakdetector_valgrind_unittest.py: Make unit tests Python 3 compatible.
* Scripts/webkitpy/port/linux_get_crash_log.py:
(GDBCrashLogGenerator._get_trace_from_systemd): Modernize exception handling.
(GDBCrashLogGenerator.generate_crash_log): No need to decode strings in Python 3.
* Scripts/webkitpy/port/mac.py:
(MacPort.start_helper): is_ready will be a byte array.
(MacPort.stop_helper): stdin will be a byte array.
* Scripts/webkitpy/port/mock_drt_unittest.py:
(MockDRTTest.assertTest): Use unicode compatible StringIO objects.
(MockDRTTest.test_main): Ditto.
* Scripts/webkitpy/port/port_testcase.py:
(bind_mock_apple_additions.MockAppleAdditions.version_name_mapping): Use items instead of iteritems.
(PortTestCase.test_expectations_ordering): Convert iterator to list.
(PortTestCase.test_test_expectations): Ditto.
* Scripts/webkitpy/port/win.py:
(WinPort.__init__):
(WinPort.default_baseline_search_path): Convert map to list.
(WinPort.test_search_path): Ditto.
(WinPort.setup_crash_log_saving): Use items instead of iteritems.
(WinPort.restore_crash_log_saving): Ditto.
(WinPort.prevent_error_dialogs): Ditto.
(WinPort.allow_error_dialogs): Ditto.
(WinCairoPort.default_baseline_search_path): Convert map to list.
(WinCairoPort._port_specific_expectations_files): Ditto.
(FTWPort.default_baseline_search_path): Ditto.
(FTWPort._port_specific_expectations_files): Ditto.
* Scripts/webkitpy/port/win_unittest.py: Ditto.
(WinPortTest._assert_search_path): Ditto.
* Scripts/webkitpy/port/wpe.py:
(WPEPort.default_baseline_search_path): Convert map to list.
(WPEPort._port_specific_expectations_files): Ditto.

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

25 files changed:
Tools/ChangeLog
Tools/Scripts/test-webkitpy-python3
Tools/Scripts/webkitpy/common/newstringio.py [deleted file]
Tools/Scripts/webkitpy/common/newstringio_unittest.py [deleted file]
Tools/Scripts/webkitpy/common/system/executive_mock.py
Tools/Scripts/webkitpy/common/version.py
Tools/Scripts/webkitpy/port/base.py
Tools/Scripts/webkitpy/port/base_unittest.py
Tools/Scripts/webkitpy/port/builders_unittest.py
Tools/Scripts/webkitpy/port/config_standalone.py
Tools/Scripts/webkitpy/port/config_unittest.py
Tools/Scripts/webkitpy/port/darwin.py
Tools/Scripts/webkitpy/port/driver_unittest.py
Tools/Scripts/webkitpy/port/factory.py
Tools/Scripts/webkitpy/port/gtk.py
Tools/Scripts/webkitpy/port/leakdetector.py
Tools/Scripts/webkitpy/port/leakdetector_valgrind.py
Tools/Scripts/webkitpy/port/leakdetector_valgrind_unittest.py
Tools/Scripts/webkitpy/port/linux_get_crash_log.py
Tools/Scripts/webkitpy/port/mac.py
Tools/Scripts/webkitpy/port/mock_drt_unittest.py
Tools/Scripts/webkitpy/port/port_testcase.py
Tools/Scripts/webkitpy/port/win.py
Tools/Scripts/webkitpy/port/win_unittest.py
Tools/Scripts/webkitpy/port/wpe.py

index a607c31..c105c6b 100644 (file)
@@ -1,5 +1,81 @@
 2019-10-30  Jonathan Bedard  <jbedard@apple.com>
 
+        Python 3: Add support in webkitpy.port
+        https://bugs.webkit.org/show_bug.cgi?id=203489
+
+        Reviewed by Dewei Zhu.
+
+        * Scripts/test-webkitpy-python3: Add webkitpy.port.
+        * Scripts/webkitpy/common/newstringio.py: Removed.
+        * Scripts/webkitpy/common/newstringio_unittest.py: Removed.
+        * Scripts/webkitpy/common/system/executive_mock.py:
+        (MockProcess.__init__): Ensure that stdout and stderr are byte arrays.
+        * Scripts/webkitpy/common/version.py:
+        (Version.__hash__): Add hash function for Version objects.
+        * Scripts/webkitpy/port/base.py:
+        (Port.default_baseline_search_path): Convert list to map.
+        (Port.diff_text): Decode for the native string type.
+        (Port.skipped_perf_tests): Convert filter to list.
+        (Port._run_script): No need to decode strings in Python 3, even if decode_output is set.
+        (Port.diff_text.to_raw_bytes): Deleted.
+        * Scripts/webkitpy/port/base_unittest.py:
+        (cmp): Add cmp function for Python 3 comparisons.
+        (PortTest.test_diff_text): Do not escape spaces.
+        (PortTest.test_parse_reftest_list): Write to test file explicitly.
+        * Scripts/webkitpy/port/builders_unittest.py: Use full import path.
+        * Scripts/webkitpy/port/config_standalone.py: script_dir was refering to Tools,
+        not Tools/Scripts.
+        * Scripts/webkitpy/port/config_unittest.py: Use full import path.
+        * Scripts/webkitpy/port/darwin.py:
+        (DarwinPort.show_results_html_file): Use os.devnull directly.
+        * Scripts/webkitpy/port/driver_unittest.py:
+        (DriverTest.test_read_base64_block): Explicitly compare against byte array.
+        (DriverTest.test_setup_environ_base_vars): Convert iterators to lists.
+        * Scripts/webkitpy/port/factory.py:
+        (PortFactory.get.in): Imports need to use the full import path.
+        * Scripts/webkitpy/port/gtk.py:
+        (GtkPort.default_baseline_search_path): Convert map to list.
+        * Scripts/webkitpy/port/leakdetector.py:
+        (LeakDetector._parse_leaks_output): Search byte array with byte array.
+        * Scripts/webkitpy/port/leakdetector_valgrind.py:
+        (ValgrindError.__str__): Split byte array with byte array.
+        (ValgrindError.error_hash): Correct regex.
+        (LeakDetectorValgrind._parse_leaks_output): Convert bytes to string.
+        (LeakDetectorValgrind.parse_and_print_leaks_detail): Standardize Python 2 and 3 sorting order.
+        * Scripts/webkitpy/port/leakdetector_valgrind_unittest.py: Make unit tests Python 3 compatible.
+        * Scripts/webkitpy/port/linux_get_crash_log.py:
+        (GDBCrashLogGenerator._get_trace_from_systemd): Modernize exception handling.
+        (GDBCrashLogGenerator.generate_crash_log): No need to decode strings in Python 3.
+        * Scripts/webkitpy/port/mac.py:
+        (MacPort.start_helper): is_ready will be a byte array.
+        (MacPort.stop_helper): stdin will be a byte array.
+        * Scripts/webkitpy/port/mock_drt_unittest.py:
+        (MockDRTTest.assertTest): Use unicode compatible StringIO objects.
+        (MockDRTTest.test_main): Ditto.
+        * Scripts/webkitpy/port/port_testcase.py:
+        (bind_mock_apple_additions.MockAppleAdditions.version_name_mapping): Use items instead of iteritems.
+        (PortTestCase.test_expectations_ordering): Convert iterator to list.
+        (PortTestCase.test_test_expectations): Ditto.
+        * Scripts/webkitpy/port/win.py:
+        (WinPort.__init__):
+        (WinPort.default_baseline_search_path): Convert map to list.
+        (WinPort.test_search_path): Ditto.
+        (WinPort.setup_crash_log_saving): Use items instead of iteritems.
+        (WinPort.restore_crash_log_saving): Ditto.
+        (WinPort.prevent_error_dialogs): Ditto.
+        (WinPort.allow_error_dialogs): Ditto.
+        (WinCairoPort.default_baseline_search_path): Convert map to list.
+        (WinCairoPort._port_specific_expectations_files): Ditto.
+        (FTWPort.default_baseline_search_path): Ditto.
+        (FTWPort._port_specific_expectations_files): Ditto.
+        * Scripts/webkitpy/port/win_unittest.py: Ditto.
+        (WinPortTest._assert_search_path): Ditto.
+        * Scripts/webkitpy/port/wpe.py:
+        (WPEPort.default_baseline_search_path): Convert map to list.
+        (WPEPort._port_specific_expectations_files): Ditto.
+
+2019-10-30  Jonathan Bedard  <jbedard@apple.com>
+
         Simulator testers are filling up
         https://bugs.webkit.org/show_bug.cgi?id=203056
         <rdar://problem/56344905>
index de7e5a4..58c20fe 100755 (executable)
@@ -40,6 +40,7 @@ PYTHON3_COMPATIBLE_DIRECTORIES = [
   'webkitpy.common.thread',
   'webkitpy.common.net',
   'webkitpy.common.watchlist',
+  'webkitpy.port',
   'webkitpy.results',
   'webkitpy.xcode',
 ]
diff --git a/Tools/Scripts/webkitpy/common/newstringio.py b/Tools/Scripts/webkitpy/common/newstringio.py
deleted file mode 100644 (file)
index 7748d50..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright (C) 2010 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-"""'with'-compliant StringIO implementation."""
-
-import StringIO as OldStringIO
-
-
-class StringIO(OldStringIO.StringIO):
-    def __enter__(self):
-        return self
-
-    def __exit__(self, type, value, traceback):
-        pass
diff --git a/Tools/Scripts/webkitpy/common/newstringio_unittest.py b/Tools/Scripts/webkitpy/common/newstringio_unittest.py
deleted file mode 100644 (file)
index 2a1dba8..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright (C) 2010 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-"""Unit tests for newstringio module."""
-
-import unittest
-
-import newstringio
-
-
-class NewStringIOTest(unittest.TestCase):
-    def test_with(self):
-        with newstringio.StringIO("foo") as f:
-            contents = f.read()
-        self.assertEqual(contents, "foo")
index fc71271..0aa514f 100644 (file)
@@ -29,7 +29,7 @@
 import logging
 import os
 
-from webkitpy.common.unicode_compatibility import BytesIO, unicode
+from webkitpy.common.unicode_compatibility import BytesIO, encode_if_necessary, unicode
 from webkitpy.common.system.executive import ScriptError
 
 _log = logging.getLogger(__name__)
@@ -38,8 +38,8 @@ _log = logging.getLogger(__name__)
 class MockProcess(object):
     def __init__(self, stdout='MOCK STDOUT\n', stderr=''):
         self.pid = 42
-        self.stdout = BytesIO(stdout)
-        self.stderr = BytesIO(stderr)
+        self.stdout = BytesIO(encode_if_necessary(stdout))
+        self.stderr = BytesIO(encode_if_necessary(stderr))
         self.stdin = BytesIO()
         self.returncode = 0
         self._is_running = False
index 3f13d4d..62c76f6 100644 (file)
@@ -116,6 +116,9 @@ class Version(object):
             result += '.{}'.format(self[i + 1])
         return result
 
+    def __hash__(self):
+        return hash(str(self))
+
     def __cmp__(self, other):
         if other is None:
             return 1
index e251cb8..6800b17 100644 (file)
@@ -51,6 +51,7 @@ from webkitpy.common.system.executive import ScriptError
 from webkitpy.common.version_name_map import PUBLIC_TABLE, INTERNAL_TABLE, VersionNameMap
 from webkitpy.common.wavediff import WaveDiff
 from webkitpy.common.webkit_finder import WebKitFinder
+from webkitpy.common.unicode_compatibility import encode_for, encode_if_necessary, decode_for
 from webkitpy.layout_tests.models.test_configuration import TestConfiguration
 from webkitpy.port import config as port_config
 from webkitpy.port import driver
@@ -222,7 +223,7 @@ class Port(object):
         search_paths.append(self.name())
         if self.name() != self.port_name:
             search_paths.append(self.port_name)
-        return map(self._webkit_baseline_path, search_paths)
+        return list(map(self._webkit_baseline_path, search_paths))
 
     @memoized
     def _compare_baseline(self):
@@ -340,16 +341,8 @@ class Port(object):
     def diff_text(self, expected_text, actual_text, expected_filename, actual_filename):
         """Returns a string containing the diff of the two text strings
         in 'unified diff' format."""
-
-        # The filenames show up in the diff output, make sure they're
-        # raw bytes and not unicode, so that they don't trigger join()
-        # trying to decode the input.
-        def to_raw_bytes(string_value):
-            if isinstance(string_value, unicode):
-                return string_value.encode('utf-8')
-            return string_value
-        expected_filename = to_raw_bytes(expected_filename)
-        actual_filename = to_raw_bytes(actual_filename)
+        expected_filename = decode_for(encode_if_necessary(expected_filename), str)
+        actual_filename = decode_for(encode_if_necessary(actual_filename), str)
         diff = difflib.unified_diff(expected_text.splitlines(True),
                                     actual_text.splitlines(True),
                                     expected_filename,
@@ -358,7 +351,7 @@ class Port(object):
         for line in diff:
             result += line
             if not line.endswith('\n'):
-                result += '\n\ No newline at end of file\n'
+                result += '\n No newline at end of file\n'
         return result
 
     def check_for_leaks(self, process_name, process_id):
@@ -764,7 +757,7 @@ class Port(object):
             if not match:
                 _log.error("Syntax error at line %d in %s: %s" % (line_number + 1, filename, line))
             else:
-                platform_names = filter(lambda token: token, match.group('platforms').lower().split(' ')) if match.group('platforms') else []
+                platform_names = list(filter(lambda token: token, match.group('platforms').lower().split(' '))) if match.group('platforms') else []
                 test_name = match.group('test')
                 if test_name and (not platform_names or self.port_name in platform_names or self._name in platform_names):
                     tests_to_skip.append(test_name)
@@ -1492,7 +1485,7 @@ class Port(object):
         if args:
             run_script_command.extend(args)
         output = self._executive.run_command(run_script_command, cwd=self.webkit_base(), decode_output=decode_output, env=env)
-        _log.debug('Output of %s:\n%s' % (run_script_command, output.encode('utf-8') if decode_output else output))
+        _log.debug('Output of %s:\n%s' % (run_script_command, encode_for(output, str) if decode_output else output))
         return output
 
     def _build_driver(self):
index 16854fa..5df1cc5 100644 (file)
@@ -41,6 +41,9 @@ from webkitpy.port import Port
 from webkitpy.port.test import add_unit_tests_to_mock_filesystem, TestPort
 
 
+def cmp(a, b):
+    return (a > b) - (a < b)
+
 class PortTest(unittest.TestCase):
     def make_port(self, executive=None, with_tests=False, port_name=None, **kwargs):
         host = MockSystemHost()
@@ -105,7 +108,7 @@ class PortTest(unittest.TestCase):
 
         t1 = "A\n\nB"
         t2 = "A\n\nB\n\n\n"
-        t3 = "--- exp.txt\n+++ act.txt\n@@ -1,3 +1,5 @@\n A\n \n-B\n\ No newline at end of file\n+B\n+\n+\n"
+        t3 = "--- exp.txt\n+++ act.txt\n@@ -1,3 +1,5 @@\n A\n \n-B\n No newline at end of file\n+B\n+\n+\n"
         self.assertEqual(t3, port.diff_text(t1, t2, 'exp.txt', 'act.txt'))
 
         # And make sure we actually get diff output.
@@ -288,13 +291,18 @@ class PortTest(unittest.TestCase):
 
     def test_parse_reftest_list(self):
         port = self.make_port(with_tests=True)
-        port.host.filesystem.files['bar/reftest.list'] = "\n".join(["== test.html test-ref.html",
-        "",
-        "# some comment",
-        "!= test-2.html test-notref.html # more comments",
-        "== test-3.html test-ref.html",
-        "== test-3.html test-ref2.html",
-        "!= test-3.html test-notref.html"])
+        port.host.filesystem.write_text_file(
+            'bar/reftest.list',
+            "\n".join([
+                "== test.html test-ref.html",
+                "",
+                "# some comment",
+                "!= test-2.html test-notref.html # more comments",
+                "== test-3.html test-ref.html",
+                "== test-3.html test-ref2.html",
+                "!= test-3.html test-notref.html",
+            ]),
+        )
 
         reftest_list = Port._parse_reftest_list(port.host.filesystem, 'bar')
         self.assertEqual(reftest_list, {'bar/test.html': [('==', 'bar/test-ref.html')],
index 5997f54..05f4acd 100644 (file)
@@ -26,8 +26,8 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-import builders
 import unittest
+import webkitpy.port.builders as builders
 
 
 class BuildersTest(unittest.TestCase):
index db2d4b8..09fae24 100644 (file)
@@ -39,7 +39,7 @@ import sys
 # Ensure that webkitpy is in PYTHONPATH.
 this_dir = os.path.abspath(sys.path[0])
 up = os.path.dirname
-script_dir = up(up(up(this_dir)))
+script_dir = up(up(this_dir))
 if script_dir not in sys.path:
     sys.path.append(script_dir)
 
index 68118b3..6311ebe 100644 (file)
@@ -37,7 +37,7 @@ from webkitpy.common.system.filesystem_mock import MockFileSystem
 from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.common.webkit_finder import WebKitFinder
 
-import config
+import webkitpy.port.config as config
 
 
 class ConfigTest(unittest.TestCase):
index f047434..9502f6e 100644 (file)
@@ -85,7 +85,7 @@ class DarwinPort(ApplePort):
         # to exit and we want the output to show up on stdout in case there are errors
         # launching the browser.
         self._executive.popen([self.path_to_script('run-safari')] + self._arguments_for_configuration() + ['--no-saved-state', '-NSOpen', results_filename],
-            cwd=self.webkit_base(), stdout=file(os.devnull), stderr=file(os.devnull))
+            cwd=self.webkit_base(), stdout=os.devnull, stderr=os.devnull)
 
     @memoized
     def path_to_crash_logs(self):
index 09e5c90..0dded7c 100644 (file)
@@ -202,7 +202,7 @@ class DriverTest(unittest.TestCase):
         self.assertEqual(content_block.content_hash, 'actual')
         self.assertEqual(content_block.encoding, 'base64')
         self.assertEqual(content_block.content, 'MTIzNDU2NzgK')
-        self.assertEqual(content_block.decoded_content, '12345678\n')
+        self.assertEqual(content_block.decoded_content, b'12345678\n')
 
     def test_no_timeout(self):
         port = TestWebKitPort()
@@ -368,7 +368,7 @@ class DriverTest(unittest.TestCase):
                           'WAYLAND_DISPLAY': 'wayland-0',
                           'WAYLAND_SOCKET': 'wayland-socket-0',
                           'GDK_BACKEND': 'x11'}
-        environment_user = dict(environ_keep_yes.items() + environ_keep_no.items())
+        environment_user = dict(list(environ_keep_yes.items()) + list(environ_keep_no.items()))
         with patch('os.environ', environment_user):
             port = self.make_port()
             driver = Driver(port, None, pixel_tests=False)
index 28dbf71..d063a72 100644 (file)
@@ -136,9 +136,10 @@ class PortFactory(object):
         classes = []
         for port_class in self.PORT_CLASSES:
             module_name, class_name = port_class.rsplit('.', 1)
-            module = __import__(module_name, globals(), locals(), [], -1)
-            cls = module.__dict__[class_name]
-            classes.append(cls)
+            module = __import__('webkitpy.port.{}'.format(module_name), globals(), locals(), [], 0)
+            cls = module.__dict__.get('port').__dict__.get(module_name).__dict__.get(class_name)
+            if cls:
+                classes.append(cls)
         if config.apple_additions() and hasattr(config.apple_additions(), 'ports'):
             classes += config.apple_additions().ports()
 
index 6cde88f..e6f80f9 100644 (file)
@@ -211,7 +211,7 @@ class GtkPort(Port):
         return search_paths
 
     def default_baseline_search_path(self, **kwargs):
-        return map(self._webkit_baseline_path, self._search_paths())
+        return list(map(self._webkit_baseline_path, self._search_paths()))
 
     def _port_specific_expectations_files(self, **kwargs):
         return [self._filesystem.join(self._webkit_baseline_path(p), 'TestExpectations') for p in reversed(self._search_paths())]
index 328f47d..29af1ef 100644 (file)
@@ -31,6 +31,7 @@ import logging
 import re
 
 from webkitpy.common.system.executive import ScriptError
+from webkitpy.common.unicode_compatibility import encode_if_necessary
 
 _log = logging.getLogger(__name__)
 
@@ -78,8 +79,9 @@ class LeakDetector(object):
     def _parse_leaks_output(self, leaks_output):
         if not leaks_output:
             return 0, 0, 0
-        _, count, bytes = re.search(r'Process (?P<pid>\d+): (?P<count>\d+) leaks? for (?P<bytes>\d+) total', leaks_output).groups()
-        excluded_match = re.search(r'(?P<excluded>\d+) leaks? excluded', leaks_output)
+        leaks_output = encode_if_necessary(leaks_output)
+        _, count, bytes = re.search(b'Process (?P<pid>\\d+): (?P<count>\\d+) leaks? for (?P<bytes>\\d+) total', leaks_output).groups()
+        excluded_match = re.search(b'(?P<excluded>\\d+) leaks? excluded', leaks_output)
         excluded = excluded_match.group('excluded') if excluded_match else 0
         return int(count), int(excluded), int(bytes)
 
index 9513e2a..592ffb7 100644 (file)
@@ -35,6 +35,8 @@ import subprocess
 from xml.dom.minidom import parseString
 from xml.parsers.expat import ExpatError
 
+from webkitpy.common.unicode_compatibility import encode_if_necessary, decode_for
+
 _log = logging.getLogger(__name__)
 
 
@@ -127,7 +129,7 @@ class ValgrindError:
             for frame in backtrace[1]:
                 buf += (frame[FUNCTION_NAME] or frame[INSTRUCTION_POINTER]) + "\n"
 
-            input = buf.encode('latin-1').split("\n")
+            input = buf.encode('latin-1').split(b"\n")
             demangled_names = [self._executive.run_command(['c++filt', '-n', name]) for name in input if name]
 
             i = 0
@@ -172,9 +174,9 @@ class ValgrindError:
 
         for frame in range(len(supplines)):
             # Replace the always-changing anonymous namespace prefix with "*".
-            m = re.match("( +fun:)_ZN.*_GLOBAL__N_.*\.cc_" +
-                         "[0-9a-fA-F]{8}_[0-9a-fA-F]{8}(.*)",
-                         supplines[frame])
+            m = re.match(r"( +fun:)_ZN.*_GLOBAL__N_.*\.cc_" +
+                          "[0-9a-fA-F]{8}_[0-9a-fA-F]{8}(.*)",
+                          supplines[frame])
             if m:
                 supplines[frame] = "*".join(m.groups())
 
@@ -196,7 +198,7 @@ class ValgrindError:
         # This is a device-independent hash identifying the suppression.
         # By printing out this hash we can find duplicate reports between tests and
         # different shards running on multiple buildbots
-        return int(hashlib.md5(self.unique_string()).hexdigest()[:16], 16)
+        return int(hashlib.md5(encode_if_necessary(self.unique_string())).hexdigest()[:16], 16)
 
     def __hash__(self):
         return hash(self.unique_string())
@@ -222,7 +224,7 @@ class LeakDetectorValgrind(object):
             parsed_string = parseString(leaks_output)
         except ExpatError as e:
             parse_failed = True
-            _log.error("could not parse %s: %s" % (leaks_output, e))
+            _log.error("could not parse %s: %s" % (decode_for(leaks_output, str), e))
             return
 
         cur_report_errors = set()
@@ -283,11 +285,12 @@ class LeakDetectorValgrind(object):
         _log.info("-----------------------------------------------------")
         _log.info("Suppressions used:")
         _log.info("  count name")
-        for (name, count) in sorted(self._suppressions.items(), key=lambda (k, v): (v, k)):
+        for (name, count) in sorted(self._suppressions.items(), key=lambda pair: (pair[1], pair[0])):
             _log.info("%7d %s" % (count, name))
         _log.info("-----------------------------------------------------")
 
         if self._errors:
             _log.info("Valgrind detected %s leaks:" % len(self._errors))
-            for leak in self._errors:
+            # Force the same order in Python 2 and Python 3
+            for leak in sorted(self._errors, key=lambda error: error.unique_string()):
                 _log.info(leak)
index afd4241..48fa872 100644 (file)
@@ -29,6 +29,7 @@ import unittest
 from webkitpy.common.system.executive_mock import MockExecutive2
 from webkitpy.common.system.filesystem_mock import MockFileSystem
 from webkitpy.common.system.outputcapture import OutputCapture
+from webkitpy.common.unicode_compatibility import decode_for
 from webkitpy.port.leakdetector_valgrind import LeakDetectorValgrind
 
 
@@ -619,40 +620,6 @@ Suppressions used:
 -----------------------------------------------------
 Valgrind detected 2 leaks:
 Leak_DefinitelyLost
-8 bytes in 1 blocks are definitely lost in loss record 421 of 7,972
-  operator new(unsigned long) (/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
-  std::_Function_base::_Base_manager<WebCore::PolicyChecker::checkNavigationPolicy(WebCore::ResourceRequest const&, WebCore::DocumentLoader*, WTF::PassRefPtr<WebCore::FormState>, void (*)(void*, WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool), void*)::{lambda(WebCore::PolicyAction)#1}>::_M_manager(std::_Any_data&, std::_Function_base::_Base_manager<WebCore::PolicyChecker::checkNavigationPolicy(WebCore::ResourceRequest const&, WebCore::DocumentLoader*, WTF::PassRefPtr<WebCore::FormState>, void (*)(void*, WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool), void*)::{lambda(WebCore::PolicyAction)#1}> const&, std::_Manager_operation) (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
-  webkit_web_policy_decision_new (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
-  WebKit::FrameLoaderClient::dispatchDecidePolicyForNavigationAction(WebCore::NavigationAction const&, WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, std::function<void (WebCore::PolicyAction)>) (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
-  WebCore::PolicyChecker::checkNavigationPolicy(WebCore::ResourceRequest const&, WebCore::DocumentLoader*, WTF::PassRefPtr<WebCore::FormState>, void (*)(void*, WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool), void*) (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
-  WebCore::FrameLoader::loadWithDocumentLoader(WebCore::DocumentLoader*, WebCore::FrameLoadType, WTF::PassRefPtr<WebCore::FormState>) (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
-  WebCore::FrameLoader::load(WebCore::DocumentLoader*) (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
-  WebCore::FrameLoader::load(WebCore::FrameLoadRequest const&) (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
-  webkit_web_frame_load_uri (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
-  runTest(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (/home/user/WebKit/WebKitBuild/Release/Programs/DumpRenderTree)
-  runTestingServerLoop() (/home/user/WebKit/WebKitBuild/Release/Programs/DumpRenderTree)
-  main (/home/user/WebKit/WebKitBuild/Release/Programs/DumpRenderTree)
-Suppression (error hash=#0449D3ED253FE1F9#):
-
-{
-   <insert_a_suppression_name_here>
-   Memcheck:Leak
-   fun:_Znw*
-   fun:_ZNSt14_Function_base13_Base_managerIZN7WebCore13PolicyChecker21checkNavigationPolicyERKNS1_15ResourceRequestEPNS1_14DocumentLoaderEN3WTF10PassRefPtrINS1_9FormStateEEEPFvPvS5_SB_bESC_EUlNS1_12PolicyActionEE_E10_M_managerERSt9_Any_dataRKSI_St18_Manager_operation
-   fun:webkit_web_policy_decision_new
-   fun:_ZN6WebKit17FrameLoaderClient39dispatchDecidePolicyForNavigationActionERKN7WebCore16NavigationActionERKNS1_15ResourceRequestEN3WTF10PassRefPtrINS1_9FormStateEEESt8functionIFvNS1_12PolicyActionEEE
-   fun:_ZN7WebCore13PolicyChecker21checkNavigationPolicyERKNS_15ResourceRequestEPNS_14DocumentLoaderEN3WTF10PassRefPtrINS_9FormStateEEEPFvPvS3_S9_bESA_
-   fun:_ZN7WebCore11FrameLoader22loadWithDocumentLoaderEPNS_14DocumentLoaderENS_13FrameLoadTypeEN3WTF10PassRefPtrINS_9FormStateEEE
-   fun:_ZN7WebCore11FrameLoader4loadEPNS_14DocumentLoaderE
-   fun:_ZN7WebCore11FrameLoader4loadERKNS_16FrameLoadRequestE
-   fun:webkit_web_frame_load_uri
-   fun:_ZL7runTestRKSs
-   fun:_ZL20runTestingServerLoopv
-   fun:main
-}
-
-
-Leak_DefinitelyLost
 8 bytes in 1 blocks are definitely lost in loss record 422 of 7,972
   operator new(unsigned long) (/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   std::_Function_base::_Base_manager<WebCore::PolicyChecker::checkContentPolicy(WebCore::ResourceResponse const&, void (*)(void*, WebCore::PolicyAction), void*)::{lambda(WebCore::PolicyAction)#1}>::_M_manager(std::_Any_data&, std::_Function_base::_Base_manager<WebCore::PolicyChecker::checkContentPolicy(WebCore::ResourceResponse const&, void (*)(void*, WebCore::PolicyAction), void*)::{lambda(WebCore::PolicyAction)#1}> const&, std::_Manager_operation) (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
@@ -698,6 +665,40 @@ Suppression (error hash=#8313DEB16B069438#):
 }
 
 
+Leak_DefinitelyLost
+8 bytes in 1 blocks are definitely lost in loss record 421 of 7,972
+  operator new(unsigned long) (/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
+  std::_Function_base::_Base_manager<WebCore::PolicyChecker::checkNavigationPolicy(WebCore::ResourceRequest const&, WebCore::DocumentLoader*, WTF::PassRefPtr<WebCore::FormState>, void (*)(void*, WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool), void*)::{lambda(WebCore::PolicyAction)#1}>::_M_manager(std::_Any_data&, std::_Function_base::_Base_manager<WebCore::PolicyChecker::checkNavigationPolicy(WebCore::ResourceRequest const&, WebCore::DocumentLoader*, WTF::PassRefPtr<WebCore::FormState>, void (*)(void*, WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool), void*)::{lambda(WebCore::PolicyAction)#1}> const&, std::_Manager_operation) (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
+  webkit_web_policy_decision_new (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
+  WebKit::FrameLoaderClient::dispatchDecidePolicyForNavigationAction(WebCore::NavigationAction const&, WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, std::function<void (WebCore::PolicyAction)>) (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
+  WebCore::PolicyChecker::checkNavigationPolicy(WebCore::ResourceRequest const&, WebCore::DocumentLoader*, WTF::PassRefPtr<WebCore::FormState>, void (*)(void*, WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool), void*) (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
+  WebCore::FrameLoader::loadWithDocumentLoader(WebCore::DocumentLoader*, WebCore::FrameLoadType, WTF::PassRefPtr<WebCore::FormState>) (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
+  WebCore::FrameLoader::load(WebCore::DocumentLoader*) (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
+  WebCore::FrameLoader::load(WebCore::FrameLoadRequest const&) (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
+  webkit_web_frame_load_uri (/home/user/WebKit/WebKitBuild/Release/.libs/libwebkitgtk-3.0.so.0.19.3)
+  runTest(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (/home/user/WebKit/WebKitBuild/Release/Programs/DumpRenderTree)
+  runTestingServerLoop() (/home/user/WebKit/WebKitBuild/Release/Programs/DumpRenderTree)
+  main (/home/user/WebKit/WebKitBuild/Release/Programs/DumpRenderTree)
+Suppression (error hash=#0449D3ED253FE1F9#):
+
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Leak
+   fun:_Znw*
+   fun:_ZNSt14_Function_base13_Base_managerIZN7WebCore13PolicyChecker21checkNavigationPolicyERKNS1_15ResourceRequestEPNS1_14DocumentLoaderEN3WTF10PassRefPtrINS1_9FormStateEEEPFvPvS5_SB_bESC_EUlNS1_12PolicyActionEE_E10_M_managerERSt9_Any_dataRKSI_St18_Manager_operation
+   fun:webkit_web_policy_decision_new
+   fun:_ZN6WebKit17FrameLoaderClient39dispatchDecidePolicyForNavigationActionERKN7WebCore16NavigationActionERKNS1_15ResourceRequestEN3WTF10PassRefPtrINS1_9FormStateEEESt8functionIFvNS1_12PolicyActionEEE
+   fun:_ZN7WebCore13PolicyChecker21checkNavigationPolicyERKNS_15ResourceRequestEPNS_14DocumentLoaderEN3WTF10PassRefPtrINS_9FormStateEEEPFvPvS3_S9_bESA_
+   fun:_ZN7WebCore11FrameLoader22loadWithDocumentLoaderEPNS_14DocumentLoaderENS_13FrameLoadTypeEN3WTF10PassRefPtrINS_9FormStateEEE
+   fun:_ZN7WebCore11FrameLoader4loadEPNS_14DocumentLoaderE
+   fun:_ZN7WebCore11FrameLoader4loadERKNS_16FrameLoadRequestE
+   fun:webkit_web_frame_load_uri
+   fun:_ZL7runTestRKSs
+   fun:_ZL20runTestingServerLoopv
+   fun:main
+}
+
+
 """
 
 valgrind_output_cppfilt_map = {
@@ -807,7 +808,7 @@ Suppressions used:
 
 def mock_run_cppfilt_command(args):
     if args[0] == 'c++filt':
-        return valgrind_output_cppfilt_map[args[2]]
+        return valgrind_output_cppfilt_map[decode_for(args[2], str)]
     return ""
 
 
index c69b477..9adc463 100644 (file)
@@ -36,6 +36,7 @@ import tempfile
 import time
 
 from webkitpy.common.system.executive import ScriptError
+from webkitpy.common.unicode_compatibility import decode_if_necessary
 
 
 class GDBCrashLogGenerator(object):
@@ -75,7 +76,7 @@ class GDBCrashLogGenerator(object):
             try:
                 info = self._executive.run_command(coredumpctl + ['info', "--since=" + time.strftime("%a %Y-%m-%d %H:%M:%S %Z", time.localtime(self.newer_than))],
                     return_stderr=True)
-            except ScriptError, OSError:
+            except (ScriptError, OSError):
                 continue
 
             found_newer = False
@@ -129,7 +130,7 @@ class GDBCrashLogGenerator(object):
         elif coredumpctl:
             crash_log, errors = self._get_trace_from_systemd(coredumpctl, pid_representation)
 
-        stderr_lines = errors + str(stderr or '<empty>').decode('utf8', 'ignore').splitlines()
+        stderr_lines = errors + decode_if_necessary(str(stderr or '<empty>'), errors='ignore').splitlines()
         errors_str = '\n'.join(('STDERR: ' + stderr_line) for stderr_line in stderr_lines)
         cppfilt_proc = self._executive.popen(
             ['c++filt'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
index 19d95c7..b7f6ea6 100644 (file)
@@ -222,7 +222,7 @@ class MacPort(DarwinPort):
         self._helper = self._executive.popen(arguments,
             stdin=self._executive.PIPE, stdout=self._executive.PIPE, stderr=None)
         is_ready = self._helper.stdout.readline()
-        if not is_ready.startswith('ready'):
+        if not is_ready.startswith(b'ready'):
             _log.error("LayoutTestHelper could not start")
             return False
         return True
@@ -242,7 +242,7 @@ class MacPort(DarwinPort):
         if self._helper:
             _log.debug("Stopping LayoutTestHelper")
             try:
-                self._helper.stdin.write("x\n")
+                self._helper.stdin.write(b"x\n")
                 self._helper.stdin.close()
                 self._helper.wait()
             except IOError as e:
index 58fe5e0..b64d654 100644 (file)
@@ -31,8 +31,8 @@
 import sys
 import unittest
 
-from webkitpy.common import newstringio
 from webkitpy.common.system.systemhost_mock import MockSystemHost
+from webkitpy.common.unicode_compatibility import StringIO
 from webkitpy.port import mock_drt
 from webkitpy.port import port_testcase
 from webkitpy.port import test
@@ -146,9 +146,9 @@ class MockDRTTest(unittest.TestCase):
             pixel_tests, expected_checksum, drt_output, drt_input=None, expected_text=expected_text)
 
         args = ['--platform', port_name] + self.extra_args(pixel_tests)
-        stdin = newstringio.StringIO(drt_input)
-        stdout = newstringio.StringIO()
-        stderr = newstringio.StringIO()
+        stdin = StringIO(drt_input)
+        stdout = StringIO()
+        stderr = StringIO()
         options, args = mock_drt.parse_options(args)
 
         drt = self.make_drt(options, args, host, stdin, stdout, stderr)
@@ -156,17 +156,15 @@ class MockDRTTest(unittest.TestCase):
 
         self.assertEqual(res, 0)
 
-        # We use the StringIO.buflist here instead of getvalue() because
-        # the StringIO might be a mix of unicode/ascii and 8-bit strings.
-        self.assertEqual(stdout.buflist, drt_output)
+        self.assertEqual(stdout.getvalue(), ''.join(drt_output))
         self.assertEqual(stderr.getvalue(), '#EOF\n')
 
     def test_main(self):
         host = MockSystemHost()
         test.add_unit_tests_to_mock_filesystem(host.filesystem)
-        stdin = newstringio.StringIO()
-        stdout = newstringio.StringIO()
-        stderr = newstringio.StringIO()
+        stdin = StringIO()
+        stdout = StringIO()
+        stderr = StringIO()
         res = mock_drt.main(['--platform', 'test'] + self.extra_args(False),
                             host, stdin, stdout, stderr)
         self.assertEqual(res, 0)
index 7b58cce..46406c4 100644 (file)
@@ -89,7 +89,7 @@ def bind_mock_apple_additions():
             result.mapping[INTERNAL_TABLE] = {}
             for platform in result.mapping[PUBLIC_TABLE]:
                 result.mapping[INTERNAL_TABLE][platform] = {}
-                for name, version in result.mapping[PUBLIC_TABLE][platform].iteritems():
+                for name, version in result.mapping[PUBLIC_TABLE][platform].items():
                     result.mapping[INTERNAL_TABLE][platform]['add-' + name] = version
             return result
 
@@ -469,8 +469,8 @@ class PortTestCase(unittest.TestCase):
         for path in port.expectations_files():
             port._filesystem.write_text_file(path, '')
         ordered_dict = port.expectations_dict()
-        self.assertEqual(port.path_to_generic_test_expectations_file(), ordered_dict.keys()[0])
-        self.assertEqual(port.path_to_test_expectations_file(), ordered_dict.keys()[port.test_expectations_file_position()])
+        self.assertEqual(port.path_to_generic_test_expectations_file(), list(ordered_dict.keys())[0])
+        self.assertEqual(port.path_to_test_expectations_file(), list(ordered_dict.keys())[port.test_expectations_file_position()])
 
         options = MockOptions(additional_expectations=['/tmp/foo', '/tmp/bar'])
         port = self.make_port(options=options)
@@ -479,8 +479,8 @@ class PortTestCase(unittest.TestCase):
         port._filesystem.write_text_file('/tmp/foo', 'foo')
         port._filesystem.write_text_file('/tmp/bar', 'bar')
         ordered_dict = port.expectations_dict()
-        self.assertEqual(ordered_dict.keys()[-2:], options.additional_expectations)  # pylint: disable=E1101
-        self.assertEqual(ordered_dict.values()[-2:], ['foo', 'bar'])
+        self.assertEqual(list(ordered_dict.keys())[-2:], options.additional_expectations)  # pylint: disable=E1101
+        self.assertEqual(list(ordered_dict.values())[-2:], ['foo', 'bar'])
 
     def test_path_to_test_expectations_file(self):
         port = TestWebKitPort()
@@ -531,7 +531,7 @@ class PortTestCase(unittest.TestCase):
         host.filesystem.write_text_file('/mock-checkout/LayoutTests/platform/testwebkitport/TestExpectations',
             'BUG_TESTEXPECTATIONS SKIP : fast/html/article-element.html = FAIL\n')
         port = TestWebKitPort(host=host)
-        self.assertEqual(''.join(port.expectations_dict().values()), 'BUG_TESTEXPECTATIONS SKIP : fast/html/article-element.html = FAIL\n')
+        self.assertEqual(''.join(list(port.expectations_dict().values())), 'BUG_TESTEXPECTATIONS SKIP : fast/html/article-element.html = FAIL\n')
 
     def test_build_driver(self):
         output = OutputCapture()
index c55b2ba..5a39b73 100644 (file)
@@ -91,7 +91,7 @@ class WinPort(ApplePort):
 
     def __init__(self, host, port_name, **kwargs):
         ApplePort.__init__(self, host, port_name, **kwargs)
-        if port_name.split('-') > 1:
+        if len(port_name.split('-')) > 1:
             self._os_version = VersionNameMap.map(host.platform).from_name(port_name.split('-')[1])[1]
         else:
             self._os_version = self.host.platform.os_version
@@ -127,7 +127,7 @@ class WinPort(ApplePort):
             # Note we do not add 'wk2' here, even though it's included in _skipped_search_paths().
         # FIXME: Perhaps we should get this list from MacPort?
         fallback_names.append('mac')
-        result = map(self._webkit_baseline_path, fallback_names)
+        result = list(map(self._webkit_baseline_path, fallback_names))
         if apple_additions() and getattr(apple_additions(), "layout_tests_path", None):
             result.insert(0, self._filesystem.join(apple_additions().layout_tests_path(), self.port_name))
         return result
@@ -205,7 +205,7 @@ class WinPort(ApplePort):
 
     def test_search_path(self, **kwargs):
         test_fallback_names = [path for path in self.baseline_search_path() if not path.startswith(self._webkit_baseline_path('mac'))]
-        return map(self._webkit_baseline_path, test_fallback_names)
+        return list(map(self._webkit_baseline_path, test_fallback_names))
 
     def _ntsd_location(self):
         if 'PROGRAMFILES' not in os.environ:
@@ -340,7 +340,7 @@ class WinPort(ApplePort):
             return None
         debugger_options = '"{0}" -p %ld -e %ld -g -noio -lines -cf "{1}"'.format(cygpath(ntsd_path), cygpath(command_file))
         registry_settings = {'Debugger': [debugger_options, self._REG_SZ], 'Auto': ["1", self._REG_SZ]}
-        for key, value in registry_settings.iteritems():
+        for key, value in registry_settings.items():
             for arch in ["--wow32", "--wow64"]:
                 self.previous_debugger_values[(arch, self._HKLM, key)] = self.read_registry_value(self.POST_MORTEM_DEBUGGER_KEY, arch, self._HKLM, key)
                 self.previous_wow64_debugger_values[(arch, self._HKLM, key)] = self.read_registry_value(self.WOW64_POST_MORTEM_DEBUGGER_KEY, arch, self._HKLM, key)
@@ -348,14 +348,14 @@ class WinPort(ApplePort):
                 self.write_registry_value(self.WOW64_POST_MORTEM_DEBUGGER_KEY, arch, self._HKLM, key, value[1], value[0])
 
     def restore_crash_log_saving(self):
-        for key, value in self.previous_debugger_values.iteritems():
+        for key, value in self.previous_debugger_values.items():
             self.write_registry_value(self.POST_MORTEM_DEBUGGER_KEY, key[0], key[1], key[2], value[1], value[0])
-        for key, value in self.previous_wow64_debugger_values.iteritems():
+        for key, value in self.previous_wow64_debugger_values.items():
             self.write_registry_value(self.WOW64_POST_MORTEM_DEBUGGER_KEY, key[0], key[1], key[2], value[1], value[0])
 
     def prevent_error_dialogs(self):
         registry_settings = {'DontShowUI': [1, self._REG_DWORD], 'Disabled': [1, self._REG_DWORD]}
-        for key, value in registry_settings.iteritems():
+        for key, value in registry_settings.items():
             for root in [self._HKLM, self._HKCU]:
                 for arch in ["--wow32", "--wow64"]:
                     self.previous_error_reporting_values[(arch, root, key)] = self.read_registry_value(self.WINDOWS_ERROR_REPORTING_KEY, arch, root, key)
@@ -364,9 +364,9 @@ class WinPort(ApplePort):
                     self.write_registry_value(self.WOW64_WINDOWS_ERROR_REPORTING_KEY, arch, root, key, value[1], value[0])
 
     def allow_error_dialogs(self):
-        for key, value in self.previous_error_reporting_values.iteritems():
+        for key, value in self.previous_error_reporting_values.items():
             self.write_registry_value(self.WINDOWS_ERROR_REPORTING_KEY, key[0], key[1], key[2], value[1], value[0])
-        for key, value in self.previous_wow64_error_reporting_values.iteritems():
+        for key, value in self.previous_wow64_error_reporting_values.items():
             self.write_registry_value(self.WOW64_WINDOWS_ERROR_REPORTING_KEY, key[0], key[1], key[2], value[1], value[0])
 
     def delete_sem_locks(self):
@@ -463,10 +463,10 @@ class WinCairoPort(WinPort):
     DEFAULT_ARCHITECTURE = 'x86_64'
 
     def default_baseline_search_path(self, **kwargs):
-        return map(self._webkit_baseline_path, self._search_paths())
+        return list(map(self._webkit_baseline_path, self._search_paths()))
 
     def _port_specific_expectations_files(self, **kwargs):
-        return map(lambda x: self._filesystem.join(self._webkit_baseline_path(x), 'TestExpectations'), reversed(self._search_paths()))
+        return list(map(lambda x: self._filesystem.join(self._webkit_baseline_path(x), 'TestExpectations'), reversed(self._search_paths())))
 
     def _search_paths(self):
         paths = []
@@ -507,10 +507,10 @@ class FTWPort(WinPort):
     DEFAULT_ARCHITECTURE = 'x86_64'
 
     def default_baseline_search_path(self, **kwargs):
-        return map(self._webkit_baseline_path, self._search_paths())
+        return list(map(self._webkit_baseline_path, self._search_paths()))
 
     def _port_specific_expectations_files(self, **kwargs):
-        return map(lambda x: self._filesystem.join(self._webkit_baseline_path(x), 'TestExpectations'), reversed(self._search_paths()))
+        return list(map(lambda x: self._filesystem.join(self._webkit_baseline_path(x), 'TestExpectations'), reversed(self._search_paths())))
 
     def _search_paths(self):
         paths = []
index 0c62114..681b2fd 100644 (file)
@@ -56,7 +56,7 @@ class WinPortTest(port_testcase.PortTestCase):
 
     def _assert_search_path(self, expected_search_paths, version, use_webkit2=False):
         port = self.make_port(port_name='win', os_version=version, options=MockOptions(webkit_test_runner=use_webkit2))
-        absolute_search_paths = map(port._webkit_baseline_path, expected_search_paths)
+        absolute_search_paths = list(map(port._webkit_baseline_path, expected_search_paths))
         self.assertEqual(port.baseline_search_path(), absolute_search_paths)
 
     def test_baseline_search_path(self):
index 4356b7a..4fd0271 100644 (file)
@@ -107,10 +107,10 @@ class WPEPort(Port):
         return [self.port_name, 'wk2'] + self.get_option("additional_platform_directory", [])
 
     def default_baseline_search_path(self, **kwargs):
-        return map(self._webkit_baseline_path, self._search_paths())
+        return list(map(self._webkit_baseline_path, self._search_paths()))
 
     def _port_specific_expectations_files(self, **kwargs):
-        return map(lambda x: self._filesystem.join(self._webkit_baseline_path(x), 'TestExpectations'), reversed(self._search_paths()))
+        return list(map(lambda x: self._filesystem.join(self._webkit_baseline_path(x), 'TestExpectations'), reversed(self._search_paths())))
 
     def test_expectations_file_position(self):
         # WPE port baseline search path is wpe -> wk2 -> generic, so port test expectations file is at third to last position.