Changeset 90542 in webkit


Ignore:
Timestamp:
Jul 6, 2011 11:19:21 PM (13 years ago)
Author:
abarth@webkit.org
Message:

2011-07-06 Adam Barth <abarth@webkit.org>

Wean rebaseline-server off unexpected_results.json
https://bugs.webkit.org/show_bug.cgi?id=64063

Reviewed by Eric Seidel.

In the process of changing this code to use full_results.json, I
noticed that the code was broken (because it wasn't tested). This
patch also adds test coverage for the broken code.

  • Scripts/webkitpy/tool/commands/rebaselineserver.py:
  • Scripts/webkitpy/tool/servers/rebaselineserver.py:
  • Scripts/webkitpy/tool/servers/rebaselineserver_unittest.py:
Location:
trunk/Tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r90539 r90542  
     12011-07-06  Adam Barth  <abarth@webkit.org>
     2
     3        Wean rebaseline-server off unexpected_results.json
     4        https://bugs.webkit.org/show_bug.cgi?id=64063
     5
     6        Reviewed by Eric Seidel.
     7
     8        In the process of changing this code to use full_results.json, I
     9        noticed that the code was broken (because it wasn't tested).  This
     10        patch also adds test coverage for the broken code.
     11
     12        * Scripts/webkitpy/tool/commands/rebaselineserver.py:
     13        * Scripts/webkitpy/tool/servers/rebaselineserver.py:
     14        * Scripts/webkitpy/tool/servers/rebaselineserver_unittest.py:
     15
    1162011-07-06  Adam Barth  <abarth@webkit.org>
    217
  • trunk/Tools/Scripts/webkitpy/tool/commands/rebaselineserver.py

    r90410 r90542  
    3535
    3636from webkitpy.common import system
    37 from webkitpy.common.net import resultsjsonparser
     37from webkitpy.common.net.resultsjsonparser import for_each_test, JSONTestResult
    3838from webkitpy.layout_tests.layout_package import json_results_generator
    3939from webkitpy.layout_tests.port import factory
    4040from webkitpy.tool.commands.abstractlocalservercommand import AbstractLocalServerCommand
    41 from webkitpy.tool.servers.rebaselineserver import RebaselineHTTPServer, STATE_NEEDS_REBASELINE
     41from webkitpy.tool.servers.rebaselineserver import get_test_baselines, RebaselineHTTPServer, STATE_NEEDS_REBASELINE
    4242
    4343
     
    5959    server = RebaselineHTTPServer
    6060
     61    def _gather_baselines(self, results_json):
     62        # Rebaseline server and it's associated JavaScript expected the tests subtree to
     63        # be key-value pairs instead of hierarchical.
     64        # FIXME: make the rebaseline server use the hierarchical tree.
     65        new_tests_subtree = {}
     66
     67        def gather_baselines_for_test(test_name, result_dict):
     68            result = JSONTestResult(test_name, result_dict)
     69            if result.did_pass_or_run_as_expected():
     70                return
     71            result_dict['state'] = STATE_NEEDS_REBASELINE
     72            result_dict['baselines'] = get_test_baselines(test_name, self._test_config)
     73            new_tests_subtree[test_name] = result_dict
     74
     75        for_each_test(results_json['tests'], gather_baselines_for_test)
     76        results_json['tests'] = new_tests_subtree
     77
    6178    def _prepare_config(self, options, args, tool):
    6279        results_directory = args[0]
     
    6582
    6683        print 'Parsing unexpected_results.json...'
    67         results_json_path = filesystem.join(results_directory, 'unexpected_results.json')
     84        results_json_path = filesystem.join(results_directory, 'full_results.json')
    6885        results_json = json_results_generator.load_json(filesystem, results_json_path)
    6986
     
    7188        layout_tests_directory = port.layout_tests_dir()
    7289        platforms = filesystem.listdir(filesystem.join(layout_tests_directory, 'platform'))
    73         test_config = TestConfig(port, layout_tests_directory, results_directory, platforms, filesystem, scm)
     90        self._test_config = TestConfig(port, layout_tests_directory, results_directory, platforms, filesystem, scm)
    7491
    7592        print 'Gathering current baselines...'
    76         # Rebaseline server and it's associated JavaScript expected the tests subtree to
    77         # be key-value pairs instead of hierarchical.
    78         # FIXME: make the rebaseline server use the hierarchical tree.
    79         new_tests_subtree = {}
    80 
    81         def gather_baselines(test, result):
    82             result['state'] = STATE_NEEDS_REBASELINE
    83             result['baselines'] = _get_test_baselines(test, test_config)
    84             new_tests_subtree[test] = result
    85 
    86         resultsjsonparser.for_each_test(results_json['tests'], gather_baselines)
    87         results_json['tests'] = new_tests_subtree
     93        self._gather_baselines(results_json)
    8894
    8995        return {
    90             'test_config': test_config,
     96            'test_config': self._test_config,
    9197            "results_json": results_json,
    9298            "platforms_json": {
  • trunk/Tools/Scripts/webkitpy/tool/servers/rebaselineserver.py

    r90520 r90542  
    7373
    7474    # If requested, move current baselines out
    75     current_baselines = _get_test_baselines(test_file, test_config)
     75    current_baselines = get_test_baselines(test_file, test_config)
    7676    if baseline_target in current_baselines and baseline_move_to != 'none':
    7777        log('  Moving current %s baselines to %s' %
     
    161161
    162162
    163 def _get_test_baselines(test_file, test_config):
     163def get_test_baselines(test_file, test_config):
    164164    # FIXME: This seems like a hack. This only seems used to access the Port.expected_baselines logic.
    165165    class AllPlatformsPort(WebKitPort):
  • trunk/Tools/Scripts/webkitpy/tool/servers/rebaselineserver_unittest.py

    r90506 r90542  
    2929import unittest
    3030
     31from webkitpy.common.net import resultsjsonparser_unittest
    3132from webkitpy.common.system import filesystem_mock
     33from webkitpy.layout_tests.layout_package.json_results_generator import strip_json_wrapper
    3234from webkitpy.layout_tests.port.webkit import WebKitPort
    33 from webkitpy.tool.commands.rebaselineserver import TestConfig
     35import webkitpy.thirdparty.simplejson as simplejson
     36from webkitpy.tool.commands.rebaselineserver import TestConfig, RebaselineServer
    3437from webkitpy.tool.mocktool import MockSCM
    3538from webkitpy.tool.servers import rebaselineserver
     
    202205                '    Updated image-expected.png',
    203206            ])
     207
     208    def test_gather_baselines(self):
     209        example_json = resultsjsonparser_unittest.ResultsJSONParserTest._example_unexpected_results_json
     210        results_json = simplejson.loads(strip_json_wrapper(example_json))
     211        server = RebaselineServer()
     212        server._test_config = get_test_config()
     213        server._gather_baselines(results_json)
     214        self.assertEqual(results_json['tests']['svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation-attr.html']['state'], 'needs_rebaseline')
     215        self.assertFalse('prototype-chocolate.html' in results_json['tests'])
    204216
    205217    def _assertRebaseline(self, test_files, results_files, test_name, baseline_target, baseline_move_to, expected_success, expected_log):
     
    275287
    276288    def _assertBaselines(self, test_files, test_name, expected_baselines):
    277         actual_baselines = rebaselineserver._get_test_baselines(test_name, get_test_config(test_files))
     289        actual_baselines = rebaselineserver.get_test_baselines(test_name, get_test_config(test_files))
    278290        self.assertEqual(expected_baselines, actual_baselines)
    279291
Note: See TracChangeset for help on using the changeset viewer.