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

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

Issue 2439153002: Script for exporting WPT (Closed)
Patch Set: Address most of CL feedback 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/'
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):
20 cr_commits = self.cr_commits_since(sha)
21 return filter(self.has_changes_in_wpt, cr_commits)
22
23 def has_changes_in_wpt(self, sha):
24 """Returns if a Chromium sha has changed files in
25 LayoutTests/imported/wpt unless they're expectations
26 """
27 assert sha
28
29 files = self.host.executive.run_command([
30 'git', 'diff-tree', '--no-commit-id',
31 '--name-only', '-r', sha
32 ]).splitlines()
33
34 return any([f.startswith(CR_WPT_DIR) and '-expected' not in f for f in f iles])
35
36 def cr_commits_since(self, sha):
37 return self.host.executive.run_command([
38 'git', 'rev-list', '--reverse', '{}..HEAD'.format(sha)
39 ]).splitlines()
40
41 def subject(self, sha):
42 return self.host.executive.run_command([
43 'git', 'show', '--format=%s', '--no-patch', sha
44 ])
45
46 def commit_position(self, sha):
47 return self.host.executive.run_command([
48 'git', 'footers', '--position', sha
49 ])
50
51 def message(self, sha):
52 """This returns both the subject and body of a given revision."""
53 return self.host.executive.run_command([
54 'git', 'show', '--format=%B', '--no-patch', sha
55 ])
56
57 def format_patch(self, sha):
58 """Get patch but only for files in LayoutTests/imported/wpt"""
59 return self.host.executive.run_command([
60 'git', 'format-patch', '-1', '--stdout',
61 sha, self.absolute_chromium_wpt_dir()
62 ])
63
64 @memoized
65 def absolute_chromium_wpt_dir(self):
66 finder = WebKitFinder(self.host.filesystem)
67 return finder.path_from_webkit_base('LayoutTests', 'imported', 'wpt')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698