| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Fetches a copy of the latest state of a W3C test repository and commits. | 5 """Fetches a copy of the latest state of a W3C test repository and commits. |
| 6 | 6 |
| 7 If this script is given the argument --auto-update, it will also: | 7 If this script is given the argument --auto-update, it will also: |
| 8 1. Upload a CL. | 8 1. Upload a CL. |
| 9 2. Trigger try jobs and wait for them to complete. | 9 2. Trigger try jobs and wait for them to complete. |
| 10 3. Make any changes that are required for new failing tests. | 10 3. Make any changes that are required for new failing tests. |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 if not self.git_cl.is_closed(): | 354 if not self.git_cl.is_closed(): |
| 355 _log.error('CQ appears to have failed; aborting.') | 355 _log.error('CQ appears to have failed; aborting.') |
| 356 self.git_cl.run(['set-close']) | 356 self.git_cl.run(['set-close']) |
| 357 return False | 357 return False |
| 358 | 358 |
| 359 _log.info('Update completed.') | 359 _log.info('Update completed.') |
| 360 return True | 360 return True |
| 361 | 361 |
| 362 def _upload_cl(self): | 362 def _upload_cl(self): |
| 363 _log.info('Uploading change list.') | 363 _log.info('Uploading change list.') |
| 364 cc_list = self.get_directory_owners() | 364 directory_owners = self.get_directory_owners() |
| 365 description = self._cl_description() | 365 description = self._cl_description(directory_owners) |
| 366 self.git_cl.run([ | 366 self.git_cl.run([ |
| 367 'upload', | 367 'upload', |
| 368 '-f', | 368 '-f', |
| 369 '--rietveld', | 369 '--rietveld', |
| 370 '-m', | 370 '-m', |
| 371 description, | 371 description, |
| 372 ] + ['--cc=' + email for email in cc_list]) | 372 ] + ['--cc=' + email_address for email_address in directory_owners]) |
| 373 | 373 |
| 374 def get_directory_owners(self): | 374 def get_directory_owners(self): |
| 375 """Returns a list of email addresses of owners of changed tests.""" | 375 """Returns a list of email addresses of owners of changed tests.""" |
| 376 _log.info('Gathering directory owners emails to CC.') | 376 _log.info('Gathering directory owners emails to CC.') |
| 377 changed_files = self.host.scm().changed_files() | 377 changed_files = self.host.scm().changed_files() |
| 378 extractor = DirectoryOwnersExtractor(self.fs) | 378 extractor = DirectoryOwnersExtractor(self.fs) |
| 379 extractor.read_owner_map() | 379 extractor.read_owner_map() |
| 380 return extractor.list_owners(changed_files) | 380 return extractor.list_owners(changed_files) |
| 381 | 381 |
| 382 def _cl_description(self): | 382 def _cl_description(self, directory_owners): |
| 383 description = self.check_run(['git', 'log', '-1', '--format=%B']) | 383 description = self.check_run(['git', 'log', '-1', '--format=%B']) |
| 384 build_link = current_build_link(self.host) | 384 build_link = current_build_link(self.host) |
| 385 if build_link: | 385 if build_link: |
| 386 description += 'Build: %s\n\n' % build_link | 386 description += 'Build: %s\n\n' % build_link |
| 387 |
| 388 if directory_owners: |
| 389 description += self._format_directory_owners(directory_owners) + '\n
\n' |
| 387 description += 'TBR=qyearsley@chromium.org\n' | 390 description += 'TBR=qyearsley@chromium.org\n' |
| 391 |
| 388 # Move any NOEXPORT tag to the end of the description. | 392 # Move any NOEXPORT tag to the end of the description. |
| 389 description = description.replace('NOEXPORT=true', '') | 393 description = description.replace('NOEXPORT=true', '') |
| 390 description = description.replace('\n\n\n\n', '\n\n') | 394 description = description.replace('\n\n\n\n', '\n\n') |
| 391 description += 'NOEXPORT=true' | 395 description += 'NOEXPORT=true' |
| 392 return description | 396 return description |
| 393 | 397 |
| 398 @staticmethod |
| 399 def _format_directory_owners(directory_owners): |
| 400 message_lines = ['Directory owners for changes in this CL:'] |
| 401 for owner, directories in sorted(directory_owners.items()): |
| 402 message_lines.append(owner + ':') |
| 403 message_lines.extend([' ' + d for d in directories]) |
| 404 return '\n'.join(message_lines) |
| 405 |
| 394 def fetch_new_expectations_and_baselines(self): | 406 def fetch_new_expectations_and_baselines(self): |
| 395 """Adds new expectations and downloads baselines based on try job result
s, then commits and uploads the change.""" | 407 """Adds new expectations and downloads baselines based on try job result
s, then commits and uploads the change.""" |
| 396 _log.info('Adding test expectations lines to LayoutTests/TestExpectation
s.') | 408 _log.info('Adding test expectations lines to LayoutTests/TestExpectation
s.') |
| 397 expectation_updater = WPTExpectationsUpdater(self.host) | 409 expectation_updater = WPTExpectationsUpdater(self.host) |
| 398 expectation_updater.run(args=[]) | 410 expectation_updater.run(args=[]) |
| 399 message = 'Update test expectations and baselines.' | 411 message = 'Update test expectations and baselines.' |
| 400 self.check_run(['git', 'commit', '-a', '-m', message]) | 412 self.check_run(['git', 'commit', '-a', '-m', message]) |
| 401 self.git_cl.run(['upload', '-m', message, '--rietveld']) | 413 self.git_cl.run(['upload', '-m', message, '--rietveld']) |
| 402 | 414 |
| 403 def update_all_test_expectations_files(self, deleted_tests, renamed_tests): | 415 def update_all_test_expectations_files(self, deleted_tests, renamed_tests): |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 """Returns a dict mapping source to dest name for layout tests that have
been renamed.""" | 455 """Returns a dict mapping source to dest name for layout tests that have
been renamed.""" |
| 444 out = self.check_run(['git', 'diff', 'origin/master', '-M100%', '--diff-
filter=R', '--name-status']) | 456 out = self.check_run(['git', 'diff', 'origin/master', '-M100%', '--diff-
filter=R', '--name-status']) |
| 445 renamed_tests = {} | 457 renamed_tests = {} |
| 446 for line in out.splitlines(): | 458 for line in out.splitlines(): |
| 447 _, source_path, dest_path = line.split() | 459 _, source_path, dest_path = line.split() |
| 448 source_test = self.finder.layout_test_name(source_path) | 460 source_test = self.finder.layout_test_name(source_path) |
| 449 dest_test = self.finder.layout_test_name(dest_path) | 461 dest_test = self.finder.layout_test_name(dest_path) |
| 450 if source_test and dest_test: | 462 if source_test and dest_test: |
| 451 renamed_tests[source_test] = dest_test | 463 renamed_tests[source_test] = dest_test |
| 452 return renamed_tests | 464 return renamed_tests |
| OLD | NEW |