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 | 11 |
| 12 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' |
| 13 WPT_TMP_DIR = '/tmp/wpt' | 13 WPT_TMP_DIR = '/tmp/wpt' |
| 14 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/' | 14 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/' |
| 15 | 15 |
| 16 _log = logging.getLogger(__name__) | 16 _log = logging.getLogger(__name__) |
| 17 | 17 |
| 18 | 18 |
| 19 class LocalWPT(object): | 19 class LocalWPT(object): |
| 20 | 20 |
| 21 def __init__(self, host, path=WPT_TMP_DIR, no_fetch=False, use_github=False) : | 21 def __init__(self, host, path=WPT_TMP_DIR, no_fetch=False, use_github=False) : |
| 22 """ | 22 """ |
| 23 Args: | 23 Args: |
| 24 host: A Host object. | 24 host: A Host object. |
| 25 path: Optional, the directory where LocalWPT will check out web-plat form-tests. | 25 path: Optional, the directory where LocalWPT will check out web-plat form-tests. |
| 26 no_fetch: Optional, passing true will skip updating the local WPT. | 26 no_fetch: Optional, passing true will skip updating the local WPT. |
| 27 Intended for use only in development after fetching once. | 27 Intended for use only in development after fetching once. |
| 28 use_github: Optional, passing true will check if the GitHub remote i s enabled | 28 use_github: Optional, passing true will check if the GitHub remote i s enabled |
|
qyearsley
2017/01/10 20:42:46
Is this argument now unused?
| |
| 29 (necessary for later pull request steps). | 29 (necessary for later pull request steps). |
| 30 """ | 30 """ |
| 31 self.host = host | 31 self.host = host |
| 32 self.path = path | 32 self.path = path |
| 33 self.branch_name = 'chromium-export-try' | 33 self.branch_name = 'chromium-export-try' |
| 34 | 34 |
| 35 if no_fetch: | 35 if no_fetch: |
| 36 _log.info('Skipping remote WPT fetch') | 36 _log.info('Skipping remote WPT fetch') |
| 37 return | 37 return |
| 38 | 38 |
| 39 if self.host.filesystem.exists(self.path): | 39 if self.host.filesystem.exists(self.path): |
| 40 _log.info('WPT checkout exists at %s, fetching latest', self.path) | 40 _log.info('WPT checkout exists at %s, fetching latest', self.path) |
| 41 self.run(['git', 'fetch', '--all']) | 41 self.run(['git', 'fetch', '--all']) |
| 42 self.run(['git', 'checkout', 'origin/master']) | 42 self.run(['git', 'checkout', 'origin/master']) |
| 43 else: | 43 else: |
| 44 _log.info('Cloning %s into %s', WPT_REPO_URL, self.path) | 44 _log.info('Cloning %s into %s', WPT_REPO_URL, self.path) |
| 45 self.host.executive.run_command(['git', 'clone', WPT_REPO_URL, self. path]) | 45 self.host.executive.run_command(['git', 'clone', WPT_REPO_URL, self. path]) |
| 46 | 46 |
| 47 if use_github and 'github' not in self.run(['git', 'remote']): | 47 if 'github' not in self.run(['git', 'remote']): |
| 48 raise Exception('Need to set up remote "github"') | 48 self.run(['git', 'remote', 'add', 'github', 'git@github.com:w3c/web- platform-tests.git']) |
| 49 | 49 |
| 50 def run(self, command, **kwargs): | 50 def run(self, command, **kwargs): |
| 51 """Runs a command in the local WPT directory.""" | 51 """Runs a command in the local WPT directory.""" |
| 52 return self.host.executive.run_command(command, cwd=self.path, **kwargs) | 52 return self.host.executive.run_command(command, cwd=self.path, **kwargs) |
| 53 | 53 |
| 54 def most_recent_chromium_commit(self): | 54 def most_recent_chromium_commit(self): |
| 55 """Finds the most recent commit in WPT with a Chromium commit position." "" | 55 """Finds the most recent commit in WPT with a Chromium commit position." "" |
| 56 sha = self.run(['git', 'rev-list', 'HEAD', '-n', '1', '--grep=Cr-Commit- Position']) | 56 sha = self.run(['git', 'rev-list', 'HEAD', '-n', '1', '--grep=Cr-Commit- Position']) |
| 57 if not sha: | 57 if not sha: |
| 58 return None, None | 58 return None, None |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 | 131 |
| 132 def commits_behind_master(self, commit): | 132 def commits_behind_master(self, commit): |
| 133 """Returns the number of commits after the given commit on origin/master . | 133 """Returns the number of commits after the given commit on origin/master . |
| 134 | 134 |
| 135 This doesn't include the given commit, and this assumes that the given | 135 This doesn't include the given commit, and this assumes that the given |
| 136 commit is on the the master branch. | 136 commit is on the the master branch. |
| 137 """ | 137 """ |
| 138 return len(self.run([ | 138 return len(self.run([ |
| 139 'git', 'rev-list', '{}..origin/master'.format(commit) | 139 'git', 'rev-list', '{}..origin/master'.format(commit) |
| 140 ]).splitlines()) | 140 ]).splitlines()) |
| OLD | NEW |