<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[160271] trunk/Tools</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/160271">160271</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2013-12-07 06:54:15 -0800 (Sat, 07 Dec 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move PrettyPatch related code to prettypatch.py
https://bugs.webkit.org/show_bug.cgi?id=124937
Patch by Dániel Bátyai <Batyai.Daniel@stud.u-szeged.hu> on 2013-12-07
Reviewed by Ryosuke Niwa.
This code seems to have a better place here than in Port, since PrettyPatch already knows
pretty_patch_path, and this also unifies the usage of PrettyPatch
* Scripts/webkitpy/common/prettypatch.py:
(PrettyPatch.__init__):
(PrettyPatch.pretty_diff):
(PrettyPatch):
(PrettyPatch.pretty_patch_available):
(PrettyPatch.check_pretty_patch):
(PrettyPatch.pretty_patch_text):
* Scripts/webkitpy/layout_tests/controllers/test_result_writer.py:
(TestResultWriter.create_text_diff_and_write_result):
* Scripts/webkitpy/layout_tests/models/test_run_results.py:
(summarize_results):
* Scripts/webkitpy/port/base.py:
(Port.__init__):
(Port.wdiff_available):
(Port.check_image_diff):
(Port.wdiff_text):
* Scripts/webkitpy/port/base_unittest.py:
(PortTest.test_pretty_patch_os_error):
(PortTest.test_pretty_patch_script_error):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitpycommonprettypatchpy">trunk/Tools/Scripts/webkitpy/common/prettypatch.py</a></li>
<li><a href="#trunkToolsScriptswebkitpylayout_testscontrollerstest_result_writerpy">trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py</a></li>
<li><a href="#trunkToolsScriptswebkitpylayout_testsmodelstest_run_resultspy">trunk/Tools/Scripts/webkitpy/layout_tests/models/test_run_results.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyportbasepy">trunk/Tools/Scripts/webkitpy/port/base.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyportbase_unittestpy">trunk/Tools/Scripts/webkitpy/port/base_unittest.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (160270 => 160271)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2013-12-07 13:03:10 UTC (rev 160270)
+++ trunk/Tools/ChangeLog        2013-12-07 14:54:15 UTC (rev 160271)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2013-12-07 Dániel Bátyai <Batyai.Daniel@stud.u-szeged.hu>
+
+ Move PrettyPatch related code to prettypatch.py
+ https://bugs.webkit.org/show_bug.cgi?id=124937
+
+ Reviewed by Ryosuke Niwa.
+
+ This code seems to have a better place here than in Port, since PrettyPatch already knows
+ pretty_patch_path, and this also unifies the usage of PrettyPatch
+
+ * Scripts/webkitpy/common/prettypatch.py:
+ (PrettyPatch.__init__):
+ (PrettyPatch.pretty_diff):
+ (PrettyPatch):
+ (PrettyPatch.pretty_patch_available):
+ (PrettyPatch.check_pretty_patch):
+ (PrettyPatch.pretty_patch_text):
+ * Scripts/webkitpy/layout_tests/controllers/test_result_writer.py:
+ (TestResultWriter.create_text_diff_and_write_result):
+ * Scripts/webkitpy/layout_tests/models/test_run_results.py:
+ (summarize_results):
+ * Scripts/webkitpy/port/base.py:
+ (Port.__init__):
+ (Port.wdiff_available):
+ (Port.check_image_diff):
+ (Port.wdiff_text):
+ * Scripts/webkitpy/port/base_unittest.py:
+ (PortTest.test_pretty_patch_os_error):
+ (PortTest.test_pretty_patch_script_error):
+
</ins><span class="cx"> 2013-12-06 Dan Bernstein <mitz@apple.com>
</span><span class="cx">
</span><span class="cx"> [Mac] MiniBrowser Debug builds are compiled with -Os
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpycommonprettypatchpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/common/prettypatch.py (160270 => 160271)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/common/prettypatch.py        2013-12-07 13:03:10 UTC (rev 160270)
+++ trunk/Tools/Scripts/webkitpy/common/prettypatch.py        2013-12-07 14:54:15 UTC (rev 160271)
</span><span class="lines">@@ -26,15 +26,25 @@
</span><span class="cx"> # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
</span><span class="cx"> # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">
</span><ins>+import errno
+import logging
</ins><span class="cx"> import os
</span><span class="cx"> import tempfile
</span><ins>+from webkitpy.common.system.executive import ScriptError
</ins><span class="cx">
</span><ins>+_log = logging.getLogger(__name__)
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> class PrettyPatch(object):
</span><span class="cx"> # FIXME: PrettyPatch should not require checkout_root.
</span><del>- def __init__(self, executive, checkout_root):
</del><ins>+ def __init__(self, executive, checkout_root, filesystem=None):
</ins><span class="cx"> self._executive = executive
</span><ins>+ self._filesystem = filesystem
</ins><span class="cx"> self._checkout_root = checkout_root
</span><ins>+ self._pretty_patch_path = os.path.join(self._checkout_root, "Websites", "bugs.webkit.org", "PrettyPatch")
+ self._prettify_path = os.path.join(self._pretty_patch_path, "prettify.rb")
+ self.pretty_patch_error_html = "Failed to run PrettyPatch, see error log."
+ self.ppatch_available = None
</ins><span class="cx">
</span><span class="cx"> def pretty_diff_file(self, diff):
</span><span class="cx"> # Diffs can contain multiple text files of different encodings
</span><span class="lines">@@ -52,16 +62,59 @@
</span><span class="cx"> if not diff:
</span><span class="cx"> return ""
</span><span class="cx">
</span><del>- pretty_patch_path = os.path.join(self._checkout_root,
- "Websites", "bugs.webkit.org",
- "PrettyPatch")
- prettify_path = os.path.join(pretty_patch_path, "prettify.rb")
</del><span class="cx"> args = [
</span><span class="cx"> "ruby",
</span><span class="cx"> "-I",
</span><del>- pretty_patch_path,
- prettify_path,
</del><ins>+ self._pretty_patch_path,
+ self._prettify_path,
</ins><span class="cx"> ]
</span><span class="cx"> # PrettyPatch does not modify the encoding of the diff output
</span><span class="cx"> # so we can't expect it to be utf-8.
</span><span class="cx"> return self._executive.run_command(args, input=diff, decode_output=False)
</span><ins>+
+ def pretty_patch_available(self):
+ if self.ppatch_available is None:
+ self.ppatch_available = self.check_pretty_patch(logging=False)
+ return self.ppatch_available
+
+ def check_pretty_patch(self, logging=True):
+ """Checks whether we can use the PrettyPatch ruby script."""
+ try:
+ _ = self._executive.run_command(['ruby', '--version'])
+ except OSError, e:
+ if e.errno in [errno.ENOENT, errno.EACCES, errno.ECHILD]:
+ if logging:
+ _log.warning("Ruby is not installed; can't generate pretty patches.")
+ _log.warning('')
+ return False
+
+ if not self._filesystem.exists(self._pretty_patch_path):
+ if logging:
+ _log.warning("Unable to find %s; can't generate pretty patches." % self._pretty_patch_path)
+ _log.warning('')
+ return False
+
+ return True
+
+ def pretty_patch_text(self, diff_path):
+ if self.ppatch_available is None:
+ self.ppatch_available = self.check_pretty_patch(logging=False)
+ if not self.ppatch_available:
+ return self.pretty_patch_error_html
+ command = ("ruby", "-I", self._filesystem.dirname(self._prettify_path),
+ self._prettify_path, diff_path)
+ try:
+ # Diffs are treated as binary (we pass decode_output=False) as they
+ # may contain multiple files of conflicting encodings.
+ return self._executive.run_command(command, decode_output=False)
+ except OSError, e:
+ # If the system is missing ruby log the error and stop trying.
+ self.ppatch_available = False
+ _log.error("Failed to run PrettyPatch (%s): %s" % (command, e))
+ return self.pretty_patch_error_html
+ except ScriptError, e:
+ # If ruby failed to run for some reason, log the command
+ # output and stop trying.
+ self.ppatch_available = False
+ _log.error("Failed to run PrettyPatch (%s):\n%s" % (command, e.message_with_output()))
+ return self.pretty_patch_error_html
</ins></span></pre></div>
<a id="trunkToolsScriptswebkitpylayout_testscontrollerstest_result_writerpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py (160270 => 160271)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py        2013-12-07 13:03:10 UTC (rev 160270)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py        2013-12-07 14:54:15 UTC (rev 160271)
</span><span class="lines">@@ -160,8 +160,8 @@
</span><span class="cx"> self._write_binary_file(wdiff_filename, wdiff)
</span><span class="cx">
</span><span class="cx"> # Use WebKit's PrettyPatch.rb to get an HTML diff.
</span><del>- if self._port.pretty_patch_available():
- pretty_patch = self._port.pretty_patch_text(diff_filename)
</del><ins>+ if self._port.pretty_patch.pretty_patch_available():
+ pretty_patch = self._port.pretty_patch.pretty_patch_text(diff_filename)
</ins><span class="cx"> pretty_patch_filename = self.output_filename(self.FILENAME_SUFFIX_PRETTY_PATCH)
</span><span class="cx"> self._write_binary_file(pretty_patch_filename, pretty_patch)
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpylayout_testsmodelstest_run_resultspy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_run_results.py (160270 => 160271)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_run_results.py        2013-12-07 13:03:10 UTC (rev 160270)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_run_results.py        2013-12-07 14:54:15 UTC (rev 160271)
</span><span class="lines">@@ -243,7 +243,7 @@
</span><span class="cx"> 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?)
</span><span class="cx"> results['layout_tests_dir'] = port_obj.layout_tests_dir()
</span><span class="cx"> results['has_wdiff'] = port_obj.wdiff_available()
</span><del>- results['has_pretty_patch'] = port_obj.pretty_patch_available()
</del><ins>+ results['has_pretty_patch'] = port_obj.pretty_patch.pretty_patch_available()
</ins><span class="cx"> results['pixel_tests_enabled'] = port_obj.get_option('pixel_tests')
</span><span class="cx">
</span><span class="cx"> try:
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportbasepy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/base.py (160270 => 160271)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/base.py        2013-12-07 13:03:10 UTC (rev 160270)
+++ trunk/Tools/Scripts/webkitpy/port/base.py        2013-12-07 14:54:15 UTC (rev 160271)
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx"> from webkitpy.common import find_files
</span><span class="cx"> from webkitpy.common import read_checksum_from_png
</span><span class="cx"> from webkitpy.common.memoized import memoized
</span><ins>+from webkitpy.common.prettypatch import PrettyPatch
</ins><span class="cx"> from webkitpy.common.system import path
</span><span class="cx"> from webkitpy.common.system.executive import ScriptError
</span><span class="cx"> from webkitpy.common.system.systemhost import SystemHost
</span><span class="lines">@@ -116,6 +117,7 @@
</span><span class="cx"> self._filesystem = host.filesystem
</span><span class="cx"> self._webkit_finder = WebKitFinder(host.filesystem)
</span><span class="cx"> self._config = port_config.Config(self._executive, self._filesystem, self.port_name)
</span><ins>+ self.pretty_patch = PrettyPatch(self._executive, self.path_from_webkit_base(), self._filesystem)
</ins><span class="cx">
</span><span class="cx"> self._helper = None
</span><span class="cx"> self._http_server = None
</span><span class="lines">@@ -139,10 +141,6 @@
</span><span class="cx"> # http://bugs.python.org/issue3210
</span><span class="cx"> self._wdiff_available = None
</span><span class="cx">
</span><del>- # FIXME: prettypatch.py knows this path, why is it copied here?
- self._pretty_patch_path = self.path_from_webkit_base("Websites", "bugs.webkit.org", "PrettyPatch", "prettify.rb")
- self._pretty_patch_available = None
-
</del><span class="cx"> if not hasattr(options, 'configuration') or not options.configuration:
</span><span class="cx"> self.set_option_default('configuration', self.default_configuration())
</span><span class="cx"> self._test_configuration = None
</span><span class="lines">@@ -178,11 +176,6 @@
</span><span class="cx"> self._wdiff_available = self.check_wdiff(logging=False)
</span><span class="cx"> return self._wdiff_available
</span><span class="cx">
</span><del>- def pretty_patch_available(self):
- if self._pretty_patch_available is None:
- self._pretty_patch_available = self.check_pretty_patch(logging=False)
- return self._pretty_patch_available
-
</del><span class="cx"> def should_retry_crashes(self):
</span><span class="cx"> return False
</span><span class="cx">
</span><span class="lines">@@ -281,25 +274,6 @@
</span><span class="cx"> return False
</span><span class="cx"> return True
</span><span class="cx">
</span><del>- def check_pretty_patch(self, logging=True):
- """Checks whether we can use the PrettyPatch ruby script."""
- try:
- _ = self._executive.run_command(['ruby', '--version'])
- except OSError, e:
- if e.errno in [errno.ENOENT, errno.EACCES, errno.ECHILD]:
- if logging:
- _log.warning("Ruby is not installed; can't generate pretty patches.")
- _log.warning('')
- return False
-
- if not self._filesystem.exists(self._pretty_patch_path):
- if logging:
- _log.warning("Unable to find %s; can't generate pretty patches." % self._pretty_patch_path)
- _log.warning('')
- return False
-
- return True
-
</del><span class="cx"> def check_wdiff(self, logging=True):
</span><span class="cx"> if not self._path_to_wdiff():
</span><span class="cx"> # Don't need to log here since this is the port choosing not to use wdiff.
</span><span class="lines">@@ -1154,32 +1128,6 @@
</span><span class="cx"> return ""
</span><span class="cx"> raise
</span><span class="cx">
</span><del>- # This is a class variable so we can test error output easily.
- _pretty_patch_error_html = "Failed to run PrettyPatch, see error log."
-
- def pretty_patch_text(self, diff_path):
- if self._pretty_patch_available is None:
- self._pretty_patch_available = self.check_pretty_patch(logging=False)
- if not self._pretty_patch_available:
- return self._pretty_patch_error_html
- command = ("ruby", "-I", self._filesystem.dirname(self._pretty_patch_path),
- self._pretty_patch_path, diff_path)
- try:
- # Diffs are treated as binary (we pass decode_output=False) as they
- # may contain multiple files of conflicting encodings.
- return self._executive.run_command(command, decode_output=False)
- except OSError, e:
- # If the system is missing ruby log the error and stop trying.
- self._pretty_patch_available = False
- _log.error("Failed to run PrettyPatch (%s): %s" % (command, e))
- return self._pretty_patch_error_html
- except ScriptError, e:
- # If ruby failed to run for some reason, log the command
- # output and stop trying.
- self._pretty_patch_available = False
- _log.error("Failed to run PrettyPatch (%s):\n%s" % (command, e.message_with_output()))
- return self._pretty_patch_error_html
-
</del><span class="cx"> def default_configuration(self):
</span><span class="cx"> return self._config.default_configuration()
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportbase_unittestpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/base_unittest.py (160270 => 160271)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/base_unittest.py        2013-12-07 13:03:10 UTC (rev 160270)
+++ trunk/Tools/Scripts/webkitpy/port/base_unittest.py        2013-12-07 14:54:15 UTC (rev 160271)
</span><span class="lines">@@ -90,24 +90,24 @@
</span><span class="cx"> port = self.make_port(executive=executive_mock.MockExecutive2(exception=OSError))
</span><span class="cx"> oc = OutputCapture()
</span><span class="cx"> oc.capture_output()
</span><del>- self.assertEqual(port.pretty_patch_text("patch.txt"),
- port._pretty_patch_error_html)
</del><ins>+ self.assertEqual(port.pretty_patch.pretty_patch_text("patch.txt"),
+ port.pretty_patch.pretty_patch_error_html)
</ins><span class="cx">
</span><span class="cx"> # This tests repeated calls to make sure we cache the result.
</span><del>- self.assertEqual(port.pretty_patch_text("patch.txt"),
- port._pretty_patch_error_html)
</del><ins>+ self.assertEqual(port.pretty_patch.pretty_patch_text("patch.txt"),
+ port.pretty_patch.pretty_patch_error_html)
</ins><span class="cx"> oc.restore_output()
</span><span class="cx">
</span><span class="cx"> def test_pretty_patch_script_error(self):
</span><span class="cx"> # FIXME: This is some ugly white-box test hacking ...
</span><span class="cx"> port = self.make_port(executive=executive_mock.MockExecutive2(exception=ScriptError))
</span><del>- port._pretty_patch_available = True
- self.assertEqual(port.pretty_patch_text("patch.txt"),
- port._pretty_patch_error_html)
</del><ins>+ port.pretty_patch.ppatch_available = True
+ self.assertEqual(port.pretty_patch.pretty_patch_text("patch.txt"),
+ port.pretty_patch.pretty_patch_error_html)
</ins><span class="cx">
</span><span class="cx"> # This tests repeated calls to make sure we cache the result.
</span><del>- self.assertEqual(port.pretty_patch_text("patch.txt"),
- port._pretty_patch_error_html)
</del><ins>+ self.assertEqual(port.pretty_patch.pretty_patch_text("patch.txt"),
+ port.pretty_patch.pretty_patch_error_html)
</ins><span class="cx">
</span><span class="cx"> def integration_test_run_wdiff(self):
</span><span class="cx"> executive = Executive()
</span></span></pre>
</div>
</div>
</body>
</html>