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

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

Issue 2544173002: Skip commits that don't generate a patch + fixes to get export working (Closed)
Patch Set: Merge ChromiumWPT functionality into TestExporter, expose exportable_commits Created 4 years 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 """A utility class for interacting with the Chromium git tree
6 for use cases relating to the Web Platform Tests.
7 """
8
9 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/'
10
11 from webkitpy.common.memoized import memoized
12 from webkitpy.common.webkit_finder import WebKitFinder
13 from webkitpy.w3c.deps_updater import DepsUpdater
14
15
16 class ChromiumWPT(object):
17
18 def __init__(self, host):
19 """
20 Args:
21 host: A Host object.
22 """
23 self.host = host
24
25 def exportable_commits_since(self, commit):
26 """Returns SHAs of exportable commits since `commit` in chronological or der.
27
28 Args:
29 commit: The SHA of the Chromium commit from which this method will l ook.
30 """
31 toplevel = self.host.executive.run_command([
32 'git', 'rev-parse', '--show-toplevel'
33 ]).strip()
34
35 commits = self.host.executive.run_command([
36 'git', 'rev-list', '{}..HEAD'.format(commit), '--reverse',
37 '--', toplevel + '/' + CHROMIUM_WPT_DIR
38 ]).splitlines()
39
40 # TODO(jeffcarp): allow this logic to be shared
41 def is_exportable(chromium_commit):
42 message = self.message(chromium_commit)
43 return (
44 'NOEXPORT=true' not in message
45 and not message.startswith('Import ')
46 # TODO(jeffcarp): change this to allow any commit with
47 # any non-expectation changes to be exportable
48 and not self._has_expectations(chromium_commit)
49 )
50
51 return filter(is_exportable, commits)
52
53 def _has_expectations(self, chromium_commit):
54 files = self.host.executive.run_command([
55 'git', 'diff-tree', '--no-commit-id',
56 '--name-only', '-r', chromium_commit
57 ]).splitlines()
58
59 return any(DepsUpdater.is_baseline(f) for f in files)
60
61 def subject(self, chromium_commit):
62 return self.host.executive.run_command([
63 'git', 'show', '--format=%s', '--no-patch', chromium_commit
64 ])
65
66 def commit_position(self, chromium_commit):
67 return self.host.executive.run_command([
68 'git', 'footers', '--position', chromium_commit
69 ])
70
71 def message(self, chromium_commit):
72 """Returns a string with a commit's subject and body."""
73 return self.host.executive.run_command([
74 'git', 'show', '--format=%B', '--no-patch', chromium_commit
75 ])
76
77 def format_patch(self, chromium_commit):
78 """Makes a patch with just changes in files in the WPT for a given commi t."""
79 # TODO(jeffcarp): do not include expectations files
80 return self.host.executive.run_command([
81 'git', 'format-patch', '-1', '--stdout',
82 chromium_commit, self.absolute_chromium_wpt_dir()
83 ])
84
85 @memoized
86 def absolute_chromium_wpt_dir(self):
87 finder = WebKitFinder(self.host.filesystem)
88 return finder.path_from_webkit_base('LayoutTests', 'imported', 'wpt')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698