Changeset 103952 in webkit


Ignore:
Timestamp:
Jan 3, 2012 11:53:50 AM (12 years ago)
Author:
Adam Roben
Message:

Make Port subclasses override the operating_system method rather than setting an attribute

Without this patch, any use of Port.operating_system() within a port's init method would
return the default value ("mac"). This was confusing the version-checking logic inside
ApplePort.init on Windows.

Fixes <http://webkit.org/b/75479> <rdar://problem/10637385> REGRESSION (r102161): NRWT
crashes on launch on Windows 7 SP1

Reviewed by Eric Seidel.

  • Scripts/webkitpy/layout_tests/port/apple.py:

(ApplePort.init): Replaced uses of self._operating_system with self.operating_system().

  • Scripts/webkitpy/layout_tests/port/base.py:

(Port.init): Removed code that set the self._operating_system attribute. Subclasses
should now override the operating_system method instead.
(Port.operating_system): Changed to always return "mac". Subclasses should override to
return something else.

  • Scripts/webkitpy/layout_tests/port/chromium_linux.py:

(ChromiumLinuxPort.init):
(ChromiumLinuxPort.operating_system):

  • Scripts/webkitpy/layout_tests/port/chromium_mac.py:

(ChromiumMacPort.init):
(ChromiumMacPort.operating_system):

  • Scripts/webkitpy/layout_tests/port/chromium_win.py:

(ChromiumWinPort.init):
(ChromiumWinPort.operating_system):

  • Scripts/webkitpy/layout_tests/port/mac.py:

(MacPort.init):
(MacPort.operating_system):

  • Scripts/webkitpy/layout_tests/port/win.py:

(WinPort.init):
(WinPort.operating_system):
Changed to override the operating_system method rather than setting the _operating_system
attribute, since setting the attribute isn't sufficient for code inside init methods.

  • Scripts/webkitpy/layout_tests/port/qt.py:

(QtPort.init):
(QtPort._path_to_webcore_library):
Changed to use self.operating_system() instead of self._operating_system, for consistency
with other Port-related code.

(QtPort.operating_system): Added this override of Port.operating_system that returns the
value we determined in our init method.

  • Scripts/webkitpy/layout_tests/port/test.py:

(TestPort.operating_system): Added this override of Port.operating_system that returns the
value we determined in our init method.

  • Scripts/webkitpy/layout_tests/port/base_unittest.py:

(PortTest.test_operating_system):

  • Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py:

(ChromiumLinuxPortTest.test_operating_system):

  • Scripts/webkitpy/layout_tests/port/chromium_mac_unittest.py:

(ChromiumMacPortTest.test_operating_system):

  • Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:

(ChromiumWinPortTest.test_operating_system):

  • Scripts/webkitpy/layout_tests/port/mac_unittest.py:

(MacPortTest.test_operating_system):

  • Scripts/webkitpy/layout_tests/port/qt_unittest.py:

(QtPortTest.test_operating_system):

  • Scripts/webkitpy/layout_tests/port/win_unittest.py:

(WinPortTest.test_operating_system):
Test that all ports return the expected operating system string.

Location:
trunk/Tools
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r103943 r103952  
     12012-01-03  Adam Roben  <aroben@apple.com>
     2
     3        Make Port subclasses override the operating_system method rather than setting an attribute
     4
     5        Without this patch, any use of Port.operating_system() within a port's __init__ method would
     6        return the default value ("mac"). This was confusing the version-checking logic inside
     7        ApplePort.__init__ on Windows.
     8
     9        Fixes <http://webkit.org/b/75479> <rdar://problem/10637385> REGRESSION (r102161): NRWT
     10        crashes on launch on Windows 7 SP1
     11
     12        Reviewed by Eric Seidel.
     13
     14        * Scripts/webkitpy/layout_tests/port/apple.py:
     15        (ApplePort.__init__): Replaced uses of self._operating_system with self.operating_system().
     16
     17        * Scripts/webkitpy/layout_tests/port/base.py:
     18        (Port.__init__): Removed code that set the self._operating_system attribute. Subclasses
     19        should now override the operating_system method instead.
     20        (Port.operating_system): Changed to always return "mac". Subclasses should override to
     21        return something else.
     22
     23        * Scripts/webkitpy/layout_tests/port/chromium_linux.py:
     24        (ChromiumLinuxPort.__init__):
     25        (ChromiumLinuxPort.operating_system):
     26        * Scripts/webkitpy/layout_tests/port/chromium_mac.py:
     27        (ChromiumMacPort.__init__):
     28        (ChromiumMacPort.operating_system):
     29        * Scripts/webkitpy/layout_tests/port/chromium_win.py:
     30        (ChromiumWinPort.__init__):
     31        (ChromiumWinPort.operating_system):
     32        * Scripts/webkitpy/layout_tests/port/mac.py:
     33        (MacPort.__init__):
     34        (MacPort.operating_system):
     35        * Scripts/webkitpy/layout_tests/port/win.py:
     36        (WinPort.__init__):
     37        (WinPort.operating_system):
     38        Changed to override the operating_system method rather than setting the _operating_system
     39        attribute, since setting the attribute isn't sufficient for code inside __init__ methods.
     40
     41        * Scripts/webkitpy/layout_tests/port/qt.py:
     42        (QtPort.__init__):
     43        (QtPort._path_to_webcore_library):
     44        Changed to use self.operating_system() instead of self._operating_system, for consistency
     45        with other Port-related code.
     46
     47        (QtPort.operating_system): Added this override of Port.operating_system that returns the
     48        value we determined in our __init__ method.
     49
     50        * Scripts/webkitpy/layout_tests/port/test.py:
     51        (TestPort.operating_system): Added this override of Port.operating_system that returns the
     52        value we determined in our __init__ method.
     53
     54        * Scripts/webkitpy/layout_tests/port/base_unittest.py:
     55        (PortTest.test_operating_system):
     56        * Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py:
     57        (ChromiumLinuxPortTest.test_operating_system):
     58        * Scripts/webkitpy/layout_tests/port/chromium_mac_unittest.py:
     59        (ChromiumMacPortTest.test_operating_system):
     60        * Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
     61        (ChromiumWinPortTest.test_operating_system):
     62        * Scripts/webkitpy/layout_tests/port/mac_unittest.py:
     63        (MacPortTest.test_operating_system):
     64        * Scripts/webkitpy/layout_tests/port/qt_unittest.py:
     65        (QtPortTest.test_operating_system):
     66        * Scripts/webkitpy/layout_tests/port/win_unittest.py:
     67        (WinPortTest.test_operating_system):
     68        Test that all ports return the expected operating system string.
     69
    1702012-01-03  Mario Sanchez Prada  <msanchez@igalia.com>
    271
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/apple.py

    r102161 r103952  
    7171            self._name = self.port_name + '-' + self._version
    7272        else:
    73             allowed_port_names = self.VERSION_FALLBACK_ORDER + [self._operating_system + "-future"]
     73            allowed_port_names = self.VERSION_FALLBACK_ORDER + [self.operating_system() + "-future"]
    7474            assert port_name in allowed_port_names, "%s is not in %s" % (port_name, allowed_port_names)
    7575            self._version = self._strip_port_name_prefix(port_name)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py

    r103289 r103952  
    9393        # These are default values that should be overridden in a subclasses.
    9494        self._name = port_name or self.port_name  # Subclasses may append a -VERSION (like mac-leopard) or other qualifiers.
    95         self._operating_system = 'mac'
    9695        self._version = ''
    9796        self._architecture = 'x86'
     
    636635
    637636    def operating_system(self):
    638         return self._operating_system
     637        # Subclasses should override this default implementation.
     638        return 'mac'
    639639
    640640    def version(self):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py

    r103289 r103952  
    349349            'bar/test-3.html': [('==', 'bar/test-ref.html'), ('==', 'bar/test-ref2.html'), ('!=', 'bar/test-notref.html')]})
    350350
     351    def test_operating_system(self):
     352        self.assertEqual('mac', self.make_port().operating_system())
     353
    351354
    352355class VirtualTest(unittest.TestCase):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux.py

    r99773 r103952  
    7575                             'chromium-gpu-linux-x86_64')
    7676        self._name = port_name
    77         self._operating_system = 'linux'
    7877        self._version = 'lucid'  # We only support lucid right now.
    7978
     
    111110            _log.error('    http://code.google.com/p/chromium/wiki/LinuxBuildInstructions')
    112111        return result
     112
     113    def operating_system(self):
     114        return 'linux'
    113115
    114116    #
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py

    r99781 r103952  
    8787        self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, host)
    8888
     89    def test_operating_system(self):
     90        self.assertEqual('linux', self.make_port().operating_system())
     91
    8992
    9093if __name__ == '__main__':
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py

    r102454 r103952  
    126126        else:
    127127            self._graphics_type = 'cpu'
    128         self._operating_system = 'mac'
    129128
    130129    def baseline_search_path(self):
     
    150149            return 1
    151150        return chromium.ChromiumPort.default_child_processes(self)
     151
     152    def operating_system(self):
     153        return 'mac'
    152154
    153155    #
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac_unittest.py

    r102454 r103952  
    8686        self.assertEquals('cpu', self.make_port().graphics_type())
    8787
     88    def test_operating_system(self):
     89        self.assertEqual('mac', self.make_port().operating_system())
     90
    8891
    8992if __name__ == '__main__':
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py

    r100674 r103952  
    9696            self._version = port_name[port_name.index('-win-') + len('-win-'):]
    9797            assert self._version in self.SUPPORTED_VERSIONS, "%s is not in %s" % (self._version, self.SUPPORTED_VERSIONS)
    98         self._operating_system = 'win'
    9998
    10099
     
    131130            _log.error('    http://dev.chromium.org/developers/how-tos/build-instructions-windows')
    132131        return result
     132
     133    def operating_system(self):
     134        return 'win'
    133135
    134136    def relative_test_filename(self, filename):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py

    r100674 r103952  
    127127            '/mock-checkout/Source/WebKit/chromium/build/Debug/DumpRenderTree.exe',
    128128            port._path_to_driver('Debug'))
     129
     130    def test_operating_system(self):
     131        self.assertEqual('win', self.make_port().operating_system())
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py

    r102161 r103952  
    7676
    7777    def __init__(self, host, **kwargs):
    78         self._operating_system = 'mac'
    7978        ApplePort.__init__(self, host, **kwargs)
    8079        self._leak_detector = LeakDetector(self)
     
    105104        env['XML_CATALOG_FILES'] = ''  # work around missing /etc/catalog <rdar://problem/4292995>
    106105        return env
     106
     107    def operating_system(self):
     108        return 'mac'
    107109
    108110    # Belongs on a Platform object.
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py

    r102161 r103952  
    163163        expected_stderr = "MOCK run_command: ['Tools/Scripts/run-safari', '--release', '-NSOpen', 'test.html'], cwd=/mock-checkout\n"
    164164        OutputCapture().assert_outputs(self, port.show_results_html_file, ["test.html"], expected_stderr=expected_stderr)
     165
     166    def test_operating_system(self):
     167        self.assertEqual('mac', self.make_port().operating_system())
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/qt.py

    r102766 r103952  
    6464        WebKitPort.__init__(self, host, port_name=None, **kwargs)
    6565        self._operating_system = self._operating_system_for_platform(sys_platform or sys.platform)
    66         self._version = self._operating_system
     66        self._version = self.operating_system()
    6767
    6868        # FIXME: This will allow WebKitPort.baseline_search_path and WebKitPort._skipped_file_search_paths
     
    7373        else:
    7474            name_components = [self.port_name]
    75             if self._operating_system:
    76                 name_components.append(self._operating_system)
     75            if self.operating_system():
     76                name_components.append(self.operating_system())
    7777            self._name = "-".join(name_components)
    7878
     
    9595
    9696    def _path_to_webcore_library(self):
    97         if self._operating_system == 'mac':
     97        if self.operating_system() == 'mac':
    9898            return self._build_path('lib/QtWebKit.framework/QtWebKit')
    9999        else:
     
    156156        run_launcher_args.append("file://%s" % results_filename)
    157157        self._run_script("run-launcher", run_launcher_args)
     158
     159    def operating_system(self):
     160        return self._operating_system
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/qt_unittest.py

    r103253 r103952  
    8484        env = port.setup_environ_for_server(port.driver_name())
    8585        self.assertEquals(env['QTWEBKIT_PLUGIN_PATH'], 'MOCK output of child process/lib/plugins')
     86
     87    def test_operating_system(self):
     88        self.assertEqual('linux', self.make_port(sys_platform='linux').operating_system())
     89        self.assertEqual('mac', self.make_port(sys_platform='darwin').operating_system())
     90        self.assertEqual('win', self.make_port(sys_platform='cygwin').operating_system())
     91        self.assertEqual('win', self.make_port(sys_platform='win32').operating_system())
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py

    r103254 r103952  
    378378        return self._name
    379379
     380    def operating_system(self):
     381        return self._operating_system
     382
    380383    def _path_to_wdiff(self):
    381384        return None
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/win.py

    r102161 r103952  
    7575            return self._version_string_from_windows_version_tuple(version_tuple)
    7676
    77     def __init__(self, host, **kwargs):
    78         self._operating_system = 'win'
    79         ApplePort.__init__(self, host, **kwargs)
    80 
    8177    def compare_text(self, expected_text, actual_text):
    8278        # Sanity was restored in WK2, so we don't need this hack there.
     
    109105        return map(self._webkit_baseline_path, fallback_names)
    110106
     107    def operating_system(self):
     108        return 'win'
     109
    111110    # This port may need to override setup_environ_for_server
    112111    # to match behavior of setPathForRunningWebKitApp from ORWT.
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/win_unittest.py

    r99781 r103952  
    104104        port._options = MockOptions(webkit_test_runner=True)
    105105        self.assertTrue(port.compare_text(expected, "foo\n"))
     106
     107    def test_operating_system(self):
     108        self.assertEqual('win', self.make_port().operating_system())
Note: See TracChangeset for help on using the changeset viewer.