Changeset 121699 in webkit
- Timestamp:
- Jul 2, 2012 12:22:43 PM (12 years ago)
- Location:
- trunk/Tools
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r121696 r121699 1 2012-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 1 43 2012-07-02 Ojan Vafai <ojan@chromium.org> 2 44 -
trunk/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py
r107136 r121699 260 260 mock_patch.contents = lambda: "foo" 261 261 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" 263 263 OutputCapture().assert_outputs(self, checkout.apply_patch, [mock_patch], expected_stderr=expected_stderr) -
trunk/Tools/Scripts/webkitpy/common/system/executive_mock.py
r120846 r121699 89 89 if env: 90 90 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)) 92 95 output = "MOCK output of child process" 93 96 if self._should_throw: -
trunk/Tools/Scripts/webkitpy/tool/commands/download_unittest.py
r116572 r121699 137 137 expected_stderr = """MOCK run_and_throw_if_fail: ['mock-prepare-ChangeLog', '--email=MOCK email', '--merge-base=None', 'MockFile1'], cwd=/mock-checkout 138 138 MOCK 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 139 MOCK run_command: ['ruby', '-I', '/mock-checkout/Websites/bugs.webkit.org/PrettyPatch', '/mock-checkout/Websites/bugs.webkit.org/PrettyPatch/prettify.rb'], cwd=None, input=Patch1 140 140 MOCK: user.open_url: file://... 141 141 Was that diff correct? -
trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py
r121577 r121699 33 33 import re 34 34 import shutil 35 import sys 35 36 import urllib 36 37 … … 302 303 303 304 305 class 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 304 380 class Rebaseline(AbstractDeclarativeCommand): 305 381 name = "rebaseline" -
trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py
r121595 r121699 190 190 OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Mac10.7", "userscripts/another-test.html", ["chromium-mac-snowleopard"], "txt"], expected_logs=expected_logs) 191 191 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 205 MOCK 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 210 MOCK 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 215 MOCK 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 192 221 def test_rebaseline_expectations(self): 193 222 command = RebaselineExpectations() -
trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py
r120230 r121699 141 141 self._serve_text('success') 142 142 143 # FIXME: Is this dead code? 143 144 def rebaseline(self): 144 145 builder = self.query['builder'][0] … … 156 157 self._serve_text('success') 157 158 158 def _builders_to_fetch_from(self, builders):159 # This routine returns the subset of builders that will cover all of the baseline search paths160 # used in the input list. In particular, if the input list contains both Release and Debug161 # versions of a configuration, we *only* return the Release version (since we don't save162 # 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_path177 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_root182 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 commands189 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 208 159 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) 218 162 self._serve_text('success') -
trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py
r121194 r121699 70 70 return GardeningExpectationsUpdater(self.server.tool, TestPortFactory.create()) 71 71 72 def _read_entity_body(self):72 def read_entity_body(self): 73 73 return self.body if self.body else '' 74 74 … … 184 184 185 185 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" 191 187 expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n" 192 188 server = MockServer() … … 194 190 self.output = ['{"add": [], "delete": []}', ''] 195 191 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) 198 194 return self.output.pop(0) 199 195 200 196 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) 206 200 207 201 def test_rebaseline_new_port(self): -
trunk/Tools/Scripts/webkitpy/tool/servers/reflectionhandler.py
r107302 r121699 60 60 self._handle_request() 61 61 62 def _read_entity_body(self):62 def read_entity_body(self): 63 63 length = int(self.headers.getheader('content-length')) 64 64 return self.rfile.read(length) 65 65 66 66 def _read_entity_body_as_json(self): 67 return json.loads(self. _read_entity_body())67 return json.loads(self.read_entity_body()) 68 68 69 69 def _handle_request(self):
Note: See TracChangeset
for help on using the changeset viewer.