Changeset 69040 in webkit


Ignore:
Timestamp:
Oct 4, 2010 3:11:10 PM (14 years ago)
Author:
dpranke@chromium.org
Message:

2010-10-04 Dirk Pranke <dpranke@chromium.org>

Reviewed by Tony Chang.

Add a way for us to have test expectations that are specific to the
official builds of Google Chrome (as opposed to Chromium). This change
looks for an additional "test_expectations_chrome.txt" file in
Chromium's repository (webkit/tools/layout_tests), and uses the
concatenation of that file and the regular test_expectations.txt
file for test overrides.

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

  • Scripts/webkitpy/layout_tests/port/google_chrome.py:
  • Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py:
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r69036 r69040  
     12010-10-04  Dirk Pranke  <dpranke@chromium.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        Add a way for us to have test expectations that are specific to the
     6        official builds of Google Chrome (as opposed to Chromium). This change
     7        looks for an additional "test_expectations_chrome.txt" file in
     8        Chromium's repository (webkit/tools/layout_tests), and uses the
     9        concatenation of that file and the regular test_expectations.txt
     10        file for test overrides.
     11
     12        https://bugs.webkit.org/show_bug.cgi?id=46854
     13
     14        * Scripts/webkitpy/layout_tests/port/google_chrome.py:
     15        * Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py:
     16
    1172010-10-04  Simon Fraser  <simon.fraser@apple.com>
    218
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/google_chrome.py

    r68008 r69040  
    2525# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2626
     27import codecs
     28import os
     29
     30
     31def _test_expectations_overrides(port, super):
     32    # The chrome ports use the regular overrides plus anything in the
     33    # official test_expectations as well. Hopefully we don't get collisions.
     34    chromium_overrides = super.test_expectations_overrides(port)
     35
     36    # FIXME: It used to be that AssertionError would get raised by
     37    # path_from_chromium_base() if we weren't in a Chromium checkout, but
     38    # this changed in r60427. This should probably be changed back.
     39    overrides_path = port.path_from_chromium_base('webkit', 'tools',
     40            'layout_tests', 'test_expectations_chrome.txt')
     41    if not os.path.exists(overrides_path):
     42        return chromium_overrides
     43
     44    with codecs.open(overrides_path, "r", "utf-8") as file:
     45        if chromium_overrides:
     46            return chromium_overrides + file.read()
     47        else:
     48            return file.read()
    2749
    2850def GetGoogleChromePort(**kwargs):
     
    4264                    'google-chrome-linux32'))
    4365                return paths
     66
     67            def test_expectations_overrides(self):
     68                return _test_expectations_overrides(self,
     69                    chromium_linux.ChromiumLinuxPort)
     70
    4471        return GoogleChromeLinux32Port(**kwargs)
    4572    elif port_name == 'google-chrome-linux64':
     
    5380                    'google-chrome-linux64'))
    5481                return paths
     82
     83            def test_expectations_overrides(self):
     84                return _test_expectations_overrides(self,
     85                    chromium_linux.ChromiumLinuxPort)
     86
    5587        return GoogleChromeLinux64Port(**kwargs)
    5688    elif port_name.startswith('google-chrome-mac'):
     
    6496                    'google-chrome-mac'))
    6597                return paths
     98
     99            def test_expectations_overrides(self):
     100                return _test_expectations_overrides(self,
     101                    chromium_mac.ChromiumMacPort)
     102
    66103        return GoogleChromeMacPort(**kwargs)
    67104    elif port_name.startswith('google-chrome-win'):
     
    75112                    'google-chrome-win'))
    76113                return paths
     114
     115            def test_expectations_overrides(self):
     116                return _test_expectations_overrides(self,
     117                    chromium_win.ChromiumWinPort)
     118
    77119        return GoogleChromeWinPort(**kwargs)
    78120    raise NotImplementedError('unsupported port: %s' % port_name)
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py

    r68008 r69040  
    2525# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2626
     27import codecs
    2728import os
    2829import unittest
     30
     31import base_unittest
     32import factory
    2933import google_chrome
    3034
     
    3640        for port in test_ports:
    3741            self._verify_baseline_path(port, port)
     42            self._verify_expectations_overrides(port)
    3843
    3944        self._verify_baseline_path('google-chrome-mac', 'google-chrome-mac-leopard')
     
    4651        path = port.baseline_search_path()[0]
    4752        self.assertEqual(expected_path, os.path.split(path)[1])
     53
     54    def _verify_expectations_overrides(self, port_name):
     55        # FIXME: make this more robust when we have the Tree() abstraction.
     56        # we should be able to test for the files existing or not, and
     57        # be able to control the contents better.
     58
     59        chromium_port = factory.get("chromium-mac")
     60        chromium_overrides = chromium_port.test_expectations_overrides()
     61        port = google_chrome.GetGoogleChromePort(port_name=port_name,
     62                                                 options=None)
     63
     64        orig_exists = os.path.exists
     65        orig_open = codecs.open
     66        expected_string = "// hello, world\n"
     67
     68        def mock_exists_chrome_not_found(path):
     69            if 'test_expectations_chrome.txt' in path:
     70                return False
     71            return orig_exists(path)
     72
     73        def mock_exists_chrome_found(path):
     74            if 'test_expectations_chrome.txt' in path:
     75                return True
     76            return orig_exists(path)
     77
     78        def mock_open(path, mode, encoding):
     79            if 'test_expectations_chrome.txt' in path:
     80                return base_unittest.NewStringIO(expected_string)
     81            return orig_open(path, mode, encoding)
     82
     83        try:
     84            os.path.exists = mock_exists_chrome_not_found
     85            chrome_overrides = port.test_expectations_overrides()
     86            self.assertEqual(chromium_overrides, chrome_overrides)
     87
     88            os.path.exists = mock_exists_chrome_found
     89            codecs.open = mock_open
     90            chrome_overrides = port.test_expectations_overrides()
     91            self.assertEqual(chrome_overrides,
     92                             chromium_overrides + expected_string)
     93        finally:
     94            os.path.exists = orig_exists
     95            codecs.open = orig_open
     96
     97
     98if __name__ == '__main__':
     99    unittest.main()
Note: See TracChangeset for help on using the changeset viewer.