Changeset 76322 in webkit


Ignore:
Timestamp:
Jan 20, 2011 6:30:17 PM (13 years ago)
Author:
dpranke@chromium.org
Message:

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:
Location:
trunk/Tools
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r76321 r76322  
     12011-01-20  Dirk Pranke  <dpranke@chromium.org>
     2
     3        Reviewed by Eric Siedel.
     4
     5        nrwt: clean up almost all remaining port references, remove
     6        unnecessary import clauses. The only remaining references are
     7        in places where a mock filesystem makes no sense or can't be
     8        used, and in one routine in port/google_chrome_unittest that
     9        I'll rewrite in a separate patch.
     10
     11        https://bugs.webkit.org/show_bug.cgi?id=52771
     12
     13        * Scripts/webkitpy/layout_tests/layout_package/test_runner.py:
     14        * Scripts/webkitpy/layout_tests/port/chromium_gpu.py:
     15        * Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py:
     16        * Scripts/webkitpy/layout_tests/port/chromium_linux.py:
     17        * Scripts/webkitpy/layout_tests/port/chromium_mac.py:
     18        * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
     19        * Scripts/webkitpy/layout_tests/port/chromium_win.py:
     20        * Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
     21        * Scripts/webkitpy/layout_tests/port/google_chrome.py:
     22        * Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py:
     23        * Scripts/webkitpy/layout_tests/port/gtk.py:
     24        * Scripts/webkitpy/layout_tests/port/mac.py:
     25        * Scripts/webkitpy/layout_tests/port/port_testcase.py:
     26        * Scripts/webkitpy/layout_tests/port/qt.py:
     27        * Scripts/webkitpy/layout_tests/port/webkit.py:
     28        * Scripts/webkitpy/layout_tests/port/win.py:
     29        * Scripts/webkitpy/layout_tests/test_types/image_diff.py:
     30
    1312011-01-20  Dirk Pranke  <dpranke@chromium.org>
    232
  • trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner.py

    r76200 r76322  
    4343import Queue
    4444import random
    45 import shutil
    4645import sys
    4746import time
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu.py

    r73748 r76322  
    2525# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2626
    27 from __future__ import with_statement
    28 
    29 import codecs
    30 import os
    3127import sys
    3228
     
    8379    except AssertionError:
    8480        return None
    85     if not os.path.exists(overrides_path):
     81    if not port._filesystem.exists(overrides_path):
    8682        return None
    87     with codecs.open(overrides_path, "r", "utf-8") as file:
    88         return file.read()
     83    return port._filesystem.read_text_file(overrides_path)
    8984
    9085
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py

    r73748 r76322  
    2525# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2626
    27 import os
    2827import unittest
    2928
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux.py

    r76190 r76322  
    8484
    8585        base = self.path_from_chromium_base()
    86         if os.path.exists(os.path.join(base, 'sconsbuild')):
    87             return os.path.join(base, 'sconsbuild', *comps)
    88         if os.path.exists(os.path.join(base, 'out', *comps)) or self.get_option('use_test_shell'):
    89             return os.path.join(base, 'out', *comps)
     86        if self._filesystem.exists(self._filesystem.join(base, 'sconsbuild')):
     87            return self._filesystem.join(base, 'sconsbuild', *comps)
     88        if self._filesystem.exists(self._filesystem.join(base, 'out', *comps)) or self.get_option('use_test_shell'):
     89            return self._filesystem.join(base, 'out', *comps)
    9090        base = self.path_from_webkit_base()
    91         if os.path.exists(os.path.join(base, 'sconsbuild')):
    92             return os.path.join(base, 'sconsbuild', *comps)
    93         return os.path.join(base, 'out', *comps)
     91        if self._filesystem.exists(self._filesystem.join(base, 'sconsbuild')):
     92            return self._filesystem.join(base, 'sconsbuild', *comps)
     93        return self._filesystem.join(base, 'out', *comps)
    9494
    9595    def _check_apache_install(self):
     
    138138            config_name = 'apache2-debian-httpd.conf'
    139139
    140         return os.path.join(self.layout_tests_dir(), 'http', 'conf',
     140        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
    141141                            config_name)
    142142
     
    168168
    169169    def _is_redhat_based(self):
    170         return os.path.exists(os.path.join('/etc', 'redhat-release'))
     170        return self._filesystem.exists(self._filesystem.join('/etc', 'redhat-release'))
    171171
    172172    def _shut_down_http_server(self, server_pid):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py

    r76101 r76322  
    111111
    112112        path = self.path_from_chromium_base('xcodebuild', *comps)
    113         if os.path.exists(path) or self.get_option('use_test_shell'):
     113        if self._filesystem.exists(path) or self.get_option('use_test_shell'):
    114114            return path
    115115        return self.path_from_webkit_base(
     
    133133
    134134    def _path_to_apache_config_file(self):
    135         return os.path.join(self.layout_tests_dir(), 'http', 'conf',
    136                             'apache2-httpd.conf')
     135        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
     136                                     'apache2-httpd.conf')
    137137
    138138    def _path_to_lighttpd(self):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py

    r76184 r76322  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
    29 import os
    3029import unittest
    3130import StringIO
     
    132131        port = ChromiumPortTest.TestLinuxPort(options=mock_options)
    133132
    134         fake_test = os.path.join(port.layout_tests_dir(), "fast/js/not-good.js")
     133        fake_test = port._filesystem.join(port.layout_tests_dir(), "fast/js/not-good.js")
    135134
    136135        port.test_expectations = lambda: """BUG_TEST SKIP : fast/js/not-good.js = TEXT
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py

    r76101 r76322  
    3131
    3232import logging
    33 import os
    3433import sys
    3534
     
    112111
    113112        p = self.path_from_chromium_base('webkit', *comps)
    114         if os.path.exists(p):
     113        if self._filesystem.exists(p):
    115114            return p
    116115        p = self.path_from_chromium_base('chrome', *comps)
    117         if os.path.exists(p) or self.get_option('use_test_shell'):
     116        if self._filesystem.exists(p) or self.get_option('use_test_shell'):
    118117            return p
    119         return os.path.join(self.path_from_webkit_base(), 'WebKit', 'chromium',
    120                             *comps)
     118        return self._filesystem.join(self.path_from_webkit_base(), 'WebKit', 'chromium', *comps)
    121119
    122120    def _lighttpd_path(self, *comps):
     
    129127
    130128    def _path_to_apache_config_file(self):
    131         return os.path.join(self.layout_tests_dir(), 'http', 'conf',
    132                             'cygwin-httpd.conf')
     129        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'cygwin-httpd.conf')
    133130
    134131    def _path_to_lighttpd(self):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py

    r70731 r76322  
    4646    def tearDown(self):
    4747        sys.platform = self.orig_platform
     48        self._port = None
    4849
    4950    def _mock_path_from_chromium_base(self, *comps):
    50         return os.path.join("/chromium/src", *comps)
     51        return self._port._filesystem.join("/chromium/src", *comps)
    5152
    5253    def test_setup_environ_for_server(self):
    5354        port = chromium_win.ChromiumWinPort()
    5455        port._executive = mocktool.MockExecutive(should_log=True)
     56        self._port = port
    5557        port.path_from_chromium_base = self._mock_path_from_chromium_base
    5658        output = outputcapture.OutputCapture()
     
    6668        port._executive = mocktool.MockExecutive(should_log=True)
    6769        port.path_from_chromium_base = self._mock_path_from_chromium_base
     70        self._port = port
    6871        setup_mount = self._mock_path_from_chromium_base("third_party",
    6972                                                         "cygwin",
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome.py

    r69079 r76322  
    2525# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2626
    27 from __future__ import with_statement
    28 
    29 import codecs
    30 import os
    31 
    3227
    3328def _test_expectations_overrides(port, super):
     
    4136    overrides_path = port.path_from_chromium_base('webkit', 'tools',
    4237            'layout_tests', 'test_expectations_chrome.txt')
    43     if not os.path.exists(overrides_path):
     38    if not port._filesystem.exists(overrides_path):
    4439        return chromium_overrides
    4540
    46     with codecs.open(overrides_path, "r", "utf-8") as file:
    47         if chromium_overrides:
    48             return chromium_overrides + file.read()
    49         else:
    50             return file.read()
     41    chromium_overrides = chromium_overrides or ''
     42    return chromium_overrides + port._filesystem.read_text_file(overrides_path)
    5143
    5244def GetGoogleChromePort(**kwargs):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py

    r71580 r76322  
    5151                                                 options=None)
    5252        path = port.baseline_search_path()[0]
    53         self.assertEqual(expected_path, os.path.split(path)[1])
     53        self.assertEqual(expected_path, port._filesystem.basename(path))
    5454
    5555    def _verify_expectations_overrides(self, port_name):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py

    r73873 r76322  
    5858    def _path_to_apache_config_file(self):
    5959        # FIXME: This needs to detect the distribution and change config files.
    60         return os.path.join(self.layout_tests_dir(), 'http', 'conf',
    61                             'apache2-debian-httpd.conf')
     60        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
     61                                     'apache2-debian-httpd.conf')
    6262
    6363    def _shut_down_http_server(self, server_pid):
     
    104104            config_name = 'apache2-debian-httpd.conf'
    105105
    106         return os.path.join(self.layout_tests_dir(), 'http', 'conf',
     106        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
    107107                            config_name)
    108108
     
    114114
    115115    def _is_redhat_based(self):
    116         return os.path.exists(os.path.join('/etc', 'redhat-release'))
     116        return self._filesystem.exists(self._filesystem.join('/etc', 'redhat-release'))
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py

    r68008 r76322  
    7777        skipped_files = []
    7878        if self._name in ('mac-tiger', 'mac-leopard', 'mac-snowleopard'):
    79             skipped_files.append(os.path.join(
     79            skipped_files.append(self._filesystem.join(
    8080                self._webkit_baseline_path(self._name), 'Skipped'))
    81         skipped_files.append(os.path.join(self._webkit_baseline_path('mac'),
     81        skipped_files.append(self._filesystem.join(self._webkit_baseline_path('mac'),
    8282                                          'Skipped'))
    8383        return skipped_files
     
    100100
    101101    def _build_java_test_support(self):
    102         java_tests_path = os.path.join(self.layout_tests_dir(), "java")
     102        java_tests_path = self._filesystem.join(self.layout_tests_dir(), "java")
    103103        build_java = ["/usr/bin/make", "-C", java_tests_path]
    104104        if self._executive.run_command(build_java, return_exit_code=True):
     
    125125
    126126    def _path_to_apache_config_file(self):
    127         return os.path.join(self.layout_tests_dir(), 'http', 'conf',
    128                             'apache2-httpd.conf')
     127        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
     128                                     'apache2-httpd.conf')
    129129
    130130    # FIXME: This doesn't have anything to do with WebKit.
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py

    r75626 r76322  
    2929"""Unit testing base class for Port implementations."""
    3030
    31 import os
    32 import tempfile
    3331import unittest
    3432
     
    6563            return
    6664
    67         # FIXME: not sure why this shouldn't always be True
    68         #self.assertTrue(port.check_image_diff())
    6965        if not port.check_image_diff():
     66            # The port hasn't been built - don't run the tests.
    7067            return
    7168
    7269        dir = port.layout_tests_dir()
    73         file1 = os.path.join(dir, 'fast', 'css', 'button_center.png')
    74         fh1 = file(file1)
    75         contents1 = fh1.read()
    76         file2 = os.path.join(dir, 'fast', 'css',
    77                              'remove-shorthand-expected.png')
    78         fh2 = file(file2)
    79         contents2 = fh2.read()
    80         tmpfile = tempfile.mktemp()
     70        file1 = port._filesystem.join(dir, 'fast', 'css', 'button_center.png')
     71        contents1 = port._filesystem.read_binary_file(file1)
     72        file2 = port._filesystem.join(dir, 'fast', 'css',
     73                                      'remove-shorthand-expected.png')
     74        contents2 = port._filesystem.read_binary_file(file2)
     75        tmpfd, tmpfile = port._filesystem.open_binary_tempfile('')
     76        tmpfd.close()
    8177
    8278        self.assertFalse(port.diff_image(contents1, contents1))
     
    8480
    8581        self.assertTrue(port.diff_image(contents1, contents2, tmpfile))
    86         fh1.close()
    87         fh2.close()
    88         # FIXME: this may not be being written?
    89         # self.assertTrue(os.path.exists(tmpfile))
    90         # os.remove(tmpfile)
     82
     83        port._filesystem.remove(tmpfile)
    9184
    9285    def test_websocket_server(self):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/qt.py

    r70643 r76322  
    7272    def _path_to_apache_config_file(self):
    7373        # FIXME: This needs to detect the distribution and change config files.
    74         return os.path.join(self.layout_tests_dir(), 'http', 'conf',
    75                             'apache2-debian-httpd.conf')
     74        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
     75                                     'apache2-debian-httpd.conf')
    7676
    7777    def _shut_down_http_server(self, server_pid):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py

    r73748 r76322  
    3232
    3333
    34 from __future__ import with_statement
    35 
    36 import codecs
    3734import logging
     35import operator
    3836import os
    3937import re
    40 import shutil
    4138import signal
    4239import sys
    4340import time
    4441import webbrowser
    45 import operator
    46 import tempfile
    47 import shutil
    4842
    4943import webkitpy.common.system.ospath as ospath
     
    7367
    7468    def path_to_test_expectations_file(self):
    75         return os.path.join(self._webkit_baseline_path(self._name),
    76                             'test_expectations.txt')
     69        return self._filesystem.join(self._webkit_baseline_path(self._name),
     70                                     'test_expectations.txt')
    7771
    7872    # Only needed by ports which maintain versioned test expectations (like mac-tiger vs. mac-leopard)
     
    8680    def _check_driver(self):
    8781        driver_path = self._path_to_driver()
    88         if not os.path.exists(driver_path):
     82        if not self._filesystem.exists(driver_path):
    8983            _log.error("DumpRenderTree was not found at %s" % driver_path)
    9084            return False
     
    109103    def check_image_diff(self, override_step=None, logging=True):
    110104        image_diff_path = self._path_to_image_diff()
    111         if not os.path.exists(image_diff_path):
     105        if not self._filesystem.exists(image_diff_path):
    112106            _log.error("ImageDiff was not found at %s" % image_diff_path)
    113107            return False
     
    166160                result = False
    167161        elif output and diff_filename:
    168             with open(diff_filename, 'w') as file:
    169                 file.write(output)
     162            self._filesystem.write_text_file(diff_filename, output)
    170163        elif sp.timed_out:
    171164            _log.error("ImageDiff timed out")
     
    301294
    302295    def _skipped_file_paths(self):
    303         return [os.path.join(self._webkit_baseline_path(self._name),
    304                                                         'Skipped')]
     296        return [self._filesystem.join(self._webkit_baseline_path(self._name), 'Skipped')]
    305297
    306298    def _expectations_from_skipped_files(self):
    307299        tests_to_skip = []
    308300        for filename in self._skipped_file_paths():
    309             if not os.path.exists(filename):
     301            if not self._filesystem.exists(filename):
    310302                _log.warn("Failed to open Skipped file: %s" % filename)
    311303                continue
    312             with codecs.open(filename, "r", "utf-8") as skipped_file:
    313                 tests_to_skip.extend(self._tests_from_skipped_file(skipped_file))
     304            skipped_file = self._filesystem.read_text_file(filename)
    314305        return tests_to_skip
    315306
     
    318309        # and 'Skipped' files.
    319310        expectations_path = self.path_to_test_expectations_file()
    320         with codecs.open(expectations_path, "r", "utf-8") as file:
    321             return file.read() + self._skips()
     311        return self._filesystem.read_text_file(expectations_path) + self._skips()
    322312
    323313    def _skips(self):
     
    374364            # See http://wiki.apache.org/httpd/DistrosDefaultLayout
    375365            for path in ["/usr/sbin/httpd", "/usr/sbin/apache2"]:
    376                 if os.path.exists(path):
     366                if self._filesystem.exists(path):
    377367                    self._cached_apache_path = path
    378368                    break
     
    390380        self._worker_number = worker_number
    391381        self._port = port
    392         self._driver_tempdir = tempfile.mkdtemp(prefix='DumpRenderTree-')
     382        self._driver_tempdir = port._filesystem.mkdtemp(prefix='DumpRenderTree-')
    393383
    394384    def __del__(self):
    395         shutil.rmtree(self._driver_tempdir)
     385        self._port._filesystem.rmtree(str(self._driver_tempdir))
    396386
    397387    def cmd_line(self):
     
    407397        environment = self._port.setup_environ_for_server()
    408398        environment['DYLD_FRAMEWORK_PATH'] = self._port._build_path()
    409         environment['DUMPRENDERTREE_TEMP'] = self._driver_tempdir
     399        environment['DUMPRENDERTREE_TEMP'] = str(self._driver_tempdir)
    410400        self._server_process = server_process.ServerProcess(self._port,
    411401            "DumpRenderTree", self.cmd_line(), environment)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/win.py

    r68008 r76322  
    3030
    3131import logging
    32 import os
    3332
    3433from webkitpy.layout_tests.port.webkit import WebKitPort
     
    6160
    6261    def _path_to_apache_config_file(self):
    63         return os.path.join(self.layout_tests_dir(), 'http', 'conf',
    64                             'cygwin-httpd.conf')
     62        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
     63                                     'cygwin-httpd.conf')
    6564
    6665    def _shut_down_http_server(self, server_pid):
  • trunk/Tools/Scripts/webkitpy/layout_tests/test_types/image_diff.py

    r73256 r76322  
    3535"""
    3636
    37 from __future__ import with_statement
    38 
    39 import codecs
    4037import errno
    4138import logging
    42 import os
    43 import shutil
    4439
    4540from webkitpy.layout_tests.layout_package import test_failures
Note: See TracChangeset for help on using the changeset viewer.