Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(715)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/rebaseline.py

Issue 2261833003: Don't run git add/rm after rebaseline commands for rebaseline-cl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2010 Google Inc. All rights reserved. 1 # Copyright (c) 2010 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 def _port_skips_test(port, test, generic_expectations, full_expectations): 427 def _port_skips_test(port, test, generic_expectations, full_expectations):
428 fs = port.host.filesystem 428 fs = port.host.filesystem
429 if port.default_smoke_test_only(): 429 if port.default_smoke_test_only():
430 smoke_test_filename = fs.join(port.layout_tests_dir(), 'SmokeTests') 430 smoke_test_filename = fs.join(port.layout_tests_dir(), 'SmokeTests')
431 if fs.exists(smoke_test_filename) and test not in fs.read_text_file( smoke_test_filename): 431 if fs.exists(smoke_test_filename) and test not in fs.read_text_file( smoke_test_filename):
432 return True 432 return True
433 433
434 return (SKIP in full_expectations.get_expectations(test) and 434 return (SKIP in full_expectations.get_expectations(test) and
435 SKIP not in generic_expectations.get_expectations(test)) 435 SKIP not in generic_expectations.get_expectations(test))
436 436
437 def _run_in_parallel_and_update_scm(self, commands): 437 def _run_in_parallel(self, commands, update_scm=True):
438 if not commands: 438 if not commands:
439 return {} 439 return {}
440 440
441 command_results = self._tool.executive.run_in_parallel(commands) 441 command_results = self._tool.executive.run_in_parallel(commands)
442 log_output = '\n'.join(result[2] for result in command_results).replace( '\n\n', '\n') 442 log_output = '\n'.join(result[2] for result in command_results).replace( '\n\n', '\n')
443 for line in log_output.split('\n'): 443 for line in log_output.split('\n'):
444 if line: 444 if line:
445 _log.error(line) 445 _log.error(line)
446 446
447 files_to_add, files_to_delete, lines_to_remove = self._serial_commands(c ommand_results) 447 files_to_add, files_to_delete, lines_to_remove = self._serial_commands(c ommand_results)
448 if files_to_delete: 448 # TODO(qyearsley): Consider removing this if possible,
449 self._tool.scm().delete_list(files_to_delete) 449 # or making it work and produce reasonable results for rebaseline-cl.
qyearsley 2016/08/19 22:45:46 Some thoughts: maybe if all file additions and del
wkorman 2016/08/19 22:54:07 Yeah, auto-rebaseline has to commit so that it can
450 if files_to_add: 450 if update_scm:
wkorman 2016/08/19 22:54:07 How much of a pain to add unit test to make sure t
qyearsley 2016/08/19 23:32:27 Hmm, maybe not too much. Possible test methods cou
wkorman 2016/08/20 00:58:29 Am ok with waiting on test as we hope to turn auto
451 self._tool.scm().add_list(files_to_add) 451 if files_to_delete:
452 self._tool.scm().delete_list(files_to_delete)
453 if files_to_add:
454 self._tool.scm().add_list(files_to_add)
452 return lines_to_remove 455 return lines_to_remove
453 456
454 def _rebaseline(self, options, test_prefix_list): 457 def _rebaseline(self, options, test_prefix_list, update_scm=True):
455 """Downloads new baselines in parallel, then updates expectations files 458 """Downloads new baselines in parallel, then updates expectations files
456 and optimizes baselines. 459 and optimizes baselines.
457 460
458 Args: 461 Args:
459 options: An object with the options passed to the current command. 462 options: An object with the options passed to the current command.
460 test_prefix_list: A map of test names to Build objects to file suffi xes 463 test_prefix_list: A map of test names to Build objects to file suffi xes
461 for new baselines. For example: 464 for new baselines. For example:
462 { 465 {
463 "some/test.html": {Build("builder-1", 412): ["txt"], Build(" builder-2", 100): ["txt"]}, 466 "some/test.html": {Build("builder-1", 412): ["txt"], Build(" builder-2", 100): ["txt"]},
464 "some/other.html": {Build("builder-1", 412): ["txt"]} 467 "some/other.html": {Build("builder-1", 412): ["txt"]}
465 } 468 }
466 This would mean that new text baselines should be downloaded for 469 This would mean that new text baselines should be downloaded for
467 "some/test.html" on both builder-1 (build 412) and builder-2 470 "some/test.html" on both builder-1 (build 412) and builder-2
468 (build 100), and new text baselines should be downloaded for 471 (build 100), and new text baselines should be downloaded for
469 "some/other.html" but only from builder-1. 472 "some/other.html" but only from builder-1.
470 TODO(qyearsley): Replace test_prefix_list everywhere with some 473 TODO(qyearsley): Replace test_prefix_list everywhere with some
471 sort of class that contains the same data. 474 sort of class that contains the same data.
475 update_scm: If True, commands like `git add` and `git rm` will be ru n.
472 """ 476 """
473 for test, builds_to_check in sorted(test_prefix_list.items()): 477 for test, builds_to_check in sorted(test_prefix_list.items()):
474 _log.info("Rebaselining %s", test) 478 _log.info("Rebaselining %s", test)
475 for build, suffixes in sorted(builds_to_check.items()): 479 for build, suffixes in sorted(builds_to_check.items()):
476 _log.debug(" %s: %s", build, ",".join(suffixes)) 480 _log.debug(" %s: %s", build, ",".join(suffixes))
477 481
478 copy_baseline_commands, rebaseline_commands, extra_lines_to_remove = sel f._rebaseline_commands( 482 copy_baseline_commands, rebaseline_commands, extra_lines_to_remove = sel f._rebaseline_commands(
479 test_prefix_list, options) 483 test_prefix_list, options)
480 lines_to_remove = {} 484 lines_to_remove = {}
481 485
482 self._run_in_parallel_and_update_scm(copy_baseline_commands) 486 self._run_in_parallel(copy_baseline_commands, update_scm=update_scm)
483 lines_to_remove = self._run_in_parallel_and_update_scm(rebaseline_comman ds) 487 lines_to_remove = self._run_in_parallel(rebaseline_commands, update_scm= update_scm)
484 488
485 for test in extra_lines_to_remove: 489 for test in extra_lines_to_remove:
486 if test in lines_to_remove: 490 if test in lines_to_remove:
487 lines_to_remove[test] = lines_to_remove[test] + extra_lines_to_r emove[test] 491 lines_to_remove[test] = lines_to_remove[test] + extra_lines_to_r emove[test]
488 else: 492 else:
489 lines_to_remove[test] = extra_lines_to_remove[test] 493 lines_to_remove[test] = extra_lines_to_remove[test]
490 494
491 if lines_to_remove: 495 if lines_to_remove:
492 self._update_expectations_files(lines_to_remove) 496 self._update_expectations_files(lines_to_remove)
493 497
494 if options.optimize: 498 if options.optimize:
495 # TODO(wkorman): Consider changing temporary branch to base off of H EAD rather than 499 # TODO(wkorman): Consider changing temporary branch to base off of H EAD rather than
496 # origin/master to ensure we run baseline optimization processes wit h the same code as 500 # origin/master to ensure we run baseline optimization processes wit h the same code as
497 # auto-rebaseline itself. 501 # auto-rebaseline itself.
498 self._run_in_parallel_and_update_scm(self._optimize_baselines(test_p refix_list, options.verbose)) 502 self._run_in_parallel(self._optimize_baselines(test_prefix_list, opt ions.verbose), update_scm=update_scm)
499 503
500 def _suffixes_for_actual_failures(self, test, build, existing_suffixes): 504 def _suffixes_for_actual_failures(self, test, build, existing_suffixes):
501 """Gets the baseline suffixes for actual mismatch failures in some resul ts. 505 """Gets the baseline suffixes for actual mismatch failures in some resul ts.
502 506
503 Args: 507 Args:
504 test: A full test path string. 508 test: A full test path string.
505 build: A Build object. 509 build: A Build object.
506 existing_suffixes: A collection of all suffixes to consider. 510 existing_suffixes: A collection of all suffixes to consider.
507 511
508 Returns: 512 Returns:
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 for test in args: 626 for test in args:
623 if test not in test_prefix_list: 627 if test not in test_prefix_list:
624 test_prefix_list[test] = {} 628 test_prefix_list[test] = {}
625 build = Build(builder) 629 build = Build(builder)
626 test_prefix_list[test][build] = suffixes_to_update 630 test_prefix_list[test][build] = suffixes_to_update
627 631
628 if options.verbose: 632 if options.verbose:
629 _log.debug("rebaseline-json: " + str(test_prefix_list)) 633 _log.debug("rebaseline-json: " + str(test_prefix_list))
630 634
631 self._rebaseline(options, test_prefix_list) 635 self._rebaseline(options, test_prefix_list)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698