2011-01-20 Dirk Pranke <dpranke@chromium.org>
authordpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jan 2011 02:30:17 +0000 (02:30 +0000)
committerdpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jan 2011 02:30:17 +0000 (02:30 +0000)
        Reviewed by Eric Siedel.

        nrwt: clean up almost all remaining port references, remove
        unnecessary import clauses. The only remaining references are
        in places where a mock filesystem makes no sense or can't be
        used, and in one routine in port/google_chrome_unittest that
        I'll rewrite in a separate patch.

        https://bugs.webkit.org/show_bug.cgi?id=52771

        * Scripts/webkitpy/layout_tests/layout_package/test_runner.py:
        * Scripts/webkitpy/layout_tests/port/chromium_gpu.py:
        * Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py:
        * Scripts/webkitpy/layout_tests/port/chromium_linux.py:
        * Scripts/webkitpy/layout_tests/port/chromium_mac.py:
        * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
        * Scripts/webkitpy/layout_tests/port/chromium_win.py:
        * Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
        * Scripts/webkitpy/layout_tests/port/google_chrome.py:
        * Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py:
        * Scripts/webkitpy/layout_tests/port/gtk.py:
        * Scripts/webkitpy/layout_tests/port/mac.py:
        * Scripts/webkitpy/layout_tests/port/port_testcase.py:
        * Scripts/webkitpy/layout_tests/port/qt.py:
        * Scripts/webkitpy/layout_tests/port/webkit.py:
        * Scripts/webkitpy/layout_tests/port/win.py:
        * Scripts/webkitpy/layout_tests/test_types/image_diff.py:

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

18 files changed:
Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner.py
Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu.py
Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py
Tools/Scripts/webkitpy/layout_tests/port/chromium_linux.py
Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py
Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py
Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py
Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py
Tools/Scripts/webkitpy/layout_tests/port/google_chrome.py
Tools/Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py
Tools/Scripts/webkitpy/layout_tests/port/gtk.py
Tools/Scripts/webkitpy/layout_tests/port/mac.py
Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py
Tools/Scripts/webkitpy/layout_tests/port/qt.py
Tools/Scripts/webkitpy/layout_tests/port/webkit.py
Tools/Scripts/webkitpy/layout_tests/port/win.py
Tools/Scripts/webkitpy/layout_tests/test_types/image_diff.py

index a0ff8fe87cf1594744b281e020759b47d8690bb5..3e0526600085dffb438bb48e26339b4cd5673caa 100644 (file)
@@ -1,3 +1,33 @@
+2011-01-20  Dirk Pranke  <dpranke@chromium.org>
+
+        Reviewed by Eric Siedel.
+
+        nrwt: clean up almost all remaining port references, remove
+        unnecessary import clauses. The only remaining references are
+        in places where a mock filesystem makes no sense or can't be
+        used, and in one routine in port/google_chrome_unittest that
+        I'll rewrite in a separate patch.
+
+        https://bugs.webkit.org/show_bug.cgi?id=52771
+
+        * Scripts/webkitpy/layout_tests/layout_package/test_runner.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_gpu.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_linux.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_mac.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_win.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/google_chrome.py:
+        * Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/gtk.py:
+        * Scripts/webkitpy/layout_tests/port/mac.py:
+        * Scripts/webkitpy/layout_tests/port/port_testcase.py:
+        * Scripts/webkitpy/layout_tests/port/qt.py:
+        * Scripts/webkitpy/layout_tests/port/webkit.py:
+        * Scripts/webkitpy/layout_tests/port/win.py:
+        * Scripts/webkitpy/layout_tests/test_types/image_diff.py:
+
 2011-01-20  Dirk Pranke  <dpranke@chromium.org>
 
         Reviewed by Mihai Parparita.
index 6bdbda978926d8d9a054ab4dc2e0bfb7a2c45a6b..6c078500eaeb7a988885b21849d0a65ebb20f202 100644 (file)
@@ -42,7 +42,6 @@ import logging
 import math
 import Queue
 import random
-import shutil
 import sys
 import time
 
index c1f5c8d69c7a40dc3f49fe96716f204250d11586..b88d8aa08537dfdcff179136636212184affb224 100644 (file)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-from __future__ import with_statement
-
-import codecs
-import os
 import sys
 
 import chromium_linux
@@ -82,10 +78,9 @@ def _gpu_overrides(port):
             'layout_tests', 'test_expectations_gpu.txt')
     except AssertionError:
         return None
-    if not os.path.exists(overrides_path):
+    if not port._filesystem.exists(overrides_path):
         return None
-    with codecs.open(overrides_path, "r", "utf-8") as file:
-        return file.read()
+    return port._filesystem.read_text_file(overrides_path)
 
 
 class ChromiumGpuLinuxPort(chromium_linux.ChromiumLinuxPort):
index ad0404cffe4790f9ede311313d1d4d8fca693605..0bfb127676c368ff226b89bbdc32f097172d4ff6 100644 (file)
@@ -24,7 +24,6 @@
 # (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 os
 import unittest
 
 from webkitpy.tool import mocktool
index 4fddd8333625e5bae969d00603d3356a91cbf848..c1c85f8985ef8b795042dbd1811f31681af2a890 100644 (file)
@@ -83,14 +83,14 @@ class ChromiumLinuxPort(chromium.ChromiumPort):
                                          *comps)
 
         base = self.path_from_chromium_base()
-        if os.path.exists(os.path.join(base, 'sconsbuild')):
-            return os.path.join(base, 'sconsbuild', *comps)
-        if os.path.exists(os.path.join(base, 'out', *comps)) or self.get_option('use_test_shell'):
-            return os.path.join(base, 'out', *comps)
+        if self._filesystem.exists(self._filesystem.join(base, 'sconsbuild')):
+            return self._filesystem.join(base, 'sconsbuild', *comps)
+        if self._filesystem.exists(self._filesystem.join(base, 'out', *comps)) or self.get_option('use_test_shell'):
+            return self._filesystem.join(base, 'out', *comps)
         base = self.path_from_webkit_base()
-        if os.path.exists(os.path.join(base, 'sconsbuild')):
-            return os.path.join(base, 'sconsbuild', *comps)
-        return os.path.join(base, 'out', *comps)
+        if self._filesystem.exists(self._filesystem.join(base, 'sconsbuild')):
+            return self._filesystem.join(base, 'sconsbuild', *comps)
+        return self._filesystem.join(base, 'out', *comps)
 
     def _check_apache_install(self):
         result = self._check_file_exists(self._path_to_apache(),
@@ -137,7 +137,7 @@ class ChromiumLinuxPort(chromium.ChromiumPort):
         else:
             config_name = 'apache2-debian-httpd.conf'
 
-        return os.path.join(self.layout_tests_dir(), 'http', 'conf',
+        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
                             config_name)
 
     def _path_to_lighttpd(self):
@@ -167,7 +167,7 @@ class ChromiumLinuxPort(chromium.ChromiumPort):
             return '/usr/bin/wdiff'
 
     def _is_redhat_based(self):
-        return os.path.exists(os.path.join('/etc', 'redhat-release'))
+        return self._filesystem.exists(self._filesystem.join('/etc', 'redhat-release'))
 
     def _shut_down_http_server(self, server_pid):
         """Shut down the lighttpd web server. Blocks until it's fully
index b08a948b44946d38f8bc66508804797ea0b8e713..5360ab34f876d8af9ccf1a98e715481cc720a364 100644 (file)
@@ -110,7 +110,7 @@ class ChromiumMacPort(chromium.ChromiumPort):
                                          *comps)
 
         path = self.path_from_chromium_base('xcodebuild', *comps)
-        if os.path.exists(path) or self.get_option('use_test_shell'):
+        if self._filesystem.exists(path) or self.get_option('use_test_shell'):
             return path
         return self.path_from_webkit_base(
             'Source', 'WebKit', 'chromium', 'xcodebuild', *comps)
@@ -132,8 +132,8 @@ class ChromiumMacPort(chromium.ChromiumPort):
         return '/usr/sbin/httpd'
 
     def _path_to_apache_config_file(self):
-        return os.path.join(self.layout_tests_dir(), 'http', 'conf',
-                            'apache2-httpd.conf')
+        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
+                                     'apache2-httpd.conf')
 
     def _path_to_lighttpd(self):
         return self._lighttpd_path('bin', 'lighttpd')
index 5a02cae4cab2c5d32e61a7f881be32ebe3abd522..6c8987b913501bc9338c6c65e27eec4d1c40018b 100644 (file)
@@ -26,7 +26,6 @@
 # (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 os
 import unittest
 import StringIO
 
@@ -131,7 +130,7 @@ class ChromiumPortTest(unittest.TestCase):
         mock_options = mocktool.MockOptions()
         port = ChromiumPortTest.TestLinuxPort(options=mock_options)
 
-        fake_test = os.path.join(port.layout_tests_dir(), "fast/js/not-good.js")
+        fake_test = port._filesystem.join(port.layout_tests_dir(), "fast/js/not-good.js")
 
         port.test_expectations = lambda: """BUG_TEST SKIP : fast/js/not-good.js = TEXT
 LINUX WIN : fast/js/very-good.js = TIMEOUT PASS"""
index 0fecc6d2d41a7126b66dbbbc6a037df37ebb6d9d..14f277791d99bd82c2c6e946ec18b28b14ae9960 100644 (file)
@@ -30,7 +30,6 @@
 """Chromium Win implementation of the Port interface."""
 
 import logging
-import os
 import sys
 
 import chromium
@@ -111,13 +110,12 @@ class ChromiumWinPort(chromium.ChromiumPort):
                                          *comps)
 
         p = self.path_from_chromium_base('webkit', *comps)
-        if os.path.exists(p):
+        if self._filesystem.exists(p):
             return p
         p = self.path_from_chromium_base('chrome', *comps)
-        if os.path.exists(p) or self.get_option('use_test_shell'):
+        if self._filesystem.exists(p) or self.get_option('use_test_shell'):
             return p
-        return os.path.join(self.path_from_webkit_base(), 'WebKit', 'chromium',
-                            *comps)
+        return self._filesystem.join(self.path_from_webkit_base(), 'WebKit', 'chromium', *comps)
 
     def _lighttpd_path(self, *comps):
         return self.path_from_chromium_base('third_party', 'lighttpd', 'win',
@@ -128,8 +126,7 @@ class ChromiumWinPort(chromium.ChromiumPort):
                                             'sbin', 'httpd')
 
     def _path_to_apache_config_file(self):
-        return os.path.join(self.layout_tests_dir(), 'http', 'conf',
-                            'cygwin-httpd.conf')
+        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'cygwin-httpd.conf')
 
     def _path_to_lighttpd(self):
         return self._lighttpd_path('LightTPD.exe')
index 36f3c6b24280ec842d2e5090e7446ceca6d50ce9..d677589a51a07960a94d76328b19e5214c6d3622 100644 (file)
@@ -45,13 +45,15 @@ class ChromiumWinTest(unittest.TestCase):
 
     def tearDown(self):
         sys.platform = self.orig_platform
+        self._port = None
 
     def _mock_path_from_chromium_base(self, *comps):
-        return os.path.join("/chromium/src", *comps)
+        return self._port._filesystem.join("/chromium/src", *comps)
 
     def test_setup_environ_for_server(self):
         port = chromium_win.ChromiumWinPort()
         port._executive = mocktool.MockExecutive(should_log=True)
+        self._port = port
         port.path_from_chromium_base = self._mock_path_from_chromium_base
         output = outputcapture.OutputCapture()
         orig_environ = os.environ.copy()
@@ -65,6 +67,7 @@ class ChromiumWinTest(unittest.TestCase):
             options=ChromiumWinTest.RegisterCygwinOption())
         port._executive = mocktool.MockExecutive(should_log=True)
         port.path_from_chromium_base = self._mock_path_from_chromium_base
+        self._port = port
         setup_mount = self._mock_path_from_chromium_base("third_party",
                                                          "cygwin",
                                                          "setup_mount.bat")
index 8d94bb594dfd460b664af926aef582ff7c6fd2e3..ae90374200779ef0ee809cec105e5c5be4f87c46 100644 (file)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-from __future__ import with_statement
-
-import codecs
-import os
-
 
 def _test_expectations_overrides(port, super):
     # The chrome ports use the regular overrides plus anything in the
@@ -40,14 +35,11 @@ def _test_expectations_overrides(port, super):
     # this changed in r60427. This should probably be changed back.
     overrides_path = port.path_from_chromium_base('webkit', 'tools',
             'layout_tests', 'test_expectations_chrome.txt')
-    if not os.path.exists(overrides_path):
+    if not port._filesystem.exists(overrides_path):
         return chromium_overrides
 
-    with codecs.open(overrides_path, "r", "utf-8") as file:
-        if chromium_overrides:
-            return chromium_overrides + file.read()
-        else:
-            return file.read()
+    chromium_overrides = chromium_overrides or ''
+    return chromium_overrides + port._filesystem.read_text_file(overrides_path)
 
 def GetGoogleChromePort(**kwargs):
     """Some tests have slightly different results when compiled as Google
index e60c27416deb37935f40b45357cbd2971d2c6ea6..6539bb2b4beb98805aaf93d4314d060a44aa838a 100644 (file)
@@ -50,7 +50,7 @@ class GetGoogleChromePortTest(unittest.TestCase):
         port = google_chrome.GetGoogleChromePort(port_name=port_name,
                                                  options=None)
         path = port.baseline_search_path()[0]
-        self.assertEqual(expected_path, os.path.split(path)[1])
+        self.assertEqual(expected_path, port._filesystem.basename(path))
 
     def _verify_expectations_overrides(self, port_name):
         # FIXME: make this more robust when we have the Tree() abstraction.
index a18fdff5cf3b4a629fd0588e16be3172e5d263fc..0ec9f878acd931ad6de4daceffdaedac75493a8d 100644 (file)
@@ -57,8 +57,8 @@ class GtkPort(WebKitPort):
 
     def _path_to_apache_config_file(self):
         # FIXME: This needs to detect the distribution and change config files.
-        return os.path.join(self.layout_tests_dir(), 'http', 'conf',
-                            'apache2-debian-httpd.conf')
+        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
+                                     'apache2-debian-httpd.conf')
 
     def _shut_down_http_server(self, server_pid):
         """Shut down the httpd web server. Blocks until it's fully
@@ -103,7 +103,7 @@ class GtkPort(WebKitPort):
         else:
             config_name = 'apache2-debian-httpd.conf'
 
-        return os.path.join(self.layout_tests_dir(), 'http', 'conf',
+        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
                             config_name)
 
     def _path_to_wdiff(self):
@@ -113,4 +113,4 @@ class GtkPort(WebKitPort):
             return '/usr/bin/wdiff'
 
     def _is_redhat_based(self):
-        return os.path.exists(os.path.join('/etc', 'redhat-release'))
+        return self._filesystem.exists(self._filesystem.join('/etc', 'redhat-release'))
index 696e3398ea4b28ac76225907dc362ffc3fb86f9e..0622196108146582660ca4f0b510899d22ac6d23 100644 (file)
@@ -76,9 +76,9 @@ class MacPort(WebKitPort):
         # platforms and moved into base.Port.
         skipped_files = []
         if self._name in ('mac-tiger', 'mac-leopard', 'mac-snowleopard'):
-            skipped_files.append(os.path.join(
+            skipped_files.append(self._filesystem.join(
                 self._webkit_baseline_path(self._name), 'Skipped'))
-        skipped_files.append(os.path.join(self._webkit_baseline_path('mac'),
+        skipped_files.append(self._filesystem.join(self._webkit_baseline_path('mac'),
                                           'Skipped'))
         return skipped_files
 
@@ -99,7 +99,7 @@ class MacPort(WebKitPort):
         return ''
 
     def _build_java_test_support(self):
-        java_tests_path = os.path.join(self.layout_tests_dir(), "java")
+        java_tests_path = self._filesystem.join(self.layout_tests_dir(), "java")
         build_java = ["/usr/bin/make", "-C", java_tests_path]
         if self._executive.run_command(build_java, return_exit_code=True):
             _log.error("Failed to build Java support files: %s" % build_java)
@@ -124,8 +124,8 @@ class MacPort(WebKitPort):
         ]
 
     def _path_to_apache_config_file(self):
-        return os.path.join(self.layout_tests_dir(), 'http', 'conf',
-                            'apache2-httpd.conf')
+        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
+                                     'apache2-httpd.conf')
 
     # FIXME: This doesn't have anything to do with WebKit.
     def _shut_down_http_server(self, server_pid):
index c4b36acd9079fd2fbe90901202d5f9c025e387e5..30f3a56916e161bea6bce46970df144d676974a4 100644 (file)
@@ -28,8 +28,6 @@
 
 """Unit testing base class for Port implementations."""
 
-import os
-import tempfile
 import unittest
 
 from webkitpy.tool import mocktool
@@ -64,30 +62,25 @@ class PortTestCase(unittest.TestCase):
         if not port:
             return
 
-        # FIXME: not sure why this shouldn't always be True
-        #self.assertTrue(port.check_image_diff())
         if not port.check_image_diff():
+            # The port hasn't been built - don't run the tests.
             return
 
         dir = port.layout_tests_dir()
-        file1 = os.path.join(dir, 'fast', 'css', 'button_center.png')
-        fh1 = file(file1)
-        contents1 = fh1.read()
-        file2 = os.path.join(dir, 'fast', 'css',
-                             'remove-shorthand-expected.png')
-        fh2 = file(file2)
-        contents2 = fh2.read()
-        tmpfile = tempfile.mktemp()
+        file1 = port._filesystem.join(dir, 'fast', 'css', 'button_center.png')
+        contents1 = port._filesystem.read_binary_file(file1)
+        file2 = port._filesystem.join(dir, 'fast', 'css',
+                                      'remove-shorthand-expected.png')
+        contents2 = port._filesystem.read_binary_file(file2)
+        tmpfd, tmpfile = port._filesystem.open_binary_tempfile('')
+        tmpfd.close()
 
         self.assertFalse(port.diff_image(contents1, contents1))
         self.assertTrue(port.diff_image(contents1, contents2))
 
         self.assertTrue(port.diff_image(contents1, contents2, tmpfile))
-        fh1.close()
-        fh2.close()
-        # FIXME: this may not be being written?
-        # self.assertTrue(os.path.exists(tmpfile))
-        # os.remove(tmpfile)
+
+        port._filesystem.remove(tmpfile)
 
     def test_websocket_server(self):
         port = self.make_port()
index af94acc3901b480c43a84158bb5390aebb36cea9..1695b60391dcbcc34644037c5b738d48e8ed831e 100644 (file)
@@ -71,8 +71,8 @@ class QtPort(WebKitPort):
 
     def _path_to_apache_config_file(self):
         # FIXME: This needs to detect the distribution and change config files.
-        return os.path.join(self.layout_tests_dir(), 'http', 'conf',
-                            'apache2-debian-httpd.conf')
+        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
+                                     'apache2-debian-httpd.conf')
 
     def _shut_down_http_server(self, server_pid):
         """Shut down the httpd web server. Blocks until it's fully
index afdebeb2c846ed7ccdfd2ffe7db021ad315213b9..577acd45e983cc1c4cd8ad17da179f3db04ad8ef 100644 (file)
 """WebKit implementations of the Port interface."""
 
 
-from __future__ import with_statement
-
-import codecs
 import logging
+import operator
 import os
 import re
-import shutil
 import signal
 import sys
 import time
 import webbrowser
-import operator
-import tempfile
-import shutil
 
 import webkitpy.common.system.ospath as ospath
 import webkitpy.layout_tests.layout_package.test_output as test_output
@@ -72,8 +66,8 @@ class WebKitPort(base.Port):
         return [self._webkit_baseline_path(self._name)]
 
     def path_to_test_expectations_file(self):
-        return os.path.join(self._webkit_baseline_path(self._name),
-                            'test_expectations.txt')
+        return self._filesystem.join(self._webkit_baseline_path(self._name),
+                                     'test_expectations.txt')
 
     # Only needed by ports which maintain versioned test expectations (like mac-tiger vs. mac-leopard)
     def version(self):
@@ -85,7 +79,7 @@ class WebKitPort(base.Port):
 
     def _check_driver(self):
         driver_path = self._path_to_driver()
-        if not os.path.exists(driver_path):
+        if not self._filesystem.exists(driver_path):
             _log.error("DumpRenderTree was not found at %s" % driver_path)
             return False
         return True
@@ -108,7 +102,7 @@ class WebKitPort(base.Port):
 
     def check_image_diff(self, override_step=None, logging=True):
         image_diff_path = self._path_to_image_diff()
-        if not os.path.exists(image_diff_path):
+        if not self._filesystem.exists(image_diff_path):
             _log.error("ImageDiff was not found at %s" % image_diff_path)
             return False
         return True
@@ -165,8 +159,7 @@ class WebKitPort(base.Port):
             if m.group(2) == 'passed':
                 result = False
         elif output and diff_filename:
-            with open(diff_filename, 'w') as file:
-                file.write(output)
+            self._filesystem.write_text_file(diff_filename, output)
         elif sp.timed_out:
             _log.error("ImageDiff timed out")
         elif sp.crashed:
@@ -300,25 +293,22 @@ class WebKitPort(base.Port):
         return tests_to_skip
 
     def _skipped_file_paths(self):
-        return [os.path.join(self._webkit_baseline_path(self._name),
-                                                        'Skipped')]
+        return [self._filesystem.join(self._webkit_baseline_path(self._name), 'Skipped')]
 
     def _expectations_from_skipped_files(self):
         tests_to_skip = []
         for filename in self._skipped_file_paths():
-            if not os.path.exists(filename):
+            if not self._filesystem.exists(filename):
                 _log.warn("Failed to open Skipped file: %s" % filename)
                 continue
-            with codecs.open(filename, "r", "utf-8") as skipped_file:
-                tests_to_skip.extend(self._tests_from_skipped_file(skipped_file))
+            skipped_file = self._filesystem.read_text_file(filename)
         return tests_to_skip
 
     def test_expectations(self):
         # The WebKit mac port uses a combination of a test_expectations file
         # and 'Skipped' files.
         expectations_path = self.path_to_test_expectations_file()
-        with codecs.open(expectations_path, "r", "utf-8") as file:
-            return file.read() + self._skips()
+        return self._filesystem.read_text_file(expectations_path) + self._skips()
 
     def _skips(self):
         # Each Skipped file contains a list of files
@@ -373,7 +363,7 @@ class WebKitPort(base.Port):
             # The Apache binary path can vary depending on OS and distribution
             # See http://wiki.apache.org/httpd/DistrosDefaultLayout
             for path in ["/usr/sbin/httpd", "/usr/sbin/apache2"]:
-                if os.path.exists(path):
+                if self._filesystem.exists(path):
                     self._cached_apache_path = path
                     break
 
@@ -389,10 +379,10 @@ class WebKitDriver(base.Driver):
     def __init__(self, port, worker_number):
         self._worker_number = worker_number
         self._port = port
-        self._driver_tempdir = tempfile.mkdtemp(prefix='DumpRenderTree-')
+        self._driver_tempdir = port._filesystem.mkdtemp(prefix='DumpRenderTree-')
 
     def __del__(self):
-        shutil.rmtree(self._driver_tempdir)
+        self._port._filesystem.rmtree(str(self._driver_tempdir))
 
     def cmd_line(self):
         cmd = self._command_wrapper(self._port.get_option('wrapper'))
@@ -406,7 +396,7 @@ class WebKitDriver(base.Driver):
     def start(self):
         environment = self._port.setup_environ_for_server()
         environment['DYLD_FRAMEWORK_PATH'] = self._port._build_path()
-        environment['DUMPRENDERTREE_TEMP'] = self._driver_tempdir
+        environment['DUMPRENDERTREE_TEMP'] = str(self._driver_tempdir)
         self._server_process = server_process.ServerProcess(self._port,
             "DumpRenderTree", self.cmd_line(), environment)
 
index 9e30155100077608dc71f2455a0f4fe262135d65..e7d2004bab35e7d3d8ddf2b8be0615a16a9405a3 100644 (file)
@@ -29,7 +29,6 @@
 """WebKit Win implementation of the Port interface."""
 
 import logging
-import os
 
 from webkitpy.layout_tests.port.webkit import WebKitPort
 
@@ -60,8 +59,8 @@ class WinPort(WebKitPort):
         ]
 
     def _path_to_apache_config_file(self):
-        return os.path.join(self.layout_tests_dir(), 'http', 'conf',
-                            'cygwin-httpd.conf')
+        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
+                                     'cygwin-httpd.conf')
 
     def _shut_down_http_server(self, server_pid):
         """Shut down the httpd web server. Blocks until it's fully
index da466c8a17cd1ce27ecfbf95b102f8f578e3518b..44605d2ee81b7b0421415d1acbd2274e5ae0a87b 100644 (file)
@@ -34,13 +34,8 @@ match, returns FailureImageHashMismatch and outputs both hashes into the layout
 test results directory.
 """
 
-from __future__ import with_statement
-
-import codecs
 import errno
 import logging
-import os
-import shutil
 
 from webkitpy.layout_tests.layout_package import test_failures
 from webkitpy.layout_tests.test_types import test_type_base