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

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

Issue 2583723002: Use LocalWPT.test_patch when filtering exportable commits (Closed)
Patch Set: Add missing constant 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
1 # Copyright 2016 The Chromium Authors. All rights reserved. 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 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 """A utility class for interacting with a local checkout of the Web Platform Tes ts.""" 5 """A utility class for interacting with a local checkout of the Web Platform Tes ts."""
6 6
7 import logging 7 import logging
8 8
9 from webkitpy.common.system.executive import ScriptError
9 from webkitpy.w3c.chromium_commit import ChromiumCommit 10 from webkitpy.w3c.chromium_commit import ChromiumCommit
10 11
11 WPT_REPO_URL = 'https://chromium.googlesource.com/external/w3c/web-platform-test s.git' 12 WPT_REPO_URL = 'https://chromium.googlesource.com/external/w3c/web-platform-test s.git'
12 WPT_TMP_DIR = '/tmp/wpt' 13 WPT_TMP_DIR = '/tmp/wpt'
13 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/' 14 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/'
14 15
15 _log = logging.getLogger(__name__) 16 _log = logging.getLogger(__name__)
16 17
17 18
18 class LocalWPT(object): 19 class LocalWPT(object):
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 patch = patch.replace(CHROMIUM_WPT_DIR, '') 101 patch = patch.replace(CHROMIUM_WPT_DIR, '')
101 102
102 # TODO(jeffcarp): Use git am -p<n> where n is len(CHROMIUM_WPT_DIR.split (/')) 103 # TODO(jeffcarp): Use git am -p<n> where n is len(CHROMIUM_WPT_DIR.split (/'))
103 # or something not off-by-one. 104 # or something not off-by-one.
104 self.run(['git', 'apply', '-'], input=patch) 105 self.run(['git', 'apply', '-'], input=patch)
105 self.run(['git', 'commit', '-am', message]) 106 self.run(['git', 'commit', '-am', message])
106 self.run(['git', 'push', 'github', branch_name]) 107 self.run(['git', 'push', 'github', branch_name])
107 108
108 return branch_name 109 return branch_name
109 110
111 def test_patch(self, patch):
112 """Returns the expected output of a patch agains origin/master.
qyearsley 2016/12/22 22:04:54 Nit: agains -> against
113
114 Args:
115 patch: The patch to test against.
116
117 Returns:
118 A string containing the diff the patch produced.
qyearsley 2016/12/22 22:04:54 Sometimes I'm confused about the words "diff" and
jeffcarp 2016/12/22 23:14:29 Hm what do you suggest re: diff/patch? That sound
qyearsley 2016/12/22 23:19:53 I was wondering if you could put an example (very
119 """
120 self.clean()
121
122 # Remove Chromium WPT directory prefix.
123 # TODO(jeffcarp): dedupe
qyearsley 2016/12/22 22:04:54 Dedupe what?
jeffcarp 2016/12/22 23:14:29 Oops it was already deduped.
124 patch = patch.replace(CHROMIUM_WPT_DIR, '')
125
126 try:
127 self.run(['git', 'apply', '-'], input=patch)
128 self.run(['git', 'add', '.'])
129 output = self.run(['git', 'diff', 'origin/master'])
130 except ScriptError as error:
131 _log.error('Error while applying patch: %s', error)
132 output = ''
133
134 self.clean()
135 return output
136
110 def commits_behind_master(self, commit): 137 def commits_behind_master(self, commit):
111 """Returns the number of commits after the given commit on origin/master . 138 """Returns the number of commits after the given commit on origin/master .
112 139
113 This doesn't include the given commit, and this assumes that the given 140 This doesn't include the given commit, and this assumes that the given
114 commit is on the the master branch. 141 commit is on the the master branch.
115 """ 142 """
116 return len(self.run([ 143 return len(self.run([
117 'git', 'rev-list', '{}..origin/master'.format(commit) 144 'git', 'rev-list', '{}..origin/master'.format(commit)
118 ]).splitlines()) 145 ]).splitlines())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698