Changeset 70277 in webkit


Ignore:
Timestamp:
Oct 21, 2010 5:04:39 PM (14 years ago)
Author:
mihaip@chromium.org
Message:

2010-10-21 Mihai Parparita <mihaip@chromium.org>

Reviewed by Ojan Vafai.

Add support for --tolerance in NRWT
https://bugs.webkit.org/show_bug.cgi?id=47959

Add support for the --tolerance flag in NRWT. The Port.diff_image
signature shouldn't need a tolerance parameter (it's not set per test),
just have ports that use it (currently only WebKitPort) read it from
the options object.

  • Scripts/webkitpy/layout_tests/port/chromium.py:
  • Scripts/webkitpy/layout_tests/port/port_testcase.py:
  • Scripts/webkitpy/layout_tests/port/test.py:
  • Scripts/webkitpy/layout_tests/port/webkit.py:
  • Scripts/webkitpy/layout_tests/run_webkit_tests.py:
  • Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:
Location:
trunk/WebKitTools
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r70274 r70277  
     12010-10-21  Mihai Parparita  <mihaip@chromium.org>
     2
     3        Reviewed by Ojan Vafai.
     4
     5        Add support for --tolerance in NRWT
     6        https://bugs.webkit.org/show_bug.cgi?id=47959
     7       
     8        Add support for the --tolerance flag in NRWT. The Port.diff_image
     9        signature shouldn't need a tolerance parameter (it's not set per test),
     10        just have ports that use it (currently only WebKitPort) read it from
     11        the options object.
     12
     13        * Scripts/webkitpy/layout_tests/port/chromium.py:
     14        * Scripts/webkitpy/layout_tests/port/port_testcase.py:
     15        * Scripts/webkitpy/layout_tests/port/test.py:
     16        * Scripts/webkitpy/layout_tests/port/webkit.py:
     17        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
     18        * Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:
     19
    1202010-10-21  Eric Seidel  <eric@webkit.org>
    221
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py

    r70013 r70277  
    136136
    137137    def diff_image(self, expected_contents, actual_contents,
    138                    diff_filename=None, tolerance=0):
     138                   diff_filename=None):
    139139        executable = self._path_to_image_diff()
    140140
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/port_testcase.py

    r70013 r70277  
    3636mock_options = mocktool.MockOptions(results_directory='layout-test-results',
    3737                                    use_apache=True,
    38                                     configuration='Release')
     38                                    configuration='Release',
     39                                    tolerance=None)
    3940
    4041
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/test.py

    r70013 r70277  
    138138
    139139    def diff_image(self, expected_contents, actual_contents,
    140                    diff_filename=None, tolerance=0):
     140                   diff_filename=None):
    141141        diffed = actual_contents != expected_contents
    142142        if diffed and diff_filename:
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/webkit.py

    r70013 r70277  
    123123
    124124    def diff_image(self, expected_contents, actual_contents,
    125                    diff_filename=None, tolerance=0.1):
     125                   diff_filename=None):
    126126        """Return True if the two files are different. Also write a delta
    127127        image of the two images into |diff_filename| if it is not None."""
    128 
    129         # FIXME: either expose the tolerance argument as a command-line
    130         # parameter, or make it go away and always use exact matches.
    131128
    132129        # Handle the case where the test didn't actually generate an image.
     
    134131            return True
    135132
    136         sp = self._diff_image_request(expected_contents, actual_contents,
    137                                       tolerance)
     133        sp = self._diff_image_request(expected_contents, actual_contents)
    138134        return self._diff_image_reply(sp, diff_filename)
    139135
    140     def _diff_image_request(self, expected_contents, actual_contents, tolerance):
     136    def _diff_image_request(self, expected_contents, actual_contents):
     137        # FIXME: use self.get_option('tolerance') and
     138        # self.set_option_default('tolerance', 0.1) once that behaves correctly
     139        # with default values.
     140        if self._options.tolerance is not None:
     141            tolerance = self._options.tolerance
     142        else:
     143            tolerance = 0.1
    141144        command = [self._path_to_image_diff(), '--tolerance', str(tolerance)]
    142145        sp = server_process.ServerProcess(self, 'ImageDiff', command)
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests.py

    r70217 r70277  
    15631563        optparse.make_option("--no-pixel-tests", action="store_false",
    15641564            dest="pixel_tests", help="Disable pixel-to-pixel PNG comparisons"),
    1565         # old-run-webkit-tests allows a specific tolerance: --tolerance t
    1566         # Ignore image differences less than this percentage (default: 0.1)
     1565        optparse.make_option("--tolerance",
     1566            help="Ignore image differences less than this percentage (some "
     1567                "ports may ignore this option)", type="float"),
    15671568        optparse.make_option("--results-directory",
    15681569            default="layout-test-results",
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py

    r70024 r70277  
    4949from webkitpy.layout_tests import run_webkit_tests
    5050from webkitpy.layout_tests.layout_package import dump_render_tree_thread
     51from webkitpy.layout_tests.port.test import TestPort
    5152
    5253from webkitpy.thirdparty.mock import Mock
     
    261262        self.assertEqual(user.url, '/tmp/foo/results.html')
    262263
     264    def test_tolerance(self):
     265        class ImageDiffTestPort(TestPort):
     266            def diff_image(self, expected_contents, actual_contents,
     267                   diff_filename=None):
     268                self.tolerance_used_for_diff_image = self._options.tolerance
     269                return True
     270
     271        def get_port_for_run(args):
     272            options, parsed_args = run_webkit_tests.parse_args(args)
     273            test_port = ImageDiffTestPort(options=options, user=MockUser())
     274            passing_run(args=args, port_obj=test_port, tests_included=True)
     275            return test_port
     276
     277        base_args = ['--pixel-tests', 'failures/expected/*']
     278
     279        # If we pass in an explicit tolerance argument, then that will be used.
     280        test_port = get_port_for_run(base_args + ['--tolerance', '.1'])
     281        self.assertEqual(0.1, test_port.tolerance_used_for_diff_image)
     282        test_port = get_port_for_run(base_args + ['--tolerance', '0'])
     283        self.assertEqual(0, test_port.tolerance_used_for_diff_image)
     284
     285        # Otherwise the port's default tolerance behavior (including ignoring it)
     286        # should be used.
     287        test_port = get_port_for_run(base_args)
     288        self.assertEqual(None, test_port.tolerance_used_for_diff_image)
    263289
    264290
Note: See TracChangeset for help on using the changeset viewer.