Changeset 121699 in webkit


Ignore:
Timestamp:
Jul 2, 2012 12:22:43 PM (12 years ago)
Author:
ojan@chromium.org
Message:

Move rebaseline-all command from the gardening-server down into webkit-patch
https://bugs.webkit.org/show_bug.cgi?id=90395

Reviewed by Adam Barth.

This is just moving code. It it in preparation for making rebaseline-expectations
use the same code in order to get the parallelism benefits and reduces the amount
of code we have for doing rebaselines.

  • Scripts/webkitpy/common/checkout/checkout_unittest.py:

(CheckoutTest.test_apply_patch):
Updated due to the change to executive_mock.

  • Scripts/webkitpy/common/system/executive_mock.py:

(MockExecutive.run_command):
Update to print out the input passed to stdin.

  • Scripts/webkitpy/tool/commands/download_unittest.py:

Updated due to executive_mock change.

  • Scripts/webkitpy/tool/commands/rebaseline.py:

(RebaselineAll):
(RebaselineAll._run_webkit_patch):
(RebaselineAll._builders_to_fetch_from):
(RebaselineAll._rebaseline_commands):
(RebaselineAll._files_to_add):
(RebaselineAll._optimize_baselines):
(RebaselineAll._rebaseline):
(RebaselineAll.execute):
All this code is just copy-pasted except for mechanical changes
(e.g. self.server.tool --> self._tool) and the reading in of the
JSON from stdin instead of the post body.

  • Scripts/webkitpy/tool/commands/rebaseline_unittest.py:

(test_rebaseline_all):
Copied the test-case out of gardeningserver_unittest.py.

  • Scripts/webkitpy/tool/servers/gardeningserver.py:

(GardeningHTTPRequestHandler):
(GardeningHTTPRequestHandler.rebaseline):
(GardeningHTTPRequestHandler.rebaselineall):

  • Scripts/webkitpy/tool/servers/gardeningserver_unittest.py:

(GardeningServerTest.test_rebaselineall):
(GardeningServerTest.test_rebaselineall.run_command):

Location:
trunk/Tools
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r121696 r121699  
     12012-07-02  Ojan Vafai  <ojan@chromium.org>
     2
     3        Move rebaseline-all command from the gardening-server down into webkit-patch
     4        https://bugs.webkit.org/show_bug.cgi?id=90395
     5
     6        Reviewed by Adam Barth.
     7
     8        This is just moving code. It it in preparation for making rebaseline-expectations
     9        use the same code in order to get the parallelism benefits and reduces the amount
     10        of code we have for doing rebaselines.
     11
     12        * Scripts/webkitpy/common/checkout/checkout_unittest.py:
     13        (CheckoutTest.test_apply_patch):
     14        Updated due to the change to executive_mock.
     15        * Scripts/webkitpy/common/system/executive_mock.py:
     16        (MockExecutive.run_command):
     17        Update to print out the input passed to stdin.
     18        * Scripts/webkitpy/tool/commands/download_unittest.py:
     19        Updated due to executive_mock change.
     20        * Scripts/webkitpy/tool/commands/rebaseline.py:
     21        (RebaselineAll):
     22        (RebaselineAll._run_webkit_patch):
     23        (RebaselineAll._builders_to_fetch_from):
     24        (RebaselineAll._rebaseline_commands):
     25        (RebaselineAll._files_to_add):
     26        (RebaselineAll._optimize_baselines):
     27        (RebaselineAll._rebaseline):
     28        (RebaselineAll.execute):
     29        All this code is just copy-pasted except for mechanical changes
     30        (e.g. self.server.tool --> self._tool) and the reading in of the
     31        JSON from stdin instead of the post body.
     32        * Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
     33        (test_rebaseline_all):
     34        Copied the test-case out of gardeningserver_unittest.py.
     35        * Scripts/webkitpy/tool/servers/gardeningserver.py:
     36        (GardeningHTTPRequestHandler):
     37        (GardeningHTTPRequestHandler.rebaseline):
     38        (GardeningHTTPRequestHandler.rebaselineall):
     39        * Scripts/webkitpy/tool/servers/gardeningserver_unittest.py:
     40        (GardeningServerTest.test_rebaselineall):
     41        (GardeningServerTest.test_rebaselineall.run_command):
     42
    1432012-07-02  Ojan Vafai  <ojan@chromium.org>
    244
  • trunk/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py

    r107136 r121699  
    260260        mock_patch.contents = lambda: "foo"
    261261        mock_patch.reviewer = lambda: None
    262         expected_stderr = "MOCK run_command: ['svn-apply', '--force'], cwd=/mock-checkout\n"
     262        expected_stderr = "MOCK run_command: ['svn-apply', '--force'], cwd=/mock-checkout, input=foo\n"
    263263        OutputCapture().assert_outputs(self, checkout.apply_patch, [mock_patch], expected_stderr=expected_stderr)
  • trunk/Tools/Scripts/webkitpy/common/system/executive_mock.py

    r120846 r121699  
    8989            if env:
    9090                env_string = ", env=%s" % env
    91             log("MOCK run_command: %s, cwd=%s%s" % (args, cwd, env_string))
     91            input_string = ""
     92            if input:
     93                input_string = ", input=%s" % input
     94            log("MOCK run_command: %s, cwd=%s%s%s" % (args, cwd, env_string, input_string))
    9295        output = "MOCK output of child process"
    9396        if self._should_throw:
  • trunk/Tools/Scripts/webkitpy/tool/commands/download_unittest.py

    r116572 r121699  
    137137        expected_stderr = """MOCK run_and_throw_if_fail: ['mock-prepare-ChangeLog', '--email=MOCK email', '--merge-base=None', 'MockFile1'], cwd=/mock-checkout
    138138MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--git-commit', 'MOCK git commit', '--diff-files', 'MockFile1', '--filter', '-changelog'], cwd=/mock-checkout
    139 MOCK run_command: ['ruby', '-I', '/mock-checkout/Websites/bugs.webkit.org/PrettyPatch', '/mock-checkout/Websites/bugs.webkit.org/PrettyPatch/prettify.rb'], cwd=None
     139MOCK run_command: ['ruby', '-I', '/mock-checkout/Websites/bugs.webkit.org/PrettyPatch', '/mock-checkout/Websites/bugs.webkit.org/PrettyPatch/prettify.rb'], cwd=None, input=Patch1
    140140MOCK: user.open_url: file://...
    141141Was that diff correct?
  • trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py

    r121577 r121699  
    3333import re
    3434import shutil
     35import sys
    3536import urllib
    3637
     
    302303
    303304
     305class RebaselineAll(AbstractDeclarativeCommand):
     306    name = "rebaseline-all"
     307    help_text = "Rebaseline based off JSON passed to stdin. Intended to only be called from other scripts."
     308
     309    def _run_webkit_patch(self, args):
     310        try:
     311            self._tool.executive.run_command([self._tool.path()] + args, cwd=self._tool.scm().checkout_root)
     312        except ScriptError, e:
     313            _log.error(e)
     314
     315    def _builders_to_fetch_from(self, builders):
     316        # This routine returns the subset of builders that will cover all of the baseline search paths
     317        # used in the input list. In particular, if the input list contains both Release and Debug
     318        # versions of a configuration, we *only* return the Release version (since we don't save
     319        # debug versions of baselines).
     320        release_builders = set()
     321        debug_builders = set()
     322        builders_to_fallback_paths = {}
     323        for builder in builders:
     324            port = self._tool.port_factory.get_from_builder_name(builder)
     325            if port.test_configuration().build_type == 'Release':
     326                release_builders.add(builder)
     327            else:
     328                debug_builders.add(builder)
     329        for builder in list(release_builders) + list(debug_builders):
     330            port = self._tool.port_factory.get_from_builder_name(builder)
     331            fallback_path = port.baseline_search_path()
     332            if fallback_path not in builders_to_fallback_paths.values():
     333                builders_to_fallback_paths[builder] = fallback_path
     334        return builders_to_fallback_paths.keys()
     335
     336    def _rebaseline_commands(self, test_list):
     337        path_to_webkit_patch = self._tool.path()
     338        cwd = self._tool.scm().checkout_root
     339        commands = []
     340        for test in test_list:
     341            for builder in self._builders_to_fetch_from(test_list[test]):
     342                suffixes = ','.join(test_list[test][builder])
     343                cmd_line = [path_to_webkit_patch, 'rebaseline-test', '--print-scm-changes', '--suffixes', suffixes, builder, test]
     344                commands.append(tuple([cmd_line, cwd]))
     345        return commands
     346
     347    def _files_to_add(self, command_results):
     348        files_to_add = set()
     349        for output in [result[1] for result in command_results]:
     350            try:
     351                files_to_add.update(json.loads(output)['add'])
     352            except ValueError, e:
     353                _log.warning('"%s" is not a JSON object, ignoring' % output)
     354
     355        return list(files_to_add)
     356
     357    def _optimize_baselines(self, test_list):
     358        # We don't run this in parallel because modifying the SCM in parallel is unreliable.
     359        for test in test_list:
     360            all_suffixes = set()
     361            for builder in self._builders_to_fetch_from(test_list[test]):
     362                all_suffixes.update(test_list[test][builder])
     363            self._run_webkit_patch(['optimize-baselines', '--suffixes', ','.join(all_suffixes), test])
     364
     365    def _rebaseline(self, json_input):
     366        test_list = json.loads(json_input)
     367
     368        commands = self._rebaseline_commands(test_list)
     369        command_results = self._tool.executive.run_in_parallel(commands)
     370
     371        files_to_add = self._files_to_add(command_results)
     372        self._tool.scm().add_list(list(files_to_add))
     373
     374        self._optimize_baselines(test_list)
     375
     376    def execute(self, options, args, tool):
     377        self._rebaseline(sys.stdin.read())
     378
     379
    304380class Rebaseline(AbstractDeclarativeCommand):
    305381    name = "rebaseline"
  • trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py

    r121595 r121699  
    190190        OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Mac10.7", "userscripts/another-test.html", ["chromium-mac-snowleopard"], "txt"], expected_logs=expected_logs)
    191191
     192    def test_rebaseline_all(self):
     193        old_exact_matches = builders._exact_matches
     194        builders._exact_matches = {
     195            "MOCK builder": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])},
     196            "MOCK builder (Debug)": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier", "debug"])},
     197        }
     198
     199        command = RebaselineAll()
     200        tool = MockTool()
     201        command.bind_to_tool(tool)
     202        tool.executive = MockExecutive(should_log=True)
     203
     204        expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', u'txt,png', u'MOCK builder', u'user-scripts/another-test.html'], cwd=/mock-checkout
     205MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', u'txt,png', u'user-scripts/another-test.html'], cwd=/mock-checkout
     206"""
     207        OutputCapture().assert_outputs(self, command._rebaseline, ['{"user-scripts/another-test.html":{"MOCK builder": ["txt","png"]}}'], expected_stderr=expected_stderr)
     208
     209        expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', u'txt,png', u'MOCK builder (Debug)', u'user-scripts/another-test.html'], cwd=/mock-checkout
     210MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', u'txt,png', u'user-scripts/another-test.html'], cwd=/mock-checkout
     211"""
     212        OutputCapture().assert_outputs(self, command._rebaseline, ['{"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt","png"]}}'], expected_stderr=expected_stderr)
     213
     214        expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', u'txt', u'MOCK builder', u'user-scripts/another-test.html'], cwd=/mock-checkout
     215MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', u'txt', u'user-scripts/another-test.html'], cwd=/mock-checkout
     216"""
     217        OutputCapture().assert_outputs(self, command._rebaseline, ['{"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt","png"], "MOCK builder": ["txt"]}}'], expected_stderr=expected_stderr)
     218
     219        builders._exact_matches = old_exact_matches
     220
    192221    def test_rebaseline_expectations(self):
    193222        command = RebaselineExpectations()
  • trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py

    r120230 r121699  
    141141        self._serve_text('success')
    142142
     143    # FIXME: Is this dead code?
    143144    def rebaseline(self):
    144145        builder = self.query['builder'][0]
     
    156157        self._serve_text('success')
    157158
    158     def _builders_to_fetch_from(self, builders):
    159         # This routine returns the subset of builders that will cover all of the baseline search paths
    160         # used in the input list. In particular, if the input list contains both Release and Debug
    161         # versions of a configuration, we *only* return the Release version (since we don't save
    162         # debug versions of baselines).
    163         release_builders = set()
    164         debug_builders = set()
    165         builders_to_fallback_paths = {}
    166         for builder in builders:
    167             port = self.server.tool.port_factory.get_from_builder_name(builder)
    168             if port.test_configuration().build_type == 'Release':
    169                 release_builders.add(builder)
    170             else:
    171                 debug_builders.add(builder)
    172         for builder in list(release_builders) + list(debug_builders):
    173             port = self.server.tool.port_factory.get_from_builder_name(builder)
    174             fallback_path = port.baseline_search_path()
    175             if fallback_path not in builders_to_fallback_paths.values():
    176                 builders_to_fallback_paths[builder] = fallback_path
    177         return builders_to_fallback_paths.keys()
    178 
    179     def _rebaseline_commands(self, test_list):
    180         path_to_webkit_patch = self.server.tool.path()
    181         cwd = self.server.tool.scm().checkout_root
    182         commands = []
    183         for test in test_list:
    184             for builder in self._builders_to_fetch_from(test_list[test]):
    185                 suffixes = ','.join(test_list[test][builder])
    186                 cmd_line = [path_to_webkit_patch, 'rebaseline-test', '--print-scm-changes', '--suffixes', suffixes, builder, test]
    187                 commands.append(tuple([cmd_line, cwd]))
    188         return commands
    189 
    190     def _files_to_add(self, command_results):
    191         files_to_add = set()
    192         for output in [result[1] for result in command_results]:
    193             try:
    194                 files_to_add.update(json.loads(output)['add'])
    195             except ValueError, e:
    196                 _log.warning('"%s" is not a JSON object, ignoring' % output)
    197 
    198         return list(files_to_add)
    199 
    200     def _optimize_baselines(self, test_list):
    201         # We don't run this in parallel because modifying the SCM in parallel is unreliable.
    202         for test in test_list:
    203             all_suffixes = set()
    204             for builder in self._builders_to_fetch_from(test_list[test]):
    205                 all_suffixes.update(test_list[test][builder])
    206             self._run_webkit_patch(['optimize-baselines', '--suffixes', ','.join(all_suffixes), test])
    207 
    208159    def rebaselineall(self):
    209         test_list = self._read_entity_body_as_json()
    210 
    211         commands = self._rebaseline_commands(test_list)
    212         command_results = self.server.tool.executive.run_in_parallel(commands)
    213 
    214         files_to_add = self._files_to_add(command_results)
    215         self.server.tool.scm().add_list(list(files_to_add))
    216 
    217         self._optimize_baselines(test_list)
     160        command = ['rebaseline-all']
     161        self.server.tool.executive.run_command([self.server.tool.path()] + command, input=self.read_entity_body(), cwd=self.server.tool.scm().checkout_root)
    218162        self._serve_text('success')
  • trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py

    r121194 r121699  
    7070        return GardeningExpectationsUpdater(self.server.tool, TestPortFactory.create())
    7171
    72     def _read_entity_body(self):
     72    def read_entity_body(self):
    7373        return self.body if self.body else ''
    7474
     
    184184
    185185    def test_rebaselineall(self):
    186         builders._exact_matches = {
    187             "MOCK builder": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])},
    188             "MOCK builder (Debug)": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier", "debug"])},
    189         }
    190         expected_stderr = "MOCK run_command: ['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', u'%s', u'%s', u'user-scripts/another-test.html'], cwd=/mock-checkout\nMOCK run_command: ['echo', 'optimize-baselines', '--suffixes', u'%s', u'user-scripts/another-test.html'], cwd=/mock-checkout\n"
     186        expected_stderr = "MOCK run_command: ['echo', 'rebaseline-all'], cwd=/mock-checkout, input={\"user-scripts/another-test.html\":{\"%s\": [%s]}}\n"
    191187        expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n"
    192188        server = MockServer()
     
    194190        self.output = ['{"add": [], "delete": []}', '']
    195191
    196         def run_command(args, cwd=None, **kwargs):
    197             print >> sys.stderr, "MOCK run_command: %s, cwd=%s" % (args, cwd)
     192        def run_command(args, cwd=None, input=None, **kwargs):
     193            print >> sys.stderr, "MOCK run_command: %s, cwd=%s, input=%s" % (args, cwd, input)
    198194            return self.output.pop(0)
    199195
    200196        server.tool.executive.run_command = run_command
    201         self._post_to_path("/rebaselineall", body='{"user-scripts/another-test.html":{"MOCK builder": ["txt","png"]}}', expected_stderr=expected_stderr % ('txt,png', 'MOCK builder', 'txt,png'), expected_stdout=expected_stdout, server=server)
    202 
    203         self._post_to_path("/rebaselineall", body='{"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt","png"]}}', expected_stderr=expected_stderr % ('txt,png', 'MOCK builder (Debug)', 'txt,png'), expected_stdout=expected_stdout)
    204 
    205         self._post_to_path("/rebaselineall", body='{"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt","png"], "MOCK builder": ["txt"]}}', expected_stderr=expected_stderr % ('txt', 'MOCK builder', 'txt'), expected_stdout=expected_stdout)
     197        self._post_to_path("/rebaselineall", body='{"user-scripts/another-test.html":{"MOCK builder": ["txt","png"]}}', expected_stderr=expected_stderr % ('MOCK builder', '"txt","png"'), expected_stdout=expected_stdout, server=server)
     198
     199        self._post_to_path("/rebaselineall", body='{"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt","png"]}}', expected_stderr=expected_stderr % ('MOCK builder (Debug)', '"txt","png"'), expected_stdout=expected_stdout)
    206200
    207201    def test_rebaseline_new_port(self):
  • trunk/Tools/Scripts/webkitpy/tool/servers/reflectionhandler.py

    r107302 r121699  
    6060        self._handle_request()
    6161
    62     def _read_entity_body(self):
     62    def read_entity_body(self):
    6363        length = int(self.headers.getheader('content-length'))
    6464        return self.rfile.read(length)
    6565
    6666    def _read_entity_body_as_json(self):
    67         return json.loads(self._read_entity_body())
     67        return json.loads(self.read_entity_body())
    6868
    6969    def _handle_request(self):
Note: See TracChangeset for help on using the changeset viewer.