[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
tony at chromium.org
tony at chromium.org
Wed Dec 22 14:14:57 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 4cc619488d2d3e7933b5ef33bfb3d134cc533d57
Author: tony at chromium.org <tony at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Oct 5 22:33:18 2010 +0000
2010-10-05 Tony Chang <tony at chromium.org>
Reviewed by Ojan Vafai.
[chromium] fix image diffing in NRWT
https://bugs.webkit.org/show_bug.cgi?id=47128
* Scripts/webkitpy/layout_tests/port/chromium.py: Stop using
NamedTemporaryFile since it doesn't work on Windows.
* Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69153 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index f5b58d2..fffd53d 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,14 @@
+2010-10-05 Tony Chang <tony at chromium.org>
+
+ Reviewed by Ojan Vafai.
+
+ [chromium] fix image diffing in NRWT
+ https://bugs.webkit.org/show_bug.cgi?id=47128
+
+ * Scripts/webkitpy/layout_tests/port/chromium.py: Stop using
+ NamedTemporaryFile since it doesn't work on Windows.
+ * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
+
2010-10-05 Kenneth Russell <kbr at google.com>
Reviewed by Tony Chang.
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/base.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/base.py
index 4073b82..aab21da 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/port/base.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/base.py
@@ -259,7 +259,10 @@ class Port(object):
path = self.expected_filename(test, extension)
if not os.path.exists(path):
return None
- with codecs.open(path, 'r', encoding) as file:
+ open_mode = 'r'
+ if encoding is None:
+ open_mode = 'r+b'
+ with codecs.open(path, open_mode, encoding) as file:
return file.read()
def expected_checksum(self, test):
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py
index a72627a..d75cfb7 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py
@@ -134,28 +134,38 @@ class ChromiumPort(base.Port):
def diff_image(self, expected_contents, actual_contents,
diff_filename=None, tolerance=0):
executable = self._path_to_image_diff()
- expected_tmpfile = tempfile.NamedTemporaryFile()
- expected_tmpfile.write(expected_contents)
- actual_tmpfile = tempfile.NamedTemporaryFile()
- actual_tmpfile.write(actual_contents)
+
+ tempdir = tempfile.mkdtemp()
+ expected_filename = os.path.join(tempdir, "expected.png")
+ with open(expected_filename, 'w+b') as file:
+ file.write(expected_contents)
+ actual_filename = os.path.join(tempdir, "actual.png")
+ with open(actual_filename, 'w+b') as file:
+ file.write(actual_contents)
+
if diff_filename:
- cmd = [executable, '--diff', expected_tmpfile.name,
- actual_tmpfile.name, diff_filename]
+ cmd = [executable, '--diff', expected_filename,
+ actual_filename, diff_filename]
else:
- cmd = [executable, expected_tmpfile.name, actual_tmpfile.name]
+ cmd = [executable, expected_filename, actual_filename]
result = True
try:
- if self._executive.run_command(cmd, return_exit_code=True) == 0:
- return False
+ exit_code = self._executive.run_command(cmd, return_exit_code=True)
+ if exit_code == 0:
+ # The images are the same.
+ result = False
+ elif exit_code != 1:
+ # Some other error occurred.
+ raise ValueError("image diff returned an exit code of " +
+ str(exit_code))
except OSError, e:
if e.errno == errno.ENOENT or e.errno == errno.EACCES:
_compare_available = False
else:
raise e
finally:
- expected_tmpfile.close()
- actual_tmpfile.close()
+ shutil.rmtree(tempdir)
return result
def driver_name(self):
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py
index a4a9ea6..48e9585 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py
@@ -156,5 +156,47 @@ DEFER LINUX WIN : fast/js/very-good.js = TIMEOUT PASS"""
self.assertEquals(options.configuration, 'default')
self.assertTrue(port.default_configuration_called)
+ def test_diff_image(self):
+ class TestPort(ChromiumPortTest.TestLinuxPort):
+ def _path_to_image_diff(self):
+ return "/path/to/image_diff"
+
+ class EmptyOptions:
+ use_drt = False
+
+ class MockExecute:
+ def __init__(self, result):
+ self._result = result
+
+ def run_command(self,
+ args,
+ cwd=None,
+ input=None,
+ error_handler=None,
+ return_exit_code=False,
+ return_stderr=True,
+ decode_output=False):
+ return self._result
+
+ options = EmptyOptions()
+ port = ChromiumPortTest.TestLinuxPort(options)
+
+ # Images are different.
+ port._executive = MockExecute(0)
+ self.assertEquals(False, port.diff_image("EXPECTED", "ACTUAL"))
+
+ # Images are the same.
+ port._executive = MockExecute(1)
+ self.assertEquals(True, port.diff_image("EXPECTED", "ACTUAL"))
+
+ # There was some error running image_diff.
+ port._executive = MockExecute(2)
+ exception_raised = False
+ try:
+ port.diff_image("EXPECTED", "ACTUAL")
+ except ValueError, e:
+ exception_raised = True
+ self.assertTrue(exception_raised)
+
if __name__ == '__main__':
unittest.main()
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py
index 1ad0fe6..0b05802 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py
@@ -104,7 +104,7 @@ class ImageDiff(test_type_base.TestTypeBase):
self.FILENAME_SUFFIX_EXPECTED + '.png')
expected_image = port.expected_image(filename)
- with codecs.open(actual_filename, 'r', None) as file:
+ with codecs.open(actual_filename, 'r+b', None) as file:
actual_image = file.read()
result = port.diff_image(expected_image, actual_image,
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list