Skip to content

Commit

Permalink
Rename compare_text and compare_audio to make it clear that they're !=
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=78301

Reviewed by Adam Barth.

I also removed the maybe_create_directory function which was redundant.

* Scripts/webkitpy/layout_tests/controllers/manager.py:
(Manager.set_up_run):
* Scripts/webkitpy/layout_tests/controllers/test_result_writer.py:
(TestResultWriter._make_output_directory):
* Scripts/webkitpy/layout_tests/port/base.py:
(Port.do_text_results_differ):
(Port.do_audio_results_differ):
(Port.diff_text):
(Port.driver_name):
(Port.skips_perf_test):
* Scripts/webkitpy/layout_tests/port/win.py:
(WinPort.do_text_results_differ):
* Scripts/webkitpy/layout_tests/port/win_unittest.py:
(WinPortTest.test_do_text_results_differ):
* Scripts/webkitpy/layout_tests/servers/apache_http_server.py:
(LayoutTestApacheHttpd.__init__):
* Scripts/webkitpy/layout_tests/servers/http_server_base.py:
(HttpServerBase.__init__):
* Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests.py:
(Rebaseliner._diff_baselines):


Canonical link: https://commits.webkit.org/95233@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@107361 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eseidel committed Feb 10, 2012
1 parent ebc7a90 commit 5cd6591
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 37 deletions.
30 changes: 30 additions & 0 deletions Tools/ChangeLog
@@ -1,3 +1,33 @@
2012-02-09 Eric Seidel <eric@webkit.org>

Rename compare_text and compare_audio to make it clear that they're !=
https://bugs.webkit.org/show_bug.cgi?id=78301

Reviewed by Adam Barth.

I also removed the maybe_create_directory function which was redundant.

* Scripts/webkitpy/layout_tests/controllers/manager.py:
(Manager.set_up_run):
* Scripts/webkitpy/layout_tests/controllers/test_result_writer.py:
(TestResultWriter._make_output_directory):
* Scripts/webkitpy/layout_tests/port/base.py:
(Port.do_text_results_differ):
(Port.do_audio_results_differ):
(Port.diff_text):
(Port.driver_name):
(Port.skips_perf_test):
* Scripts/webkitpy/layout_tests/port/win.py:
(WinPort.do_text_results_differ):
* Scripts/webkitpy/layout_tests/port/win_unittest.py:
(WinPortTest.test_do_text_results_differ):
* Scripts/webkitpy/layout_tests/servers/apache_http_server.py:
(LayoutTestApacheHttpd.__init__):
* Scripts/webkitpy/layout_tests/servers/http_server_base.py:
(HttpServerBase.__init__):
* Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests.py:
(Rebaseliner._diff_baselines):

2012-02-09 Zan Dobersek <zandobersek@gmail.com>

[GTK] Add DRT support for modal dialogs
Expand Down
2 changes: 1 addition & 1 deletion Tools/Scripts/webkitpy/layout_tests/controllers/manager.py
Expand Up @@ -867,7 +867,7 @@ def set_up_run(self):
self._clobber_old_results()

# Create the output directory if it doesn't already exist.
self._port.maybe_make_directory(self._results_directory)
self._port.host.filesystem.maybe_make_directory(self._results_directory)

self._port.setup_test_run()

Expand Down
Expand Up @@ -224,7 +224,7 @@ def _compare_text(self, actual_text, expected_text):
failures = []
if (expected_text and actual_text and
# Assuming expected_text is already normalized.
self._port.compare_text(self._get_normalized_output_text(actual_text), expected_text)):
self._port.do_text_results_differ(self._get_normalized_output_text(actual_text), expected_text)):
failures.append(test_failures.FailureTextMismatch())
elif actual_text and not expected_text:
failures.append(test_failures.FailureMissingResult())
Expand All @@ -233,7 +233,7 @@ def _compare_text(self, actual_text, expected_text):
def _compare_audio(self, actual_audio, expected_audio):
failures = []
if (expected_audio and actual_audio and
self._port.compare_audio(actual_audio, expected_audio)):
self._port.do_audio_results_differ(actual_audio, expected_audio)):
failures.append(test_failures.FailureAudioMismatch())
elif actual_audio and not expected_audio:
failures.append(test_failures.FailureMissingAudio())
Expand Down
Expand Up @@ -105,7 +105,7 @@ def _make_output_directory(self):
"""Creates the output directory (if needed) for a given test filename."""
fs = self._port._filesystem
output_filename = fs.join(self._root_output_dir, self._test_name)
self._port.maybe_make_directory(fs.dirname(output_filename))
fs.maybe_make_directory(fs.dirname(output_filename))

def output_filename(self, modifier):
"""Returns a filename inside the output dir that contains modifier.
Expand Down
29 changes: 5 additions & 24 deletions Tools/Scripts/webkitpy/layout_tests/port/base.py
Expand Up @@ -248,17 +248,10 @@ def check_httpd(self):
_log.error("No httpd found. Cannot run http tests.")
return False

def compare_text(self, expected_text, actual_text):
"""Return whether or not the two strings are *not* equal. This
routine is used to diff text output.
While this is a generic routine, we include it in the Port
interface so that it can be overriden for testing purposes."""
def do_text_results_differ(self, expected_text, actual_text):
return expected_text != actual_text

def compare_audio(self, expected_audio, actual_audio):
# FIXME: If we give this method a better name it won't need this docstring (e.g. are_audio_results_equal()).
"""Return whether the two audio files are *not* equal."""
def do_audio_results_differ(self, expected_audio, actual_audio):
return expected_audio != actual_audio

def diff_image(self, expected_contents, actual_contents, tolerance=None):
Expand All @@ -269,14 +262,9 @@ def diff_image(self, expected_contents, actual_contents, tolerance=None):
"""
raise NotImplementedError('Port.diff_image')


def diff_text(self, expected_text, actual_text,
expected_filename, actual_filename):
def diff_text(self, expected_text, actual_text, expected_filename, actual_filename):
"""Returns a string containing the diff of the two text strings
in 'unified diff' format.
While this is a generic routine, we include it in the Port
interface so that it can be overriden for testing purposes."""
in 'unified diff' format."""

# The filenames show up in the diff output, make sure they're
# raw bytes and not unicode, so that they don't trigger join()
Expand Down Expand Up @@ -309,10 +297,7 @@ def print_leaks_summary(self):
pass

def driver_name(self):
"""Returns the name of the actual binary that is performing the test,
so that it can be referred to in log messages. In most cases this
will be DumpRenderTree, but if a port uses a binary with a different
name, it can be overridden here."""
# FIXME: Seems we should get this from the Port's Driver class.
return "DumpRenderTree"

def expected_baselines(self, test_name, suffix, all_baselines=False):
Expand Down Expand Up @@ -619,10 +604,6 @@ def skips_perf_test(self, test_name):
return True
return False

def maybe_make_directory(self, *comps):
"""Creates the specified directory if it doesn't already exist."""
self._filesystem.maybe_make_directory(*comps)

def name(self):
"""Returns a name that uniquely identifies this particular type of port
(e.g., "mac-snowleopard" or "chromium-gpu-linux-x86_x64" and can be passed
Expand Down
4 changes: 2 additions & 2 deletions Tools/Scripts/webkitpy/layout_tests/port/win.py
Expand Up @@ -45,10 +45,10 @@ class WinPort(ApplePort):
# and the order of fallback between them. Matches ORWT.
VERSION_FALLBACK_ORDER = ["win-xp", "win-vista", "win-7sp0", "win"]

def compare_text(self, expected_text, actual_text):
def do_text_results_differ(self, expected_text, actual_text):
# Sanity was restored in WK2, so we don't need this hack there.
if self.get_option('webkit_test_runner'):
return ApplePort.compare_text(self, expected_text, actual_text)
return ApplePort.do_text_results_differ(self, expected_text, actual_text)

# This is a hack (which dates back to ORWT).
# Windows does not have an EDITING DELEGATE, so we strip any EDITING DELEGATE
Expand Down
8 changes: 4 additions & 4 deletions Tools/Scripts/webkitpy/layout_tests/port/win_unittest.py
Expand Up @@ -85,13 +85,13 @@ def test_versions(self):
def test_compare_text(self):
expected = "EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification\nfoo\nEDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n"
port = self.make_port()
self.assertFalse(port.compare_text(expected, "foo\n"))
self.assertTrue(port.compare_text(expected, "foo"))
self.assertTrue(port.compare_text(expected, "bar"))
self.assertFalse(port.do_text_results_differ(expected, "foo\n"))
self.assertTrue(port.do_text_results_differ(expected, "foo"))
self.assertTrue(port.do_text_results_differ(expected, "bar"))

# This hack doesn't exist in WK2.
port._options = MockOptions(webkit_test_runner=True)
self.assertTrue(port.compare_text(expected, "foo\n"))
self.assertTrue(port.do_text_results_differ(expected, "foo\n"))

def test_operating_system(self):
self.assertEqual('win', self.make_port().operating_system())
Expand Up @@ -57,7 +57,7 @@ def __init__(self, port_obj, output_dir):
{'port': 8081},
{'port': 8443, 'sslcert': True}]
self._output_dir = output_dir
port_obj.maybe_make_directory(output_dir)
self._filesystem.maybe_make_directory(output_dir)

self._pid_file = self._filesystem.join(self._runtime_path, '%s.pid' % self._name)

Expand Down
Expand Up @@ -65,7 +65,7 @@ def __init__(self, port_obj):
tmpdir = '/tmp'

self._runtime_path = self._filesystem.join(tmpdir, "WebKit")
port_obj.maybe_make_directory(self._runtime_path)
self._filesystem.maybe_make_directory(self._runtime_path)

def start(self):
"""Starts the server. It is an error to start an already started server.
Expand Down
Expand Up @@ -512,7 +512,7 @@ def _diff_baselines(self, output1, output2, is_image):
if is_image:
return self._port.diff_image(output1, output2)[0]

return self._port.compare_text(output1, output2)
return self._port.do_text_results_differ(output1, output2)

def _delete_baseline(self, filename):
"""Remove the file from repository and delete it from disk.
Expand Down

0 comments on commit 5cd6591

Please sign in to comment.