Chromium Code Reviews| 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.common.system.executive import ScriptError |
| 10 from webkitpy.w3c.chromium_commit import ChromiumCommit | 10 from webkitpy.w3c.chromium_commit import ChromiumCommit |
| 11 from webkitpy.w3c.common import WPT_GH_REPO_URL, CHROMIUM_WPT_DIR | 11 from webkitpy.w3c.common import WPT_GH_REPO_URL_TEMPLATE, CHROMIUM_WPT_DIR |
| 12 | 12 |
| 13 | 13 |
| 14 _log = logging.getLogger(__name__) | 14 _log = logging.getLogger(__name__) |
| 15 | 15 |
| 16 | 16 |
| 17 class LocalWPT(object): | 17 class LocalWPT(object): |
| 18 | 18 |
| 19 def __init__(self, host, path='/tmp/wpt'): | 19 def __init__(self, host, gh_token, path='/tmp/wpt'): |
|
qyearsley
2017/02/28 18:30:04
LocalWPT is used in test_importer, which I believe
jeffcarp
2017/02/28 18:53:38
sgtm
| |
| 20 """ | 20 """ |
| 21 Args: | 21 Args: |
| 22 host: A Host object. | 22 host: A Host object. |
| 23 path: Optional, the path to the web-platform-tests repo. | 23 path: Optional, the path to the web-platform-tests repo. |
| 24 If this directory already exists, it is assumed that the | 24 If this directory already exists, it is assumed that the |
| 25 web-platform-tests repo is already checked out at this path. | 25 web-platform-tests repo is already checked out at this path. |
| 26 """ | 26 """ |
| 27 self.host = host | 27 self.host = host |
| 28 self.path = path | 28 self.path = path |
| 29 self.gh_token = gh_token | |
| 29 self.branch_name = 'chromium-export-try' | 30 self.branch_name = 'chromium-export-try' |
| 30 | 31 |
| 31 def fetch(self): | 32 def fetch(self): |
| 32 if self.host.filesystem.exists(self.path): | 33 if self.host.filesystem.exists(self.path): |
| 33 _log.info('WPT checkout exists at %s, fetching latest', self.path) | 34 _log.info('WPT checkout exists at %s, fetching latest', self.path) |
| 34 self.run(['git', 'fetch', 'origin']) | 35 self.run(['git', 'fetch', 'origin']) |
| 35 self.run(['git', 'checkout', 'origin/master']) | 36 self.run(['git', 'checkout', 'origin/master']) |
| 36 else: | 37 else: |
| 37 _log.info('Cloning %s into %s', WPT_GH_REPO_URL, self.path) | 38 _log.info('Cloning GitHub w3c/web-platform-tests into %s', self.path ) |
| 38 self.host.executive.run_command(['git', 'clone', WPT_GH_REPO_URL, se lf.path]) | 39 remote_url = WPT_GH_REPO_URL_TEMPLATE.format(self.gh_token) |
| 40 self.host.executive.run_command(['git', 'clone', '--depth=10', remot e_url, self.path]) | |
|
qyearsley
2017/02/28 18:30:04
Why depth = 10? What if the test that we want to u
jeffcarp
2017/02/28 18:53:38
--depth in this case refers to how many commits ba
qyearsley
2017/02/28 18:58:04
Ah, I see, that's what depth means :-)
Maybe anot
| |
| 39 | 41 |
| 40 def run(self, command, **kwargs): | 42 def run(self, command, **kwargs): |
| 41 """Runs a command in the local WPT directory.""" | 43 """Runs a command in the local WPT directory.""" |
| 42 return self.host.executive.run_command(command, cwd=self.path, **kwargs) | 44 return self.host.executive.run_command(command, cwd=self.path, **kwargs) |
| 43 | 45 |
| 44 def most_recent_chromium_commit(self): | 46 def most_recent_chromium_commit(self): |
| 45 """Finds the most recent commit in WPT with a Chromium commit position." "" | 47 """Finds the most recent commit in WPT with a Chromium commit position." "" |
| 46 wpt_commit_hash = self.run(['git', 'rev-list', 'HEAD', '-n', '1', '--gre p=Cr-Commit-Position']) | 48 wpt_commit_hash = self.run(['git', 'rev-list', 'HEAD', '-n', '1', '--gre p=Cr-Commit-Position']) |
| 47 if not wpt_commit_hash: | 49 if not wpt_commit_hash: |
| 48 return None, None | 50 return None, None |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 | 127 |
| 126 def commits_behind_master(self, commit): | 128 def commits_behind_master(self, commit): |
| 127 """Returns the number of commits after the given commit on origin/master . | 129 """Returns the number of commits after the given commit on origin/master . |
| 128 | 130 |
| 129 This doesn't include the given commit, and this assumes that the given | 131 This doesn't include the given commit, and this assumes that the given |
| 130 commit is on the the master branch. | 132 commit is on the the master branch. |
| 131 """ | 133 """ |
| 132 return len(self.run([ | 134 return len(self.run([ |
| 133 'git', 'rev-list', '{}..origin/master'.format(commit) | 135 'git', 'rev-list', '{}..origin/master'.format(commit) |
| 134 ]).splitlines()) | 136 ]).splitlines()) |
| OLD | NEW |