2010-10-04 Dirk Pranke <dpranke@chromium.org>
authordpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Oct 2010 22:11:10 +0000 (22:11 +0000)
committerdpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Oct 2010 22:11:10 +0000 (22:11 +0000)
        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:

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

WebKitTools/ChangeLog
WebKitTools/Scripts/webkitpy/layout_tests/port/google_chrome.py
WebKitTools/Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py

index 6193b54b663aba382842cfda0ce820674bf464da..ca8e43b29e3c562d0d3ba82365aadd06f74d85d6 100644 (file)
@@ -1,3 +1,19 @@
+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:
+
 2010-10-04  Simon Fraser  <simon.fraser@apple.com>
 
         Color tests in the list based on existing pass/fail result.
index bffc860e22a879e6a174499b2399c6cfbd49ba2a..4f4c88fb9582647cd790277092d1e35482f6a7e3 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.
 
+import codecs
+import os
+
+
+def _test_expectations_overrides(port, super):
+    # The chrome ports use the regular overrides plus anything in the
+    # official test_expectations as well. Hopefully we don't get collisions.
+    chromium_overrides = super.test_expectations_overrides(port)
+
+    # FIXME: It used to be that AssertionError would get raised by
+    # path_from_chromium_base() if we weren't in a Chromium checkout, but
+    # 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):
+        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()
 
 def GetGoogleChromePort(**kwargs):
     """Some tests have slightly different results when compiled as Google
@@ -41,6 +63,11 @@ def GetGoogleChromePort(**kwargs):
                 paths.insert(0, self._webkit_baseline_path(
                     'google-chrome-linux32'))
                 return paths
+
+            def test_expectations_overrides(self):
+                return _test_expectations_overrides(self,
+                    chromium_linux.ChromiumLinuxPort)
+
         return GoogleChromeLinux32Port(**kwargs)
     elif port_name == 'google-chrome-linux64':
         import chromium_linux
@@ -52,6 +79,11 @@ def GetGoogleChromePort(**kwargs):
                 paths.insert(0, self._webkit_baseline_path(
                     'google-chrome-linux64'))
                 return paths
+
+            def test_expectations_overrides(self):
+                return _test_expectations_overrides(self,
+                    chromium_linux.ChromiumLinuxPort)
+
         return GoogleChromeLinux64Port(**kwargs)
     elif port_name.startswith('google-chrome-mac'):
         import chromium_mac
@@ -63,6 +95,11 @@ def GetGoogleChromePort(**kwargs):
                 paths.insert(0, self._webkit_baseline_path(
                     'google-chrome-mac'))
                 return paths
+
+            def test_expectations_overrides(self):
+                return _test_expectations_overrides(self,
+                    chromium_mac.ChromiumMacPort)
+
         return GoogleChromeMacPort(**kwargs)
     elif port_name.startswith('google-chrome-win'):
         import chromium_win
@@ -74,5 +111,10 @@ def GetGoogleChromePort(**kwargs):
                 paths.insert(0, self._webkit_baseline_path(
                     'google-chrome-win'))
                 return paths
+
+            def test_expectations_overrides(self):
+                return _test_expectations_overrides(self,
+                    chromium_win.ChromiumWinPort)
+
         return GoogleChromeWinPort(**kwargs)
     raise NotImplementedError('unsupported port: %s' % port_name)
index 85e9338722af687de7a1ec33b6b224dc6f9ebe54..fb924280c40d3a19b446caa47d9c3d758aa52e03 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.
 
+import codecs
 import os
 import unittest
+
+import base_unittest
+import factory
 import google_chrome
 
 
@@ -35,6 +39,7 @@ class GetGoogleChromePortTest(unittest.TestCase):
             'google-chrome-mac', 'google-chrome-win')
         for port in test_ports:
             self._verify_baseline_path(port, port)
+            self._verify_expectations_overrides(port)
 
         self._verify_baseline_path('google-chrome-mac', 'google-chrome-mac-leopard')
         self._verify_baseline_path('google-chrome-win', 'google-chrome-win-xp')
@@ -45,3 +50,50 @@ class GetGoogleChromePortTest(unittest.TestCase):
                                                  options=None)
         path = port.baseline_search_path()[0]
         self.assertEqual(expected_path, os.path.split(path)[1])
+
+    def _verify_expectations_overrides(self, port_name):
+        # FIXME: make this more robust when we have the Tree() abstraction.
+        # we should be able to test for the files existing or not, and
+        # be able to control the contents better.
+
+        chromium_port = factory.get("chromium-mac")
+        chromium_overrides = chromium_port.test_expectations_overrides()
+        port = google_chrome.GetGoogleChromePort(port_name=port_name,
+                                                 options=None)
+
+        orig_exists = os.path.exists
+        orig_open = codecs.open
+        expected_string = "// hello, world\n"
+
+        def mock_exists_chrome_not_found(path):
+            if 'test_expectations_chrome.txt' in path:
+                return False
+            return orig_exists(path)
+
+        def mock_exists_chrome_found(path):
+            if 'test_expectations_chrome.txt' in path:
+                return True
+            return orig_exists(path)
+
+        def mock_open(path, mode, encoding):
+            if 'test_expectations_chrome.txt' in path:
+                return base_unittest.NewStringIO(expected_string)
+            return orig_open(path, mode, encoding)
+
+        try:
+            os.path.exists = mock_exists_chrome_not_found
+            chrome_overrides = port.test_expectations_overrides()
+            self.assertEqual(chromium_overrides, chrome_overrides)
+
+            os.path.exists = mock_exists_chrome_found
+            codecs.open = mock_open
+            chrome_overrides = port.test_expectations_overrides()
+            self.assertEqual(chrome_overrides,
+                             chromium_overrides + expected_string)
+        finally:
+            os.path.exists = orig_exists
+            codecs.open = orig_open
+
+
+if __name__ == '__main__':
+    unittest.main()