Changeset 69066 in webkit


Ignore:
Timestamp:
Oct 4, 2010 9:21:10 PM (14 years ago)
Author:
tkent@chromium.org
Message:

2010-10-04 Tony Chang <tony@chromium.org>

Reviewed by Kent Tamura.

[chromium] fix image diffing in NRWT
https://bugs.webkit.org/show_bug.cgi?id=47128

  • Scripts/webkitpy/layout_tests/port/chromium.py: Flush data to the

temp file and check the image_diff error code more carefully

  • Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r69065 r69066  
     12010-10-04  Tony Chang  <tony@chromium.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        [chromium] fix image diffing in NRWT
     6        https://bugs.webkit.org/show_bug.cgi?id=47128
     7
     8        * Scripts/webkitpy/layout_tests/port/chromium.py: Flush data to the
     9              temp file and check the image_diff error code more carefully
     10        * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
     11
    1122010-10-04  Dirk Pranke  <dpranke@chromium.org>
    213
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py

    r68268 r69066  
    137137        expected_tmpfile = tempfile.NamedTemporaryFile()
    138138        expected_tmpfile.write(expected_contents)
     139        expected_tmpfile.flush()
    139140        actual_tmpfile = tempfile.NamedTemporaryFile()
    140141        actual_tmpfile.write(actual_contents)
     142        actual_tmpfile.flush()
    141143        if diff_filename:
    142144            cmd = [executable, '--diff', expected_tmpfile.name,
     
    147149        result = True
    148150        try:
    149             if self._executive.run_command(cmd, return_exit_code=True) == 0:
    150                 return False
     151            exit_code = self._executive.run_command(cmd, return_exit_code=True)
     152            if exit_code == 0:
     153                # The images are the same.
     154                result = False
     155            elif exit_code != 1:
     156                # Some other error occurred.
     157                raise ValueError("image diff returned an exit code of " +
     158                                 str(exit_code))
    151159        except OSError, e:
    152160            if e.errno == errno.ENOENT or e.errno == errno.EACCES:
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py

    r68268 r69066  
    157157        self.assertTrue(port.default_configuration_called)
    158158
     159    def test_diff_image(self):
     160        class TestPort(ChromiumPortTest.TestLinuxPort):
     161            def _path_to_image_diff(self):
     162                return "/path/to/image_diff"
     163
     164        class EmptyOptions:
     165            use_drt = False
     166
     167        class MockExecute:
     168            def __init__(self, result):
     169                self._result = result
     170
     171            def run_command(self,
     172                            args,
     173                            cwd=None,
     174                            input=None,
     175                            error_handler=None,
     176                            return_exit_code=False,
     177                            return_stderr=True,
     178                            decode_output=False):
     179                return self._result
     180
     181        options = EmptyOptions()
     182        port = ChromiumPortTest.TestLinuxPort(options)
     183
     184        # Images are different.
     185        port._executive = MockExecute(0)
     186        self.assertEquals(False, port.diff_image("EXPECTED", "ACTUAL"))
     187
     188        # Images are the same.
     189        port._executive = MockExecute(1)
     190        self.assertEquals(True, port.diff_image("EXPECTED", "ACTUAL"))
     191
     192        # There was some error running image_diff.
     193        port._executive = MockExecute(2)
     194        exception_raised = False
     195        try:
     196            port.diff_image("EXPECTED", "ACTUAL")
     197        except ValueError, e:
     198            exception_raised = True
     199        self.assertTrue(exception_raised)
     200
    159201if __name__ == '__main__':
    160202    unittest.main()
Note: See TracChangeset for help on using the changeset viewer.