Remove wdiff
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Jan 2014 16:47:54 +0000 (16:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Jan 2014 16:47:54 +0000 (16:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124766

Patch by Daniel Batyai <dbatyai.u-szeged@partner.samsung.com> on 2014-01-13
Reviewed by Ryosuke Niwa.

* Scripts/webkitpy/common/net/resultsjsonparser_unittest.py:
(ResultsJSONParserTest):
* Scripts/webkitpy/layout_tests/controllers/test_result_writer.py:
(TestResultWriter):
(TestResultWriter.create_text_diff_and_write_result):
* Scripts/webkitpy/layout_tests/models/test_run_results.py:
(summarize_results):
* Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
(RunTest.test_output_diffs):
* Scripts/webkitpy/port/base.py:
(Port.__init__):
(Port.driver_stop_timeout):
(Port.check_image_diff):
(Port.repository_paths):
(Port._path_to_lighttpd_php):
* Scripts/webkitpy/port/base_unittest.py:
(PortTest.test_default_child_processes):
(PortTest.test_pretty_patch_script_error):
* Scripts/webkitpy/port/port_testcase.py:
(PortTestCase.test_diff_image_crashed):
* Scripts/webkitpy/port/test.py:
(TestPort.operating_system):

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

Tools/ChangeLog
Tools/Scripts/webkitpy/common/net/resultsjsonparser_unittest.py
Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py
Tools/Scripts/webkitpy/layout_tests/models/test_run_results.py
Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py
Tools/Scripts/webkitpy/port/base.py
Tools/Scripts/webkitpy/port/base_unittest.py
Tools/Scripts/webkitpy/port/port_testcase.py
Tools/Scripts/webkitpy/port/test.py

index a8ddc443485a0427eec17daf90c516bdde7d9228..e5062e0b627c20930080371be1cf93d11371a33b 100644 (file)
@@ -1,3 +1,33 @@
+2014-01-13  Daniel Batyai  <dbatyai.u-szeged@partner.samsung.com>
+
+        Remove wdiff
+        https://bugs.webkit.org/show_bug.cgi?id=124766
+
+        Reviewed by Ryosuke Niwa.
+
+        * Scripts/webkitpy/common/net/resultsjsonparser_unittest.py:
+        (ResultsJSONParserTest):
+        * Scripts/webkitpy/layout_tests/controllers/test_result_writer.py:
+        (TestResultWriter):
+        (TestResultWriter.create_text_diff_and_write_result):
+        * Scripts/webkitpy/layout_tests/models/test_run_results.py:
+        (summarize_results):
+        * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
+        (RunTest.test_output_diffs):
+        * Scripts/webkitpy/port/base.py:
+        (Port.__init__):
+        (Port.driver_stop_timeout):
+        (Port.check_image_diff):
+        (Port.repository_paths):
+        (Port._path_to_lighttpd_php):
+        * Scripts/webkitpy/port/base_unittest.py:
+        (PortTest.test_default_child_processes):
+        (PortTest.test_pretty_patch_script_error):
+        * Scripts/webkitpy/port/port_testcase.py:
+        (PortTestCase.test_diff_image_crashed):
+        * Scripts/webkitpy/port/test.py:
+        (TestPort.operating_system):
+
 2014-01-13  Martin Robinson  <mrobinson@igalia.com>
 
         Build fix for the GTK+ CMake port
index aaeb5dc6d96abf6c5171fd466f47f1b95cac8d17..5e7d3a68e7c5f65502ffab43d738fb341770348b 100644 (file)
@@ -80,8 +80,7 @@ class ResultsJSONParserTest(unittest.TestCase):
     "has_pretty_patch": false,
     "fixable": 1220,
     "num_flaky": 0,
-    "uses_expectations_file": true,
-    "has_wdiff": false
+    "uses_expectations_file": true
 });"""
 
     def test_basic(self):
index b5ad9b18fbe7c9c8bc13decaf343b33b46e6ddbe..932b22e57fd028d7d3342a9b40decb8fc71321c0 100644 (file)
@@ -57,7 +57,6 @@ class TestResultWriter(object):
     FILENAME_SUFFIX_STDERR = "-stderr"
     FILENAME_SUFFIX_CRASH_LOG = "-crash-log"
     FILENAME_SUFFIX_SAMPLE = "-sample"
-    FILENAME_SUFFIX_WDIFF = "-wdiff.html"
     FILENAME_SUFFIX_PRETTY_PATCH = "-pretty-diff.html"
     FILENAME_SUFFIX_IMAGE_DIFF = "-diff.png"
     FILENAME_SUFFIX_IMAGE_DIFFS_HTML = "-diffs.html"
@@ -153,12 +152,6 @@ class TestResultWriter(object):
         diff_filename = self.output_filename(self.FILENAME_SUFFIX_DIFF + file_type)
         self._write_binary_file(diff_filename, diff)
 
-        # Shell out to wdiff to get colored inline diffs.
-        if self._port.wdiff_available():
-            wdiff = self._port.wdiff_text(expected_filename, actual_filename)
-            wdiff_filename = self.output_filename(self.FILENAME_SUFFIX_WDIFF)
-            self._write_binary_file(wdiff_filename, wdiff)
-
         # Use WebKit's PrettyPatch.rb to get an HTML diff.
         if self._port.pretty_patch.pretty_patch_available():
             pretty_patch = self._port.pretty_patch.pretty_patch_text(diff_filename)
index 43d1ec9f9cc4d6a4e22c96c428e40291f6ac9b87..f811f3873efc5b4ecf4c2d1ef1fc0b6e260b4557 100644 (file)
@@ -249,7 +249,6 @@ def summarize_results(port_obj, expectations, initial_results, retry_results, en
     results['uses_expectations_file'] = port_obj.uses_test_expectations_file()
     results['interrupted'] = initial_results.interrupted  # Does results.html have enough information to compute this itself? (by checking total number of results vs. total number of tests?)
     results['layout_tests_dir'] = port_obj.layout_tests_dir()
-    results['has_wdiff'] = port_obj.wdiff_available()
     results['has_pretty_patch'] = port_obj.pretty_patch.pretty_patch_available()
     results['pixel_tests_enabled'] = port_obj.get_option('pixel_tests')
 
index 5678b0099dac2efed7d29b3dcd7e5d2405ad35f5..be114317283dc2cf158b2df61d2ce6e6ebfdade7 100644 (file)
@@ -794,18 +794,15 @@ class RunTest(unittest.TestCase, StreamTestingMixin):
         self.assertFalse('platform/test-win-win7/http/test.html' in tests_run)
 
     def test_output_diffs(self):
-        # Test to ensure that we don't generate -wdiff.html or -pretty.html if wdiff and PrettyPatch
-        # aren't available.
+        # Test to ensure that we don't generate -pretty.html if PrettyPatch isn't available.
         host = MockHost()
         _, err, _ = logging_run(['--pixel-tests', 'failures/unexpected/text-image-checksum.html'], tests_included=True, host=host)
         written_files = host.filesystem.written_files
         self.assertTrue(any(path.endswith('-diff.txt') for path in written_files.keys()))
-        self.assertFalse(any(path.endswith('-wdiff.html') for path in written_files.keys()))
         self.assertFalse(any(path.endswith('-pretty-diff.html') for path in written_files.keys()))
 
         full_results_text = host.filesystem.read_text_file('/tmp/layout-test-results/full_results.json')
         full_results = json.loads(full_results_text.replace("ADD_RESULTS(", "").replace(");", ""))
-        self.assertEqual(full_results['has_wdiff'], False)
         self.assertEqual(full_results['has_pretty_patch'], False)
 
     def test_unsupported_platform(self):
index 1675ef89cf0c8834a62c8d74f10b21d5c830881a..e7212e5d6c03cf78eb13208a5b67033242b28044 100644 (file)
@@ -126,21 +126,6 @@ class Port(object):
         self._server_process_constructor = server_process.ServerProcess  # overridable for testing
         self._http_lock = None  # FIXME: Why does this live on the port object?
 
-        # Python's Popen has a bug that causes any pipes opened to a
-        # process that can't be executed to be leaked.  Since this
-        # code is specifically designed to tolerate exec failures
-        # to gracefully handle cases where wdiff is not installed,
-        # the bug results in a massive file descriptor leak. As a
-        # workaround, if an exec failure is ever experienced for
-        # wdiff, assume it's not available.  This will leak one
-        # file descriptor but that's better than leaking each time
-        # wdiff would be run.
-        #
-        # http://mail.python.org/pipermail/python-list/
-        #    2008-August/505753.html
-        # http://bugs.python.org/issue3210
-        self._wdiff_available = None
-
         if not hasattr(options, 'configuration') or not options.configuration:
             self.set_option_default('configuration', self.default_configuration())
         self._test_configuration = None
@@ -171,11 +156,6 @@ class Port(object):
         # well (for things like ASAN, Valgrind, etc.)
         return 3.0 * float(self.get_option('time_out_ms', '0')) / self.default_timeout_ms()
 
-    def wdiff_available(self):
-        if self._wdiff_available is None:
-            self._wdiff_available = self.check_wdiff(logging=False)
-        return self._wdiff_available
-
     def should_retry_crashes(self):
         return False
 
@@ -274,27 +254,6 @@ class Port(object):
             return False
         return True
 
-    def check_wdiff(self, logging=True):
-        if not self._path_to_wdiff():
-            # Don't need to log here since this is the port choosing not to use wdiff.
-            return False
-
-        try:
-            _ = self._executive.run_command([self._path_to_wdiff(), '--help'])
-        except OSError:
-            if logging:
-                message = self._wdiff_missing_message()
-                if message:
-                    for line in message.splitlines():
-                        _log.warning('    ' + line)
-                        _log.warning('')
-            return False
-
-        return True
-
-    def _wdiff_missing_message(self):
-        return 'wdiff is not installed; please install it to generate word-by-word diffs.'
-
     def check_httpd(self):
         if self._uses_apache():
             httpd_path = self._path_to_apache()
@@ -1075,61 +1034,6 @@ class Port(object):
             repository_paths += [(self._options.additional_repository_name, self._options.additional_repository_path)]
         return repository_paths
 
-    _WDIFF_DEL = '##WDIFF_DEL##'
-    _WDIFF_ADD = '##WDIFF_ADD##'
-    _WDIFF_END = '##WDIFF_END##'
-
-    def _format_wdiff_output_as_html(self, wdiff):
-        wdiff = cgi.escape(wdiff)
-        wdiff = wdiff.replace(self._WDIFF_DEL, "<span class=del>")
-        wdiff = wdiff.replace(self._WDIFF_ADD, "<span class=add>")
-        wdiff = wdiff.replace(self._WDIFF_END, "</span>")
-        html = "<head><style>.del { background: #faa; } "
-        html += ".add { background: #afa; }</style></head>"
-        html += "<pre>%s</pre>" % wdiff
-        return html
-
-    def _wdiff_command(self, actual_filename, expected_filename):
-        executable = self._path_to_wdiff()
-        return [executable,
-                "--start-delete=%s" % self._WDIFF_DEL,
-                "--end-delete=%s" % self._WDIFF_END,
-                "--start-insert=%s" % self._WDIFF_ADD,
-                "--end-insert=%s" % self._WDIFF_END,
-                actual_filename,
-                expected_filename]
-
-    @staticmethod
-    def _handle_wdiff_error(script_error):
-        # Exit 1 means the files differed, any other exit code is an error.
-        if script_error.exit_code != 1:
-            raise script_error
-
-    def _run_wdiff(self, actual_filename, expected_filename):
-        """Runs wdiff and may throw exceptions.
-        This is mostly a hook for unit testing."""
-        # Diffs are treated as binary as they may include multiple files
-        # with conflicting encodings.  Thus we do not decode the output.
-        command = self._wdiff_command(actual_filename, expected_filename)
-        wdiff = self._executive.run_command(command, decode_output=False,
-            error_handler=self._handle_wdiff_error)
-        return self._format_wdiff_output_as_html(wdiff)
-
-    def wdiff_text(self, actual_filename, expected_filename):
-        """Returns a string of HTML indicating the word-level diff of the
-        contents of the two filenames. Returns an empty string if word-level
-        diffing isn't available."""
-        if not self.wdiff_available():
-            return ""
-        try:
-            # It's possible to raise a ScriptError we pass wdiff invalid paths.
-            return self._run_wdiff(actual_filename, expected_filename)
-        except OSError, e:
-            if e.errno in [errno.ENOENT, errno.EACCES, errno.ECHILD]:
-                # Silently ignore cases where wdiff is missing.
-                self._wdiff_available = False
-                return ""
-            raise
 
     def default_configuration(self):
         return self._config.default_configuration()
@@ -1263,16 +1167,6 @@ class Port(object):
         This is needed only by ports that use the http_server.py module."""
         raise NotImplementedError('Port._path_to_lighttpd_php')
 
-    @memoized
-    def _path_to_wdiff(self):
-        """Returns the full path to the wdiff binary, or None if it is not available.
-
-        This is likely used only by wdiff_text()"""
-        for path in ("/usr/bin/wdiff", "/usr/bin/dwdiff"):
-            if self._filesystem.exists(path):
-                return path
-        return None
-
     def _webkit_baseline_path(self, platform):
         """Return the  full path to the top of the baseline tree for a
         given platform."""
index e2da5c60c053b839bb74ce9afc9f762f8bd481e6..7d3da0ed1358b263a17b5659f4b4fa2cbaf7a09e 100644 (file)
@@ -59,27 +59,6 @@ class PortTest(unittest.TestCase):
         port = self.make_port()
         self.assertIsNotNone(port.default_child_processes())
 
-    def test_format_wdiff_output_as_html(self):
-        output = "OUTPUT %s %s %s" % (Port._WDIFF_DEL, Port._WDIFF_ADD, Port._WDIFF_END)
-        html = self.make_port()._format_wdiff_output_as_html(output)
-        expected_html = "<head><style>.del { background: #faa; } .add { background: #afa; }</style></head><pre>OUTPUT <span class=del> <span class=add> </span></pre>"
-        self.assertEqual(html, expected_html)
-
-    def test_wdiff_command(self):
-        port = self.make_port()
-        port._path_to_wdiff = lambda: "/path/to/wdiff"
-        command = port._wdiff_command("/actual/path", "/expected/path")
-        expected_command = [
-            "/path/to/wdiff",
-            "--start-delete=##WDIFF_DEL##",
-            "--end-delete=##WDIFF_END##",
-            "--start-insert=##WDIFF_ADD##",
-            "--end-insert=##WDIFF_END##",
-            "/actual/path",
-            "/expected/path",
-        ]
-        self.assertEqual(command, expected_command)
-
     def _file_with_contents(self, contents, encoding="utf-8"):
         new_file = tempfile.NamedTemporaryFile()
         new_file.write(contents.encode(encoding))
@@ -109,55 +88,6 @@ class PortTest(unittest.TestCase):
         self.assertEqual(port.pretty_patch.pretty_patch_text("patch.txt"),
                          port.pretty_patch.pretty_patch_error_html)
 
-    def integration_test_run_wdiff(self):
-        executive = Executive()
-        # This may fail on some systems.  We could ask the port
-        # object for the wdiff path, but since we don't know what
-        # port object to use, this is sufficient for now.
-        try:
-            wdiff_path = executive.run_command(["which", "wdiff"]).rstrip()
-        except Exception, e:
-            wdiff_path = None
-
-        port = self.make_port(executive=executive)
-        port._path_to_wdiff = lambda: wdiff_path
-
-        if wdiff_path:
-            # "with tempfile.NamedTemporaryFile() as actual" does not seem to work in Python 2.5
-            actual = self._file_with_contents(u"foo")
-            expected = self._file_with_contents(u"bar")
-            wdiff = port._run_wdiff(actual.name, expected.name)
-            expected_wdiff = "<head><style>.del { background: #faa; } .add { background: #afa; }</style></head><pre><span class=del>foo</span><span class=add>bar</span></pre>"
-            self.assertEqual(wdiff, expected_wdiff)
-            # Running the full wdiff_text method should give the same result.
-            port._wdiff_available = True  # In case it's somehow already disabled.
-            wdiff = port.wdiff_text(actual.name, expected.name)
-            self.assertEqual(wdiff, expected_wdiff)
-            # wdiff should still be available after running wdiff_text with a valid diff.
-            self.assertTrue(port._wdiff_available)
-            actual.close()
-            expected.close()
-
-            # Bogus paths should raise a script error.
-            self.assertRaises(ScriptError, port._run_wdiff, "/does/not/exist", "/does/not/exist2")
-            self.assertRaises(ScriptError, port.wdiff_text, "/does/not/exist", "/does/not/exist2")
-            # wdiff will still be available after running wdiff_text with invalid paths.
-            self.assertTrue(port._wdiff_available)
-
-        # If wdiff does not exist _run_wdiff should throw an OSError.
-        port._path_to_wdiff = lambda: "/invalid/path/to/wdiff"
-        self.assertRaises(OSError, port._run_wdiff, "foo", "bar")
-
-        # wdiff_text should not throw an error if wdiff does not exist.
-        self.assertEqual(port.wdiff_text("foo", "bar"), "")
-        # However wdiff should not be available after running wdiff_text if wdiff is missing.
-        self.assertFalse(port._wdiff_available)
-
-    def test_wdiff_text(self):
-        port = self.make_port()
-        port.wdiff_available = lambda: True
-        port._run_wdiff = lambda a, b: 'PASS'
-        self.assertEqual('PASS', port.wdiff_text(None, None))
 
     def test_diff_text(self):
         port = self.make_port()
index 63cc1e9904920626416bc6c31b49e8f59ee08f1b..239e7a0817abbf58c4825d7cb0d6a21d9613bcc3 100644 (file)
@@ -291,10 +291,6 @@ class PortTestCase(unittest.TestCase):
         self.assertEqual(port.diff_image('foo', 'bar'), ('', 0, 'ImageDiff crashed\n'))
         port.clean_up_test_run()
 
-    def test_check_wdiff(self):
-        port = self.make_port()
-        port.check_wdiff()
-
     def integration_test_websocket_server__normal(self):
         port = self.make_port()
         self.assert_servers_are_down('localhost', self.WEBSOCKET_PORTS)
index 76fea3ba182853f4d5badf54248a7a2d51a84557..362a0e877900b2f9dcc78111d4e77227bcb8acf9 100644 (file)
@@ -451,9 +451,6 @@ class TestPort(Port):
     def operating_system(self):
         return self._operating_system
 
-    def _path_to_wdiff(self):
-        return None
-
     def default_results_directory(self):
         return '/tmp/layout-test-results'