Changeset 121724 in webkit
- Timestamp:
- Jul 2, 2012 8:36:05 PM (12 years ago)
- Location:
- trunk/Tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r121723 r121724 1 2012-07-02 Ojan Vafai <ojan@chromium.org> 2 3 webkit-patch rebaseline-expectations should share code with rebaseline-all 4 https://bugs.webkit.org/show_bug.cgi?id=90413 5 6 Reviewed by Dirk Pranke. 7 8 Make them share code. In addition to reducing code duplication this makes 9 rebaseline-expectations considerably faster by rebaselining in parallel. 10 11 * Scripts/webkitpy/tool/commands/rebaseline.py: 12 (AbstractParallelRebaselineCommand): 13 (AbstractParallelRebaselineCommand._run_webkit_patch): 14 (AbstractParallelRebaselineCommand._rebaseline): 15 (RebaselineJson): 16 (RebaselineJson.execute): 17 (RebaselineExpectations): 18 (RebaselineExpectations._update_expectations_file): 19 (RebaselineExpectations._tests_to_rebaseline): 20 (RebaselineExpectations._add_tests_to_rebaseline_for_port): 21 (RebaselineExpectations.execute): 22 * Scripts/webkitpy/tool/commands/rebaseline_unittest.py: 23 (test_rebaseline_all): 24 (test_rebaseline_expectations.run_in_parallel): 25 (test_rebaseline_expectations): 26 1 27 2012-07-02 Xiaobo Wang <xbwang@torchmobile.com.cn> 2 28 -
trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py
r121699 r121724 240 240 241 241 242 class RebaselineExpectations(AbstractDeclarativeCommand): 243 name = "rebaseline-expectations" 244 help_text = "Rebaselines the tests indicated in TestExpectations." 245 242 class AbstractParallelRebaselineCommand(AbstractDeclarativeCommand): 246 243 def __init__(self): 247 244 options = [ … … 252 249 ] 253 250 AbstractDeclarativeCommand.__init__(self, options=options) 254 255 def _run_webkit_patch(self, args):256 try:257 self._tool.executive.run_command([self._tool.path()] + args, cwd=self._tool.scm().checkout_root)258 except ScriptError, e:259 _log.error(e)260 261 def _update_expectations_file(self, port_name):262 port = self._tool.port_factory.get(port_name)263 264 # FIXME: This will intentionally skip over any REBASELINE expectations that were in an overrides file.265 # This is not good, but avoids having the overrides getting written into the main file.266 # See https://bugs.webkit.org/show_bug.cgi?id=88456 for context. This will no longer be needed267 # once we properly support cascading expectations files.268 expectations = TestExpectations(port, include_overrides=False)269 path = port.path_to_test_expectations_file()270 self._tool.filesystem.write_text_file(path, expectations.remove_rebaselined_tests(expectations.get_rebaselining_failures()))271 272 def _tests_to_rebaseline(self, port):273 tests_to_rebaseline = {}274 expectations = TestExpectations(port, include_overrides=True)275 for test in expectations.get_rebaselining_failures():276 tests_to_rebaseline[test] = suffixes_for_expectations(expectations.get_expectations(test))277 return tests_to_rebaseline278 279 def _rebaseline_port(self, port_name):280 builder_name = builders.builder_name_for_port_name(port_name)281 if not builder_name:282 return283 tests = self._tests_to_rebaseline(self._tool.port_factory.get(port_name)).items()284 if tests:285 _log.info("Retrieving results for %s from %s." % (port_name, builder_name))286 for test_name, suffixes in tests:287 self._touched_tests.setdefault(test_name, set()).update(set(suffixes))288 _log.info(" %s (%s)" % (test_name, ','.join(suffixes)))289 # FIXME: we should use executive.run_in_parallel() to speed this up.290 self._run_webkit_patch(['rebaseline-test', '--suffixes', ','.join(suffixes), builder_name, test_name])291 292 def execute(self, options, args, tool):293 self._touched_tests = {}294 for port_name in tool.port_factory.all_port_names():295 self._rebaseline_port(port_name)296 for port_name in tool.port_factory.all_port_names():297 self._update_expectations_file(port_name)298 if not options.optimize:299 return300 for test_name, suffixes in self._touched_tests.iteritems():301 _log.info("Optimizing baselines for %s (%s)." % (test_name, ','.join(suffixes)))302 self._run_webkit_patch(['optimize-baselines', '--suffixes', ','.join(suffixes), test_name])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 251 309 252 def _run_webkit_patch(self, args): … … 363 306 self._run_webkit_patch(['optimize-baselines', '--suffixes', ','.join(all_suffixes), test]) 364 307 365 def _rebaseline(self, json_input): 366 test_list = json.loads(json_input) 367 308 def _rebaseline(self, options, test_list): 368 309 commands = self._rebaseline_commands(test_list) 369 310 command_results = self._tool.executive.run_in_parallel(commands) … … 372 313 self._tool.scm().add_list(list(files_to_add)) 373 314 374 self._optimize_baselines(test_list) 375 376 def execute(self, options, args, tool): 377 self._rebaseline(sys.stdin.read()) 378 379 315 if options.optimize: 316 self._optimize_baselines(test_list) 317 318 319 class RebaselineJson(AbstractParallelRebaselineCommand): 320 name = "rebaseline-json" 321 help_text = "Rebaseline based off JSON passed to stdin. Intended to only be called from other scripts." 322 323 def execute(self, options, args, tool): 324 self._rebaseline(options, json.loads(sys.stdin.read())) 325 326 327 class RebaselineExpectations(AbstractParallelRebaselineCommand): 328 name = "rebaseline-expectations" 329 help_text = "Rebaselines the tests indicated in TestExpectations." 330 331 def _update_expectations_file(self, port_name): 332 port = self._tool.port_factory.get(port_name) 333 334 # FIXME: This will intentionally skip over any REBASELINE expectations that were in an overrides file. 335 # This is not good, but avoids having the overrides getting written into the main file. 336 # See https://bugs.webkit.org/show_bug.cgi?id=88456 for context. This will no longer be needed 337 # once we properly support cascading expectations files. 338 expectations = TestExpectations(port, include_overrides=False) 339 path = port.path_to_test_expectations_file() 340 self._tool.filesystem.write_text_file(path, expectations.remove_rebaselined_tests(expectations.get_rebaselining_failures())) 341 342 def _tests_to_rebaseline(self, port): 343 tests_to_rebaseline = {} 344 expectations = TestExpectations(port, include_overrides=True) 345 for test in expectations.get_rebaselining_failures(): 346 tests_to_rebaseline[test] = suffixes_for_expectations(expectations.get_expectations(test)) 347 return tests_to_rebaseline 348 349 def _add_tests_to_rebaseline_for_port(self, port_name): 350 builder_name = builders.builder_name_for_port_name(port_name) 351 if not builder_name: 352 return 353 tests = self._tests_to_rebaseline(self._tool.port_factory.get(port_name)).items() 354 355 if tests: 356 _log.info("Retrieving results for %s from %s." % (port_name, builder_name)) 357 358 for test_name, suffixes in tests: 359 _log.info(" %s (%s)" % (test_name, ','.join(suffixes))) 360 if test_name not in self._test_list: 361 self._test_list[test_name] = {} 362 self._test_list[test_name][builder_name] = suffixes 363 364 def execute(self, options, args, tool): 365 self._test_list = {} 366 for port_name in tool.port_factory.all_port_names(): 367 self._add_tests_to_rebaseline_for_port(port_name) 368 self._rebaseline(options, self._test_list) 369 370 for port_name in tool.port_factory.all_port_names(): 371 self._update_expectations_file(port_name) 372 373 374 # FIXME: Merge this with rebaseline-test. The only difference is that this prompts if you leave out the test-name, builder or suffixes. 375 # We should just make rebaseline-test prompt and get rid of this command. 380 376 class Rebaseline(AbstractDeclarativeCommand): 381 377 name = "rebaseline" -
trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py
r121699 r121724 197 197 } 198 198 199 command = RebaselineAll() 200 tool = MockTool() 199 command = RebaselineJson() 200 tool = MockTool() 201 options = MockOptions() 202 options.optimize = True 201 203 command.bind_to_tool(tool) 202 204 tool.executive = MockExecutive(should_log=True) 203 205 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-checkout205 MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', u'txt,png', u'user-scripts/another-test.html'], cwd=/mock-checkout206 """ 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-checkout210 MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', u'txt,png', u'user-scripts/another-test.html'], cwd=/mock-checkout211 """ 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-checkout215 MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', u'txt', u'user-scripts/another-test.html'], cwd=/mock-checkout216 """ 217 OutputCapture().assert_outputs(self, command._rebaseline, [ '{"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt","png"], "MOCK builder": ["txt"]}}'], expected_stderr=expected_stderr)206 expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt,png', 'MOCK builder', 'user-scripts/another-test.html'], cwd=/mock-checkout 207 MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt,png', 'user-scripts/another-test.html'], cwd=/mock-checkout 208 """ 209 OutputCapture().assert_outputs(self, command._rebaseline, [options, {"user-scripts/another-test.html":{"MOCK builder": ["txt", "png"]}}], expected_stderr=expected_stderr) 210 211 expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt,png', 'MOCK builder (Debug)', 'user-scripts/another-test.html'], cwd=/mock-checkout 212 MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt,png', 'user-scripts/another-test.html'], cwd=/mock-checkout 213 """ 214 OutputCapture().assert_outputs(self, command._rebaseline, [options, {"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt", "png"]}}], expected_stderr=expected_stderr) 215 216 expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt', 'MOCK builder', 'user-scripts/another-test.html'], cwd=/mock-checkout 217 MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt', 'user-scripts/another-test.html'], cwd=/mock-checkout 218 """ 219 OutputCapture().assert_outputs(self, command._rebaseline, [options, {"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt", "png"], "MOCK builder": ["txt"]}}], expected_stderr=expected_stderr) 218 220 219 221 builders._exact_matches = old_exact_matches … … 232 234 tool.executive = MockExecutive(should_log=True) 233 235 236 def run_in_parallel(commands): 237 print commands 238 return "" 239 240 tool.executive.run_in_parallel = run_in_parallel 241 234 242 expected_logs = """Retrieving results for chromium-linux-x86 from Webkit Linux 32. 235 243 userscripts/another-test.html (txt) … … 267 275 """ 268 276 269 expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Linux 32', 'userscripts/another-test.html'], cwd=/mock-checkout 270 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Linux 32', 'userscripts/images.svg'], cwd=/mock-checkout 271 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Linux', 'userscripts/another-test.html'], cwd=/mock-checkout 272 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Linux', 'userscripts/images.svg'], cwd=/mock-checkout 273 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Mac10.7', 'userscripts/another-test.html'], cwd=/mock-checkout 274 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Mac10.7', 'userscripts/images.svg'], cwd=/mock-checkout 275 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Mac10.6', 'userscripts/another-test.html'], cwd=/mock-checkout 276 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Mac10.6', 'userscripts/images.svg'], cwd=/mock-checkout 277 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Win7', 'userscripts/another-test.html'], cwd=/mock-checkout 278 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Win7', 'userscripts/images.svg'], cwd=/mock-checkout 279 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Win', 'userscripts/another-test.html'], cwd=/mock-checkout 280 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Win', 'userscripts/images.svg'], cwd=/mock-checkout 281 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'EFL Linux 64-bit Release', 'userscripts/another-test.html'], cwd=/mock-checkout 282 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'EFL Linux 64-bit Release', 'userscripts/images.svg'], cwd=/mock-checkout 283 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'GTK Linux 64-bit Release', 'userscripts/another-test.html'], cwd=/mock-checkout 284 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'GTK Linux 64-bit Release', 'userscripts/images.svg'], cwd=/mock-checkout 285 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Apple Lion Release WK1 (Tests)', 'userscripts/another-test.html'], cwd=/mock-checkout 286 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Apple Lion Release WK1 (Tests)', 'userscripts/images.svg'], cwd=/mock-checkout 287 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Qt Linux Release', 'userscripts/another-test.html'], cwd=/mock-checkout 288 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Qt Linux Release', 'userscripts/images.svg'], cwd=/mock-checkout 289 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Apple Win 7 Release (Tests)', 'userscripts/another-test.html'], cwd=/mock-checkout 290 MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Apple Win 7 Release (Tests)', 'userscripts/images.svg'], cwd=/mock-checkout 277 expected_stdout = """[(['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt', 'Webkit Linux 32', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt', 'Webkit Linux', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt', 'Webkit Mac10.6', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt', 'Webkit Mac10.7', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt', 'Webkit Win7', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt', 'Apple Win 7 Release (Tests)', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt', 'EFL Linux 64-bit Release', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt', 'Webkit Win', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt', 'GTK Linux 64-bit Release', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt', 'Qt Linux Release', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'txt', 'Apple Lion Release WK1 (Tests)', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'png', 'Webkit Linux 32', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'png', 'Webkit Linux', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'png', 'Webkit Mac10.6', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'png', 'Webkit Mac10.7', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'png', 'Webkit Win7', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'png', 'Apple Win 7 Release (Tests)', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'png', 'EFL Linux 64-bit Release', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'png', 'Webkit Win', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'png', 'GTK Linux 64-bit Release', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'png', 'Qt Linux Release', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test', '--print-scm-changes', '--suffixes', 'png', 'Apple Lion Release WK1 (Tests)', 'userscripts/images.svg'], '/mock-checkout')] 278 """ 279 280 expected_stderr = """MOCK run_command: ['qmake', '-v'], cwd=None 281 MOCK run_command: ['qmake', '-v'], cwd=None 291 282 MOCK run_command: ['qmake', '-v'], cwd=None 292 283 MOCK run_command: ['qmake', '-v'], cwd=None … … 296 287 297 288 command._tests_to_rebaseline = lambda port: {'userscripts/another-test.html': set(['txt']), 'userscripts/images.svg': set(['png'])} 298 OutputCapture().assert_outputs(self, command.execute, [MockOptions(optimize=False), [], tool], expected_logs=expected_logs, expected_stderr=expected_stderr) 299 300 expected_logs_with_optimize = expected_logs + ( 301 "Optimizing baselines for userscripts/another-test.html (txt).\n" 302 "Optimizing baselines for userscripts/images.svg (png).\n") 303 expected_stderr_with_optimize = expected_stderr + ( 304 "MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt', 'userscripts/another-test.html'], cwd=/mock-checkout\n" 305 "MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'png', 'userscripts/images.svg'], cwd=/mock-checkout\n") 289 OutputCapture().assert_outputs(self, command.execute, [MockOptions(optimize=False), [], tool], expected_logs=expected_logs, expected_stdout=expected_stdout, expected_stderr=expected_stderr) 290 291 expected_stderr_with_optimize = """MOCK run_command: ['qmake', '-v'], cwd=None 292 MOCK run_command: ['qmake', '-v'], cwd=None 293 MOCK run_command: ['qmake', '-v'], cwd=None 294 MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt', 'userscripts/another-test.html'], cwd=/mock-checkout 295 MOCK run_command: ['qmake', '-v'], cwd=None 296 MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'png', 'userscripts/images.svg'], cwd=/mock-checkout 297 MOCK run_command: ['qmake', '-v'], cwd=None 298 MOCK run_command: ['qmake', '-v'], cwd=None 299 MOCK run_command: ['qmake', '-v'], cwd=None 300 MOCK run_command: ['qmake', '-v'], cwd=None 301 """ 306 302 307 303 command._tests_to_rebaseline = lambda port: {'userscripts/another-test.html': set(['txt']), 'userscripts/images.svg': set(['png'])} 308 OutputCapture().assert_outputs(self, command.execute, [MockOptions(optimize=True), [], tool], expected_logs=expected_logs _with_optimize, expected_stderr=expected_stderr_with_optimize)304 OutputCapture().assert_outputs(self, command.execute, [MockOptions(optimize=True), [], tool], expected_logs=expected_logs, expected_stdout=expected_stdout, expected_stderr=expected_stderr_with_optimize) 309 305 310 306 def test_overrides_are_included_correctly(self): -
trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py
r121706 r121724 142 142 143 143 def rebaselineall(self): 144 command = ['rebaseline- all']144 command = ['rebaseline-json'] 145 145 self.server.tool.executive.run_command([self.server.tool.path()] + command, input=self.read_entity_body(), cwd=self.server.tool.scm().checkout_root) 146 146 self._serve_text('success') -
trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py
r121706 r121724 184 184 185 185 def test_rebaselineall(self): 186 expected_stderr = "MOCK run_command: ['echo', 'rebaseline- all'], cwd=/mock-checkout, input={\"user-scripts/another-test.html\":{\"%s\": [%s]}}\n"186 expected_stderr = "MOCK run_command: ['echo', 'rebaseline-json'], cwd=/mock-checkout, input={\"user-scripts/another-test.html\":{\"%s\": [%s]}}\n" 187 187 expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n" 188 188 server = MockServer()
Note: See TracChangeset
for help on using the changeset viewer.