summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-08 21:00:09 +0000
committerevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-08 21:00:09 +0000
commite9030d02f2244866304e21126c0cfa4480c28dbb (patch)
treec8b9b6a8be8cbaa0fb549c806140e25cc6f8f925 /webkit
parent0a6ad51db5ac8b5731386e1d0d4cacc61bc93dd8 (diff)
downloadchromium_src-e9030d02f2244866304e21126c0cfa4480c28dbb.zip
chromium_src-e9030d02f2244866304e21126c0cfa4480c28dbb.tar.gz
chromium_src-e9030d02f2244866304e21126c0cfa4480c28dbb.tar.bz2
Use wdiff to produce expected output.
It's enabled by a --wdiff flag to run_webkit_tests. (DEPS update is to pull in new cygwin with wdiff.exe.) Example output: http://neugierig.org/drop/inline-crash-wdiff-win.html Review URL: http://codereview.chromium.org/6330 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3048 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/tools/layout_tests/layout_package/test_failures.py8
-rw-r--r--webkit/tools/layout_tests/run_webkit_tests.py6
-rw-r--r--webkit/tools/layout_tests/test_types/test_type_base.py33
-rw-r--r--webkit/tools/layout_tests/test_types/text_diff.py3
4 files changed, 43 insertions, 7 deletions
diff --git a/webkit/tools/layout_tests/layout_package/test_failures.py b/webkit/tools/layout_tests/layout_package/test_failures.py
index 25fcf33..a70dc53 100644
--- a/webkit/tools/layout_tests/layout_package/test_failures.py
+++ b/webkit/tools/layout_tests/layout_package/test_failures.py
@@ -65,7 +65,8 @@ class FailureWithType(TestFailure):
Args:
filename: the test filename, used to construct the result file names
out_names: list of filename suffixes for the files. If three or more
- suffixes are in the list, they should be [actual, expected, diff].
+ suffixes are in the list, they should be [actual, expected, diff,
+ wdiff].
Two suffixes should be [actual, expected], and a single item is the
[actual] filename suffix. If out_names is empty, returns the empty
string.
@@ -79,6 +80,8 @@ class FailureWithType(TestFailure):
links.append("<a href='%s'>actual</a>" % uris[0])
if len(uris) > 2:
links.append("<a href='%s'>diff</a>" % uris[2])
+ if len(uris) > 3:
+ links.append("<a href='%s'>wdiff</a>" % uris[3])
return ' '.join(links)
def ResultHtmlOutput(self, filename):
@@ -129,7 +132,8 @@ class FailureMissingResult(FailureWithType):
class FailureTextMismatch(FailureWithType):
"""Text diff output failed."""
# Filename suffixes used by ResultHtmlOutput.
- OUT_FILENAMES = ["-actual-win.txt", "-expected.txt", "-diff-win.txt"]
+ OUT_FILENAMES = ["-actual-win.txt", "-expected.txt",
+ "-diff-win.txt", "-wdiff-win.html"]
@staticmethod
def Message():
diff --git a/webkit/tools/layout_tests/run_webkit_tests.py b/webkit/tools/layout_tests/run_webkit_tests.py
index 89a7720..1f5e039 100644
--- a/webkit/tools/layout_tests/run_webkit_tests.py
+++ b/webkit/tools/layout_tests/run_webkit_tests.py
@@ -237,6 +237,9 @@ class TestRunner:
shell_args.append("--pixel-tests=" + png_path)
test_args.png_path = png_path
+ if self._options.wdiff:
+ test_args.wdiff = True
+
if self._options.new_baseline:
test_args.new_baseline = self._options.new_baseline
if not self._options.pixel_tests:
@@ -553,6 +556,9 @@ if '__main__' == __name__:
option_parser.add_option("", "--pixel-tests", action="store_true",
default=False,
help="enable pixel-to-pixel PNG comparisons")
+ option_parser.add_option("", "--wdiff", action="store_true",
+ default=False,
+ help="enable word-by-word diffing")
option_parser.add_option("", "--results-directory",
default="layout-test-results",
help="Output results directory source dir,"
diff --git a/webkit/tools/layout_tests/test_types/test_type_base.py b/webkit/tools/layout_tests/test_types/test_type_base.py
index 65c1e2f..40d4448 100644
--- a/webkit/tools/layout_tests/test_types/test_type_base.py
+++ b/webkit/tools/layout_tests/test_types/test_type_base.py
@@ -7,8 +7,10 @@
Also defines the TestArguments "struct" to pass them additional arguments.
"""
+import cgi
import difflib
import os.path
+import subprocess
import google.path_utils
@@ -37,6 +39,7 @@ class TestTypeBase(object):
FILENAME_SUFFIX_ACTUAL = "-actual-win"
FILENAME_SUFFIX_EXPECTED = "-expected"
FILENAME_SUFFIX_DIFF = "-diff-win"
+ FILENAME_SUFFIX_WDIFF = "-wdiff-win.html"
def __init__(self, custom_result_id, root_output_dir):
"""Initialize a TestTypeBase object.
@@ -127,7 +130,7 @@ class TestTypeBase(object):
raise NotImplemented
def WriteOutputFiles(self, filename, test_type, file_type, output, expected,
- diff=True):
+ diff=True, wdiff=False):
"""Writes the test output, the expected output and optionally the diff
between the two to files in the results directory.
@@ -138,12 +141,13 @@ class TestTypeBase(object):
Args:
filename: The test filename
- prefix: A string appended to the test filename, e.g. "-simp". May be "".
- suffix: A string describing the test output file type, e.g. ".txt"
+ test_type: A string describing the test type, e.g. "simp"
+ file_type: A string describing the test output file type, e.g. ".txt"
output: A string containing the test output
expected: A string containing the expected test output
diff: if True, write a file containing the diffs too. This should be
- False for results that are not text.
+ False for results that are not text
+ wdiff: if True, write an HTML file containing word-by-word diffs
"""
self._MakeOutputDirectory(filename)
actual_filename = self.OutputFilename(filename,
@@ -163,3 +167,24 @@ class TestTypeBase(object):
test_type + self.FILENAME_SUFFIX_DIFF + file_type)
open(diff_filename, "wb").write(''.join(diff))
+ if wdiff:
+ # Shell out to wdiff to get colored inline diffs.
+ # TODO(evanm): make this work on other platforms.
+ cmd = [google.path_utils.FindUpward(path_utils.WebKitRoot(),
+ 'third_party', 'cygwin', 'bin',
+ 'wdiff.exe'),
+ '--start-delete=##WDIFF_DEL##', '--end-delete=##WDIFF_END##',
+ '--start-insert=##WDIFF_ADD##', '--end-insert=##WDIFF_END##',
+ actual_filename, expected_win_filename]
+ filename = self.OutputFilename(filename,
+ test_type + self.FILENAME_SUFFIX_WDIFF)
+ wdiff = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
+ wdiff = cgi.escape(wdiff)
+ wdiff = wdiff.replace('##WDIFF_DEL##', '<span class=del>')
+ wdiff = wdiff.replace('##WDIFF_ADD##', '<span class=add>')
+ wdiff = wdiff.replace('##WDIFF_END##', '</span>')
+ out = open(filename, 'wb')
+ out.write('<head><style>.del { background: #faa; } ')
+ out.write('.add { background: #afa; }</style></head>')
+ out.write('<pre>' + wdiff + '</pre>')
+ out.close()
diff --git a/webkit/tools/layout_tests/test_types/text_diff.py b/webkit/tools/layout_tests/test_types/text_diff.py
index bd60c18..997bc5e 100644
--- a/webkit/tools/layout_tests/test_types/text_diff.py
+++ b/webkit/tools/layout_tests/test_types/text_diff.py
@@ -60,7 +60,8 @@ class TestTextDiff(test_type_base.TestTypeBase):
# Write output files for new tests, too.
if output != expected:
# Text doesn't match, write output files.
- self.WriteOutputFiles(filename, "", ".txt", output, expected)
+ self.WriteOutputFiles(filename, "", ".txt", output, expected,
+ diff=True, wdiff=test_args.wdiff)
if expected == '':
failures.append(test_failures.FailureMissingResult(self))