2010-12-15 Cosmin Truta <ctruta@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Dec 2010 20:39:29 +0000 (20:39 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Dec 2010 20:39:29 +0000 (20:39 +0000)
        Reviewed by James Robinson.

        new-run-webkit-tests ignores trailing EOL differences in text tests
        https://bugs.webkit.org/show_bug.cgi?id=36983

        Changed the handling of new-line characters within new-run-webkit-tests
        to match old-run-webkit-tests.  Differences in leading and trailing empty
        lines in text expectation files are no longer ignored.

        * Scripts/webkitpy/layout_tests/port/base.py:
        * Scripts/webkitpy/layout_tests/port/test.py:
        Added unit tests.  Removed old duplicate unit test entries.
        * Scripts/webkitpy/layout_tests/test_types/text_diff.py:

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

WebKitTools/ChangeLog
WebKitTools/Scripts/webkitpy/layout_tests/port/base.py
WebKitTools/Scripts/webkitpy/layout_tests/port/test.py
WebKitTools/Scripts/webkitpy/layout_tests/test_types/text_diff.py

index 759ef77..f48b845 100644 (file)
@@ -1,3 +1,19 @@
+2010-12-15  Cosmin Truta  <ctruta@chromium.org>
+
+        Reviewed by James Robinson.
+
+        new-run-webkit-tests ignores trailing EOL differences in text tests
+        https://bugs.webkit.org/show_bug.cgi?id=36983
+
+        Changed the handling of new-line characters within new-run-webkit-tests
+        to match old-run-webkit-tests.  Differences in leading and trailing empty
+        lines in text expectation files are no longer ignored.
+
+        * Scripts/webkitpy/layout_tests/port/base.py:
+        * Scripts/webkitpy/layout_tests/port/test.py:
+        Added unit tests.  Removed old duplicate unit test entries.
+        * Scripts/webkitpy/layout_tests/test_types/text_diff.py:
+
 2010-12-15  Ojan Vafai  <ojan@chromium.org>
 
         Reviewed by Adam Barth.
index bc5a9aa..aa8b2e5 100644 (file)
@@ -322,7 +322,8 @@ class Port(object):
         return self._filesystem.read_binary_file(path)
 
     def expected_text(self, test):
-        """Returns the text output we expect the test to produce."""
+        """Returns the text output we expect the test to produce.
+        End-of-line characters are normalized to '\n'."""
         # FIXME: DRT output is actually utf-8, but since we don't decode the
         # output from DRT (instead treating it as a binary string), we read the
         # baselines as a binary string, too.
@@ -330,7 +331,7 @@ class Port(object):
         if not self.path_exists(path):
             return ''
         text = self._filesystem.read_binary_file(path)
-        return text.strip("\r\n").replace("\r\n", "\n") + "\n"
+        return text.replace("\r\n", "\n")
 
     def filename_to_uri(self, filename):
         """Convert a test file (which is an absolute path) to a URI."""
index 9e79667..f70b6d3 100644 (file)
@@ -90,8 +90,6 @@ class TestPort(base.Port):
     def __init__(self, **kwargs):
         base.Port.__init__(self, **kwargs)
         tests = TestList(self)
-        tests.add('passes/image.html')
-        tests.add('passes/text.html')
         tests.add('failures/expected/checksum.html',
                   actual_checksum='checksum_fail-checksum')
         tests.add('failures/expected/crash.html', crash=True)
@@ -114,6 +112,15 @@ class TestPort(base.Port):
                   expected_image=None)
         tests.add('failures/expected/missing_text.html',
                   expected_text=None)
+        tests.add('failures/expected/newlines_leading.html',
+                  expected_text="\nfoo\n",
+                  actual_text="foo\n")
+        tests.add('failures/expected/newlines_trailing.html',
+                  expected_text="foo\n\n",
+                  actual_text="foo\n")
+        tests.add('failures/expected/newlines_with_excess_CR.html',
+                  expected_text="foo\r\r\r\n",
+                  actual_text="foo\n")
         tests.add('failures/expected/text.html',
                   actual_text='text_fail-png')
         tests.add('failures/unexpected/text-image-checksum.html',
@@ -124,7 +131,11 @@ class TestPort(base.Port):
         tests.add('passes/error.html', error='stuff going to stderr')
         tests.add('passes/image.html')
         tests.add('passes/platform_image.html')
-        tests.add('passes/text.html')
+        # Text output files contain "\r\n" on Windows.  This may be
+        # helpfully filtered to "\r\r\n" by our Python/Cygwin tooling.
+        tests.add('passes/text.html',
+                  expected_text='\nfoo\n\n',
+                  actual_text='\nfoo\r\n\r\r\n')
         tests.add('websocket/tests/passes/text.html')
         self._tests = tests
 
@@ -270,6 +281,9 @@ WONTFIX : failures/expected/image_checksum.html = IMAGE
 WONTFIX : failures/expected/missing_check.html = MISSING PASS
 WONTFIX : failures/expected/missing_image.html = MISSING PASS
 WONTFIX : failures/expected/missing_text.html = MISSING PASS
+WONTFIX : failures/expected/newlines_leading.html = TEXT
+WONTFIX : failures/expected/newlines_trailing.html = TEXT
+WONTFIX : failures/expected/newlines_with_excess_CR.html = TEXT
 WONTFIX : failures/expected/text.html = TEXT
 WONTFIX : failures/expected/timeout.html = TIMEOUT
 WONTFIX SKIP : failures/expected/hang.html = TIMEOUT
index ca4b17d..ad25262 100644 (file)
@@ -49,11 +49,13 @@ _log = logging.getLogger("webkitpy.layout_tests.test_types.text_diff")
 class TestTextDiff(test_type_base.TestTypeBase):
 
     def _get_normalized_output_text(self, output):
-        # Some tests produce "\r\n" explicitly.  Our system (Python/Cygwin)
-        # helpfully changes the "\n" to "\r\n", resulting in "\r\r\n".
-        norm = output.replace("\r\r\n", "\r\n").strip("\r\n").replace(
-             "\r\n", "\n")
-        return norm + "\n"
+        """Returns the normalized text output, i.e. the output in which
+        the end-of-line characters are normalized to "\n"."""
+        # Running tests on Windows produces "\r\n".  The "\n" part is helpfully
+        # changed to "\r\n" by our system (Python/Cygwin), resulting in
+        # "\r\r\n", when, in fact, we wanted to compare the text output with
+        # the normalized text expectation files.
+        return output.replace("\r\r\n", "\r\n").replace("\r\n", "\n")
 
     def compare_output(self, port, filename, test_args, actual_test_output,
                         expected_test_output):