Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1750)

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py

Issue 2595983002: Extract diff_text function out of the Port class. (Closed)
Patch Set: Change indentation Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py
index 8a211699dcb9fff6fd932666e19fd336a43042c2..8455ba5155cc205801c226f16688fd6865cf21c1 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py
@@ -517,36 +517,6 @@ class Port(object):
return (result, err_str or None)
- 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.
- """
-
- # The filenames show up in the diff output, make sure they're
- # raw bytes and not unicode, so that they don't trigger join()
- # trying to decode the input.
- def to_raw_bytes(string_value):
- if isinstance(string_value, unicode):
- return string_value.encode('utf-8')
- return string_value
- expected_filename = to_raw_bytes(expected_filename)
- actual_filename = to_raw_bytes(actual_filename)
- diff = difflib.unified_diff(expected_text.splitlines(True),
- actual_text.splitlines(True),
- expected_filename,
- actual_filename)
-
- # The diff generated by the difflib is incorrect if one of the files
- # does not have a newline at the end of the file and it is present in
- # the diff. Relevant Python issue: http://bugs.python.org/issue2142
- def diff_fixup(diff):
- for line in diff:
- yield line
- if not line.endswith('\n'):
- yield '\n\\ No newline at end of file\n'
-
- return ''.join(diff_fixup(diff))
-
def driver_name(self):
if self.get_option('driver_name'):
return self.get_option('driver_name')

Powered by Google App Engine
This is Rietveld 408576698