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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/deps_updater.py

Issue 2432883003: Update all non-generic test expectations files for removed tests when updating w3c tests. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/w3c/deps_updater_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 attempt to 7 If this script is given the argument --auto-update, it will also attempt to
8 upload a CL, triggery try jobs, and make any changes that are required for 8 upload a CL, triggery try jobs, and make any changes that are required for
9 new failing tests before committing. 9 new failing tests before committing.
10 """ 10 """
11 11
12 import argparse 12 import argparse
13 import json 13 import json
14 14
15 from webkitpy.common.net.git_cl import GitCL 15 from webkitpy.common.net.git_cl import GitCL
16 from webkitpy.common.webkit_finder import WebKitFinder 16 from webkitpy.common.webkit_finder import WebKitFinder
17 from webkitpy.layout_tests.models.test_expectations import TestExpectations 17 from webkitpy.layout_tests.models.test_expectations import TestExpectations, Tes tExpectationParser
18 18
19 # Import destination directories (under LayoutTests/imported/). 19 # Import destination directories (under LayoutTests/imported/).
20 WPT_DEST_NAME = 'wpt' 20 WPT_DEST_NAME = 'wpt'
21 CSS_DEST_NAME = 'csswg-test' 21 CSS_DEST_NAME = 'csswg-test'
22 22
23 # Our mirrors of the official w3c repos, which we pull from. 23 # Our mirrors of the official w3c repos, which we pull from.
24 WPT_REPO_URL = 'https://chromium.googlesource.com/external/w3c/web-platform-test s.git' 24 WPT_REPO_URL = 'https://chromium.googlesource.com/external/w3c/web-platform-test s.git'
25 CSS_REPO_URL = 'https://chromium.googlesource.com/external/w3c/csswg-test.git' 25 CSS_REPO_URL = 'https://chromium.googlesource.com/external/w3c/csswg-test.git'
26 26
27 POLL_DELAY_SECONDS = 900 27 POLL_DELAY_SECONDS = 900
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 for subpath in previous_baselines: 189 for subpath in previous_baselines:
190 full_path = self.fs.join(dest_path, subpath) 190 full_path = self.fs.join(dest_path, subpath)
191 if self.fs.glob(full_path.replace('-expected.txt', '*')) == [full_pa th]: 191 if self.fs.glob(full_path.replace('-expected.txt', '*')) == [full_pa th]:
192 self.fs.remove(full_path) 192 self.fs.remove(full_path)
193 193
194 if not keep_w3c_repos_around: 194 if not keep_w3c_repos_around:
195 self.print_('## Deleting temp repo directory %s.' % temp_repo_path) 195 self.print_('## Deleting temp repo directory %s.' % temp_repo_path)
196 self.rmtree(temp_repo_path) 196 self.rmtree(temp_repo_path)
197 197
198 self.print_('## Updating TestExpectations for any removed or renamed tes ts.') 198 self.print_('## Updating TestExpectations for any removed or renamed tes ts.')
199 self.update_test_expectations(self._list_deleted_tests(), self._list_ren amed_tests()) 199 self.update_all_test_expectations_files(self._list_deleted_tests(), self ._list_renamed_tests())
200 200
201 return '%s@%s' % (dest_dir_name, master_commitish) 201 return '%s@%s' % (dest_dir_name, master_commitish)
202 202
203 def commit_changes_if_needed(self, chromium_commitish, import_commitish): 203 def commit_changes_if_needed(self, chromium_commitish, import_commitish):
204 if self.run(['git', 'diff', '--quiet', 'HEAD'], exit_on_failure=False)[0 ]: 204 if self.run(['git', 'diff', '--quiet', 'HEAD'], exit_on_failure=False)[0 ]:
205 self.print_('## Committing changes.') 205 self.print_('## Committing changes.')
206 commit_msg = ('Import %s\n' 206 commit_msg = ('Import %s\n'
207 '\n' 207 '\n'
208 'Using update-w3c-deps in Chromium %s.\n' 208 'Using update-w3c-deps in Chromium %s.\n'
209 % (import_commitish, chromium_commitish)) 209 % (import_commitish, chromium_commitish))
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 385
386 def fetch_new_expectations_and_baselines(self): 386 def fetch_new_expectations_and_baselines(self):
387 """Adds new expectations and downloads baselines based on try job result s, then commits and uploads the change.""" 387 """Adds new expectations and downloads baselines based on try job result s, then commits and uploads the change."""
388 self.print_('## Adding test expectations lines to LayoutTests/TestExpect ations.') 388 self.print_('## Adding test expectations lines to LayoutTests/TestExpect ations.')
389 script_path = self.path_from_webkit_base('Tools', 'Scripts', 'update-w3c -test-expectations') 389 script_path = self.path_from_webkit_base('Tools', 'Scripts', 'update-w3c -test-expectations')
390 self.run([self.host.executable, script_path, '--verbose']) 390 self.run([self.host.executable, script_path, '--verbose'])
391 message = 'Modify TestExpectations or download new baselines for tests.' 391 message = 'Modify TestExpectations or download new baselines for tests.'
392 self.check_run(['git', 'commit', '-a', '-m', message]) 392 self.check_run(['git', 'commit', '-a', '-m', message])
393 self.git_cl.run(['upload', '-m', message, '--rietveld']) 393 self.git_cl.run(['upload', '-m', message, '--rietveld'])
394 394
395 def update_test_expectations(self, deleted_tests, renamed_tests): 395 def update_all_test_expectations_files(self, deleted_tests, renamed_tests):
396 """Updates the TestExpectations file entries for tests that have been de leted or renamed.""" 396 """Updates all test expectations files for tests that have been deleted or renamed."""
397 port = self.host.port_factory.get() 397 port = self.host.port_factory.get()
398 test_expectations = TestExpectations(port, include_overrides=False) 398 for path, file_contents in port.all_expectations_dict().iteritems():
399 # Tests for which files don't exist aren't stored in TestExpectationsMod el, 399
400 # so methods like TestExpectations.remove_expectation_line don't work; i nstead 400 parser = TestExpectationParser(port, all_tests=None, is_lint_mode=Fa lse)
401 # we can run through the TestExpectationLine objects that were parsed. 401 expectation_lines = parser.parse(path, file_contents)
402 self._update_single_test_expectations_file(path, expectation_lines, deleted_tests, renamed_tests)
403
404 def _update_single_test_expectations_file(self, path, expectation_lines, del eted_tests, renamed_tests):
405 """Updates single test expectations file."""
402 # FIXME: This won't work for removed or renamed directories with test ex pectations 406 # FIXME: This won't work for removed or renamed directories with test ex pectations
403 # that are directories rather than individual tests. 407 # that are directories rather than individual tests.
404 new_lines = [] 408 new_lines = []
405 changed_lines = [] 409 changed_lines = []
406 for expectation_line in test_expectations.expectations(): 410 for expectation_line in expectation_lines:
407 if expectation_line.name in deleted_tests: 411 if expectation_line.name in deleted_tests:
408 continue 412 continue
409 if expectation_line.name in renamed_tests: 413 if expectation_line.name in renamed_tests:
410 expectation_line.name = renamed_tests[expectation_line.name] 414 expectation_line.name = renamed_tests[expectation_line.name]
411 # Upon parsing the file, a "path does not exist" warning is expe cted 415 # Upon parsing the file, a "path does not exist" warning is expe cted
412 # to be there for tests that have been renamed, and if there are warnings, 416 # to be there for tests that have been renamed, and if there are warnings,
413 # then the original string is used. If the warnings are reset, t hen the 417 # then the original string is used. If the warnings are reset, t hen the
414 # expectation line is re-serialized when output. 418 # expectation line is re-serialized when output.
415 expectation_line.warnings = [] 419 expectation_line.warnings = []
416 changed_lines.append(expectation_line) 420 changed_lines.append(expectation_line)
417 new_lines.append(expectation_line) 421 new_lines.append(expectation_line)
418 self.host.filesystem.write_text_file( 422 new_file_contents = TestExpectations.list_to_string(new_lines, reconstit ute_only_these=changed_lines)
419 port.path_to_generic_test_expectations_file(), 423 self.host.filesystem.write_text_file(path, new_file_contents)
420 TestExpectations.list_to_string(new_lines, reconstitute_only_these=c hanged_lines))
421 424
422 def _list_deleted_tests(self): 425 def _list_deleted_tests(self):
423 """Returns a list of layout tests that have been deleted.""" 426 """Returns a list of layout tests that have been deleted."""
424 out = self.check_run(['git', 'diff', 'origin/master', '--diff-filter=D', '--name-only']) 427 out = self.check_run(['git', 'diff', 'origin/master', '--diff-filter=D', '--name-only'])
425 deleted_tests = [] 428 deleted_tests = []
426 for line in out.splitlines(): 429 for line in out.splitlines():
427 test = self.finder.layout_test_name(line) 430 test = self.finder.layout_test_name(line)
428 if test: 431 if test:
429 deleted_tests.append(test) 432 deleted_tests.append(test)
430 return deleted_tests 433 return deleted_tests
431 434
432 def _list_renamed_tests(self): 435 def _list_renamed_tests(self):
433 """Returns a dict mapping source to dest name for layout tests that have been renamed.""" 436 """Returns a dict mapping source to dest name for layout tests that have been renamed."""
434 out = self.check_run(['git', 'diff', 'origin/master', '--diff-filter=R', '--name-status']) 437 out = self.check_run(['git', 'diff', 'origin/master', '--diff-filter=R', '--name-status'])
435 renamed_tests = {} 438 renamed_tests = {}
436 for line in out.splitlines(): 439 for line in out.splitlines():
437 _, source_path, dest_path = line.split() 440 _, source_path, dest_path = line.split()
438 source_test = self.finder.layout_test_name(source_path) 441 source_test = self.finder.layout_test_name(source_path)
439 dest_test = self.finder.layout_test_name(dest_path) 442 dest_test = self.finder.layout_test_name(dest_path)
440 if source_test and dest_test: 443 if source_test and dest_test:
441 renamed_tests[source_test] = dest_test 444 renamed_tests[source_test] = dest_test
442 return renamed_tests 445 return renamed_tests
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/w3c/deps_updater_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698