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/chromium_wpt.py

Issue 2439153002: Script for exporting WPT (Closed)
Patch Set: Filter out WPT import commits Created 4 years, 1 month 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
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 CR_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/'
qyearsley 2016/11/04 17:40:32 Just so it's explicit and clear for future readers
qyearsley 2016/11/04 17:42:04 Scratch out the word "avoid" in this comment...
6
7 from webkitpy.common.memoized import memoized
8 from webkitpy.common.webkit_finder import WebKitFinder
9
10
11 class ChromiumWPT(object):
12 """This is a utility class for interacting with the Chromium git tree
13 for use cases relating to the Web Platform Tests.
14 """
15
16 def __init__(self, host):
17 self.host = host
18
19 def exportable_commits_since(self, sha):
qyearsley 2016/11/04 17:40:32 `chromium_commit` might be clearer than `sha`, sin
20 cr_commits = self.cr_commits_since(sha)
21
22 def is_exportable(sha):
23 return self.has_changes_in_wpt(sha) and not self.is_import_commit(sh a)
24
25 return filter(is_exportable, cr_commits)
26
27 def is_import_commit(self, sha):
28 return self.subject(sha).startswith('Import wpt@')
29
30 def has_changes_in_wpt(self, sha):
31 """Detects if a Chromium revision has modified files in the WPT director y."""
32
33 assert sha
qyearsley 2016/11/04 17:40:32 Just a random note: I think that this use of asser
34 files = self.host.executive.run_command([
35 'git', 'diff-tree', '--no-commit-id',
36 '--name-only', '-r', sha
37 ]).splitlines()
38
39 # TODO(jeffcarp): Use DepsUpdater.is_baseline
40 return any([f.startswith(CR_WPT_DIR) and '-expected' not in f for f in f iles])
qyearsley 2016/11/04 17:40:32 Python any() and all() can take any iterable inclu
41
42 def cr_commits_since(self, sha):
43 return self.host.executive.run_command([
44 'git', 'rev-list', '--reverse', '{}..HEAD'.format(sha)
45 ]).splitlines()
46
47 def subject(self, sha):
48 return self.host.executive.run_command([
49 'git', 'show', '--format=%s', '--no-patch', sha
50 ])
51
52 def commit_position(self, sha):
53 return self.host.executive.run_command([
54 'git', 'footers', '--position', sha
55 ])
56
57 def message(self, sha):
58 """This returns both the subject and body of a given revision."""
qyearsley 2016/11/04 17:40:32 Usually docstrings start with just the verb in thi
59 return self.host.executive.run_command([
60 'git', 'show', '--format=%B', '--no-patch', sha
61 ])
62
63 def format_patch(self, sha):
64 """Get patch but only for files in LayoutTests/imported/wpt"""
qyearsley 2016/11/04 17:40:32 Likewise: """Makes a patch with just changes in
65 # TODO(jeffcarp): do not include expectations files
66 return self.host.executive.run_command([
67 'git', 'format-patch', '-1', '--stdout',
68 sha, self.absolute_chromium_wpt_dir()
69 ])
70
71 @memoized
72 def absolute_chromium_wpt_dir(self):
73 finder = WebKitFinder(self.host.filesystem)
74 return finder.path_from_webkit_base('LayoutTests', 'imported', 'wpt')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698