| OLD | NEW |
| 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 Loading... |
| 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 against origin/master. |
| 113 |
| 114 Args: |
| 115 patch: The patch to test against. |
| 116 |
| 117 Returns: |
| 118 A string containing the diff the patch produced. |
| 119 """ |
| 120 self.clean() |
| 121 |
| 122 # Remove Chromium WPT directory prefix. |
| 123 patch = patch.replace(CHROMIUM_WPT_DIR, '') |
| 124 |
| 125 try: |
| 126 self.run(['git', 'apply', '-'], input=patch) |
| 127 self.run(['git', 'add', '.']) |
| 128 output = self.run(['git', 'diff', 'origin/master']) |
| 129 except ScriptError as error: |
| 130 _log.error('Error while applying patch: %s', error) |
| 131 output = '' |
| 132 |
| 133 self.clean() |
| 134 return output |
| 135 |
| 110 def commits_behind_master(self, commit): | 136 def commits_behind_master(self, commit): |
| 111 """Returns the number of commits after the given commit on origin/master
. | 137 """Returns the number of commits after the given commit on origin/master
. |
| 112 | 138 |
| 113 This doesn't include the given commit, and this assumes that the given | 139 This doesn't include the given commit, and this assumes that the given |
| 114 commit is on the the master branch. | 140 commit is on the the master branch. |
| 115 """ | 141 """ |
| 116 return len(self.run([ | 142 return len(self.run([ |
| 117 'git', 'rev-list', '{}..origin/master'.format(commit) | 143 'git', 'rev-list', '{}..origin/master'.format(commit) |
| 118 ]).splitlines()) | 144 ]).splitlines()) |
| OLD | NEW |