Changeset 215727 in webkit


Ignore:
Timestamp:
Apr 25, 2017 3:48:31 AM (7 years ago)
Author:
clopez@igalia.com
Message:

[GTK] ImageDiff should be run by jhbuild-wrapper in case of using jhbuild
https://bugs.webkit.org/show_bug.cgi?id=168036

Reviewed by Michael Catanzaro.

Call ImageDiff with the JHBuild wrapper if we should use it.
Also add some unit tests for the JHBuild wrapper feature.

  • Scripts/webkitpy/port/base.py:

(Port._should_use_jhbuild): Use self._filesystem instead of os.path to allow mock testing.

  • Scripts/webkitpy/port/base_unittest.py:

(test_jhbuild_wrapper): Add a test for port._should_use_jhbuild()

  • Scripts/webkitpy/port/image_diff.py:

(ImageDiffer._start): The actual fix, use the wrapper if we should.

  • Scripts/webkitpy/port/image_diff_unittest.py: Removed. This two tests are now integrated in port_testcase
  • Scripts/webkitpy/port/port_testcase.py:

(PortTestCase):
(PortTestCase.test_diff_image): Test the command with wrapper and without it.
(PortTestCase.test_diff_image_passed): Moved from image_diff_unittest.py
(PortTestCase.test_diff_image_failed): Moved from image_diff_unittest.py

Location:
trunk/Tools
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r215724 r215727  
     12017-04-25  Carlos Alberto Lopez Perez  <clopez@igalia.com>
     2
     3        [GTK] ImageDiff should be run by jhbuild-wrapper in case of using jhbuild
     4        https://bugs.webkit.org/show_bug.cgi?id=168036
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Call ImageDiff with the JHBuild wrapper if we should use it.
     9        Also add some unit tests for the JHBuild wrapper feature.
     10
     11        * Scripts/webkitpy/port/base.py:
     12        (Port._should_use_jhbuild): Use self._filesystem instead of os.path to allow mock testing.
     13        * Scripts/webkitpy/port/base_unittest.py:
     14        (test_jhbuild_wrapper): Add a test for port._should_use_jhbuild()
     15        * Scripts/webkitpy/port/image_diff.py:
     16        (ImageDiffer._start): The actual fix, use the wrapper if we should.
     17        * Scripts/webkitpy/port/image_diff_unittest.py: Removed. This two tests are now integrated in port_testcase
     18        * Scripts/webkitpy/port/port_testcase.py:
     19        (PortTestCase):
     20        (PortTestCase.test_diff_image): Test the command with wrapper and without it.
     21        (PortTestCase.test_diff_image_passed): Moved from image_diff_unittest.py
     22        (PortTestCase.test_diff_image_failed): Moved from image_diff_unittest.py
     23
    1242017-04-25  Wenson Hsieh  <wenson_hsieh@apple.com>
    225
  • trunk/Tools/Scripts/webkitpy/port/base.py

    r215334 r215727  
    13861386        if self.port_name:
    13871387            suffix = self.port_name.upper()
    1388         return os.path.exists(self.path_from_webkit_base('WebKitBuild', 'Dependencies%s' % suffix))
     1388        return self._filesystem.exists(self.path_from_webkit_base('WebKitBuild', 'Dependencies%s' % suffix))
    13891389
    13901390    # FIXME: Eventually we should standarize port naming, and make this method smart enough
  • trunk/Tools/Scripts/webkitpy/port/base_unittest.py

    r205399 r215727  
    396396        self.assertTrue(port.is_w3c_resource_file(port.host.filesystem, port.layout_tests_dir() + "/imported/w3c/web-platform-tests/dom/nodes/Document-createElement-namespace-tests", "test.html"))
    397397
     398    def test_jhbuild_wrapper(self):
     399        port = self.make_port(port_name='foo')
     400        port.port_name = 'foo'
     401        self.assertFalse(port._should_use_jhbuild())
     402        port._filesystem.maybe_make_directory(port.path_from_webkit_base('WebKitBuild', 'Dependencies%s' % port.port_name.upper()))
     403        self.assertTrue(port._should_use_jhbuild())
     404
    398405class NaturalCompareTest(unittest.TestCase):
    399406    def setUp(self):
  • trunk/Tools/Scripts/webkitpy/port/image_diff.py

    r197227 r215727  
    6767    def _start(self, tolerance):
    6868        command = [self._port._path_to_image_diff(), '--tolerance', str(tolerance)]
     69        if self._port._should_use_jhbuild():
     70            command = self._port._jhbuild_wrapper + command
    6971        environment = self._port.setup_environ_for_server('ImageDiff')
    7072        self._process = self._port._server_process_constructor(self._port, 'ImageDiff', command, environment)
  • trunk/Tools/Scripts/webkitpy/port/port_testcase.py

    r214542 r215727  
    4343from webkitpy.common.system.systemhost_mock import MockSystemHost
    4444from webkitpy.port.base import Port
     45from webkitpy.port.image_diff import ImageDiffer
    4546from webkitpy.port.server_process_mock import MockServerProcess
    4647from webkitpy.layout_tests.servers import http_server_base
     
    259260        port._server_process_constructor = make_proc
    260261        port.setup_test_run()
     262
     263        # First test the case of not using the JHBuild wrapper.
     264        self.assertFalse(port._should_use_jhbuild())
     265
    261266        self.assertEqual(port.diff_image('foo', 'bar'), ('', 100.0, None))
    262         self.assertEqual(self.proc.cmd[1:3], ["--tolerance", "0.1"])
    263 
     267        self.assertEqual(self.proc.cmd, [port._path_to_image_diff(), "--tolerance", "0.1"])
    264268        self.assertEqual(port.diff_image('foo', 'bar', None), ('', 100.0, None))
    265         self.assertEqual(self.proc.cmd[1:3], ["--tolerance", "0.1"])
    266 
     269        self.assertEqual(self.proc.cmd, [port._path_to_image_diff(), "--tolerance", "0.1"])
    267270        self.assertEqual(port.diff_image('foo', 'bar', 0), ('', 100.0, None))
    268         self.assertEqual(self.proc.cmd[1:3], ["--tolerance", "0"])
     271        self.assertEqual(self.proc.cmd, [port._path_to_image_diff(), "--tolerance", "0"])
     272
     273        # Now test the case of using JHBuild wrapper.
     274        port._filesystem.maybe_make_directory(port.path_from_webkit_base('WebKitBuild', 'Dependencies%s' % port.port_name.upper()))
     275        self.assertTrue(port._should_use_jhbuild())
     276
     277        self.assertEqual(port.diff_image('foo', 'bar'), ('', 100.0, None))
     278        self.assertEqual(self.proc.cmd, port._jhbuild_wrapper + [port._path_to_image_diff(), "--tolerance", "0.1"])
     279        self.assertEqual(port.diff_image('foo', 'bar', None), ('', 100.0, None))
     280        self.assertEqual(self.proc.cmd, port._jhbuild_wrapper + [port._path_to_image_diff(), "--tolerance", "0.1"])
     281        self.assertEqual(port.diff_image('foo', 'bar', 0), ('', 100.0, None))
     282        self.assertEqual(self.proc.cmd, port._jhbuild_wrapper + [port._path_to_image_diff(), "--tolerance", "0"])
    269283
    270284        port.clean_up_test_run()
    271285        self.assertTrue(self.proc.stopped)
    272286        self.assertEqual(port._image_differ, None)
     287
     288    def test_diff_image_passed(self):
     289        port = self.make_port()
     290        port._server_process_constructor = lambda port, nm, cmd, env: MockServerProcess(lines=['diff: 0% passed\n'])
     291        image_differ = ImageDiffer(port)
     292        self.assertEqual(image_differ.diff_image('foo', 'bar', 0.1), (None, 0, None))
     293
     294    def test_diff_image_failed(self):
     295        port = self.make_port()
     296        port._server_process_constructor = lambda port, nm, cmd, env: MockServerProcess(lines=['diff: 100% failed\n'])
     297        image_differ = ImageDiffer(port)
     298        self.assertEqual(image_differ.diff_image('foo', 'bar', 0.1), ('', 100.0, None))
    273299
    274300    def test_diff_image_crashed(self):
Note: See TracChangeset for help on using the changeset viewer.