| 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 description = self._cl_description(directory_owners) | 370 description = self._cl_description(directory_owners) |
| 371 self.git_cl.run([ | 371 self.git_cl.run([ |
| 372 'upload', | 372 'upload', |
| 373 '-f', | 373 '-f', |
| 374 '--gerrit', | 374 '--gerrit', |
| 375 '-m', | 375 '-m', |
| 376 description, | 376 description, |
| 377 ] + ['--cc=' + email_address for email_address in directory_owners]) | 377 ] + ['--cc=' + email_address for email_address in directory_owners]) |
| 378 | 378 |
| 379 def get_directory_owners(self): | 379 def get_directory_owners(self): |
| 380 """Returns a list of email addresses of owners of changed tests.""" | 380 """Returns a mapping of email addresses to owners of changed tests.""" |
| 381 _log.info('Gathering directory owners emails to CC.') | 381 _log.info('Gathering directory owners emails to CC.') |
| 382 changed_files = self.host.git().changed_files() | 382 changed_files = self.host.git().changed_files() |
| 383 extractor = DirectoryOwnersExtractor(self.fs) | 383 extractor = DirectoryOwnersExtractor(self.fs) |
| 384 extractor.read_owner_map() | 384 extractor.read_owner_map() |
| 385 return extractor.list_owners(changed_files) | 385 return extractor.list_owners(changed_files) |
| 386 | 386 |
| 387 def _cl_description(self, directory_owners): | 387 def _cl_description(self, directory_owners): |
| 388 """Returns a CL description string. |
| 389 |
| 390 Args: |
| 391 directory_owners: A dict of tuples of owner names to lists of direct
ories. |
| 392 """ |
| 388 description = self.check_run(['git', 'log', '-1', '--format=%B']) | 393 description = self.check_run(['git', 'log', '-1', '--format=%B']) |
| 389 build_link = current_build_link(self.host) | 394 build_link = current_build_link(self.host) |
| 390 if build_link: | 395 if build_link: |
| 391 description += 'Build: %s\n\n' % build_link | 396 description += 'Build: %s\n\n' % build_link |
| 392 | 397 |
| 393 if directory_owners: | 398 if directory_owners: |
| 394 description += self._format_directory_owners(directory_owners) + '\n
\n' | 399 description += self._format_directory_owners(directory_owners) + '\n
\n' |
| 395 description += 'TBR=qyearsley@chromium.org\n' | 400 description += 'TBR=qyearsley@chromium.org\n' |
| 396 | 401 |
| 397 # Move any NOEXPORT tag to the end of the description. | 402 # Move any NOEXPORT tag to the end of the description. |
| 398 description = description.replace('NOEXPORT=true', '') | 403 description = description.replace('NOEXPORT=true', '') |
| 399 description = description.replace('\n\n\n\n', '\n\n') | 404 description = description.replace('\n\n\n\n', '\n\n') |
| 400 description += 'NOEXPORT=true' | 405 description += 'NOEXPORT=true' |
| 401 return description | 406 return description |
| 402 | 407 |
| 403 @staticmethod | 408 @staticmethod |
| 404 def _format_directory_owners(directory_owners): | 409 def _format_directory_owners(directory_owners): |
| 405 message_lines = ['Directory owners for changes in this CL:'] | 410 message_lines = ['Directory owners for changes in this CL:'] |
| 406 for owner, directories in sorted(directory_owners.items()): | 411 for owner_tuple, directories in sorted(directory_owners.items()): |
| 407 message_lines.append(owner + ':') | 412 message_lines.append(', '.join(owner_tuple) + ':') |
| 408 message_lines.extend([' ' + d for d in directories]) | 413 message_lines.extend(' ' + d for d in directories) |
| 409 return '\n'.join(message_lines) | 414 return '\n'.join(message_lines) |
| 410 | 415 |
| 411 def fetch_new_expectations_and_baselines(self): | 416 def fetch_new_expectations_and_baselines(self): |
| 412 """Adds new expectations and downloads baselines based on try job result
s, then commits and uploads the change.""" | 417 """Adds new expectations and downloads baselines based on try job result
s, then commits and uploads the change.""" |
| 413 _log.info('Adding test expectations lines to LayoutTests/TestExpectation
s.') | 418 _log.info('Adding test expectations lines to LayoutTests/TestExpectation
s.') |
| 414 expectation_updater = WPTExpectationsUpdater(self.host) | 419 expectation_updater = WPTExpectationsUpdater(self.host) |
| 415 expectation_updater.run(args=[]) | 420 expectation_updater.run(args=[]) |
| 416 message = 'Update test expectations and baselines.' | 421 message = 'Update test expectations and baselines.' |
| 417 self.check_run(['git', 'commit', '-a', '-m', message]) | 422 self.check_run(['git', 'commit', '-a', '-m', message]) |
| 418 self.git_cl.run(['upload', '-m', message, '--gerrit']) | 423 self.git_cl.run(['upload', '-m', message, '--gerrit']) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 """Returns a dict mapping source to dest name for layout tests that have
been renamed.""" | 465 """Returns a dict mapping source to dest name for layout tests that have
been renamed.""" |
| 461 out = self.check_run(['git', 'diff', 'origin/master', '-M100%', '--diff-
filter=R', '--name-status']) | 466 out = self.check_run(['git', 'diff', 'origin/master', '-M100%', '--diff-
filter=R', '--name-status']) |
| 462 renamed_tests = {} | 467 renamed_tests = {} |
| 463 for line in out.splitlines(): | 468 for line in out.splitlines(): |
| 464 _, source_path, dest_path = line.split() | 469 _, source_path, dest_path = line.split() |
| 465 source_test = self.finder.layout_test_name(source_path) | 470 source_test = self.finder.layout_test_name(source_path) |
| 466 dest_test = self.finder.layout_test_name(dest_path) | 471 dest_test = self.finder.layout_test_name(dest_path) |
| 467 if source_test and dest_test: | 472 if source_test and dest_test: |
| 468 renamed_tests[source_test] = dest_test | 473 renamed_tests[source_test] = dest_test |
| 469 return renamed_tests | 474 return renamed_tests |
| OLD | NEW |