Commit 9422f34b authored by jeffcarp's avatar jeffcarp Committed by Commit bot

[WPT Export] Add "github" remote repo in LocalWPT constructor if it doesn't exist.

BUG=679084
R=qyearsley@chromium.org

Review-Url: https://codereview.chromium.org/2620103002
Cr-Commit-Position: refs/heads/master@{#442729}
parent 17aab3f6
...@@ -11,6 +11,8 @@ from webkitpy.w3c.chromium_commit import ChromiumCommit ...@@ -11,6 +11,8 @@ from webkitpy.w3c.chromium_commit import ChromiumCommit
WPT_REPO_URL = 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git' WPT_REPO_URL = 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git'
WPT_TMP_DIR = '/tmp/wpt' WPT_TMP_DIR = '/tmp/wpt'
WPT_SSH_URL = 'git@github.com:w3c/web-platform-tests.git'
REMOTE_NAME = 'github'
CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/' CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/'
_log = logging.getLogger(__name__) _log = logging.getLogger(__name__)
...@@ -18,15 +20,13 @@ _log = logging.getLogger(__name__) ...@@ -18,15 +20,13 @@ _log = logging.getLogger(__name__)
class LocalWPT(object): class LocalWPT(object):
def __init__(self, host, path=WPT_TMP_DIR, no_fetch=False, use_github=False): def __init__(self, host, path=WPT_TMP_DIR, no_fetch=False):
""" """
Args: Args:
host: A Host object. host: A Host object.
path: Optional, the directory where LocalWPT will check out web-platform-tests. path: Optional, the directory where LocalWPT will check out web-platform-tests.
no_fetch: Optional, passing true will skip updating the local WPT. no_fetch: Optional, passing true will skip updating the local WPT.
Intended for use only in development after fetching once. Intended for use only in development after fetching once.
use_github: Optional, passing true will check if the GitHub remote is enabled
(necessary for later pull request steps).
""" """
self.host = host self.host = host
self.path = path self.path = path
...@@ -44,8 +44,8 @@ class LocalWPT(object): ...@@ -44,8 +44,8 @@ class LocalWPT(object):
_log.info('Cloning %s into %s', WPT_REPO_URL, self.path) _log.info('Cloning %s into %s', WPT_REPO_URL, self.path)
self.host.executive.run_command(['git', 'clone', WPT_REPO_URL, self.path]) self.host.executive.run_command(['git', 'clone', WPT_REPO_URL, self.path])
if use_github and 'github' not in self.run(['git', 'remote']): if REMOTE_NAME not in self.run(['git', 'remote']):
raise Exception('Need to set up remote "github"') self.run(['git', 'remote', 'add', REMOTE_NAME, WPT_SSH_URL])
def run(self, command, **kwargs): def run(self, command, **kwargs):
"""Runs a command in the local WPT directory.""" """Runs a command in the local WPT directory."""
...@@ -100,7 +100,7 @@ class LocalWPT(object): ...@@ -100,7 +100,7 @@ class LocalWPT(object):
# or something not off-by-one. # or something not off-by-one.
self.run(['git', 'apply', '-'], input=patch) self.run(['git', 'apply', '-'], input=patch)
self.run(['git', 'commit', '--author', author, '-am', message]) self.run(['git', 'commit', '--author', author, '-am', message])
self.run(['git', 'push', 'github', self.branch_name]) self.run(['git', 'push', REMOTE_NAME, self.branch_name])
return self.branch_name return self.branch_name
......
...@@ -12,7 +12,7 @@ from webkitpy.w3c.local_wpt import LocalWPT ...@@ -12,7 +12,7 @@ from webkitpy.w3c.local_wpt import LocalWPT
class LocalWPTTest(unittest.TestCase): class LocalWPTTest(unittest.TestCase):
def test_fetches_if_wpt_exists(self): def test_constructor_fetches_if_wpt_dir_exists(self):
host = MockHost() host = MockHost()
host.filesystem = MockFileSystem(files={ host.filesystem = MockFileSystem(files={
'/tmp/wpt': '' '/tmp/wpt': ''
...@@ -20,20 +20,22 @@ class LocalWPTTest(unittest.TestCase): ...@@ -20,20 +20,22 @@ class LocalWPTTest(unittest.TestCase):
LocalWPT(host) LocalWPT(host)
self.assertEqual(len(host.executive.calls), 2) self.assertEqual(host.executive.calls, [
self.assertEqual(host.executive.calls[0][1], 'fetch') ['git', 'fetch', '--all'],
self.assertEqual(host.executive.calls[1][1], 'checkout') ['git', 'checkout', 'origin/master'],
['git', 'remote'],
['git', 'remote', 'add', 'github', 'git@github.com:w3c/web-platform-tests.git']])
def test_clones_if_wpt_does_not_exist(self): def test_constructor_clones_if_wpt_dir_does_not_exist(self):
host = MockHost() host = MockHost()
host.filesystem = MockFileSystem() host.filesystem = MockFileSystem()
LocalWPT(host) LocalWPT(host)
self.assertEqual(len(host.executive.calls), 1) self.assertEqual(len(host.executive.calls), 3)
self.assertEqual(host.executive.calls[0][1], 'clone') self.assertEqual(host.executive.calls[0][1], 'clone')
def test_no_fetch_flag(self): def test_constructor_no_fetch_flag(self):
host = MockHost() host = MockHost()
host.filesystem = MockFileSystem(files={ host.filesystem = MockFileSystem(files={
'/tmp/wpt': '' '/tmp/wpt': ''
...@@ -50,8 +52,8 @@ class LocalWPTTest(unittest.TestCase): ...@@ -50,8 +52,8 @@ class LocalWPTTest(unittest.TestCase):
local_wpt = LocalWPT(host) local_wpt = LocalWPT(host)
local_wpt.run(['echo', 'rutabaga']) local_wpt.run(['echo', 'rutabaga'])
self.assertEqual(len(host.executive.calls), 2) self.assertEqual(len(host.executive.calls), 4)
self.assertEqual(host.executive.calls[1], ['echo', 'rutabaga']) self.assertEqual(host.executive.calls[3], ['echo', 'rutabaga'])
def test_last_wpt_exported_commit(self): def test_last_wpt_exported_commit(self):
host = MockHost() host = MockHost()
...@@ -71,7 +73,7 @@ class LocalWPTTest(unittest.TestCase): ...@@ -71,7 +73,7 @@ class LocalWPTTest(unittest.TestCase):
def test_last_wpt_exported_commit_not_found(self): def test_last_wpt_exported_commit_not_found(self):
host = MockHost() host = MockHost()
host.executive = MockExecutive(run_command_fn=lambda _: None) host.executive = MockExecutive(run_command_fn=lambda _: '')
host.filesystem = MockFileSystem() host.filesystem = MockFileSystem()
local_wpt = LocalWPT(host) local_wpt = LocalWPT(host)
...@@ -85,10 +87,11 @@ class LocalWPTTest(unittest.TestCase): ...@@ -85,10 +87,11 @@ class LocalWPTTest(unittest.TestCase):
local_wpt = LocalWPT(host) local_wpt = LocalWPT(host)
local_branch_name = local_wpt.create_branch_with_patch('message', 'patch', 'author') local_branch_name = local_wpt.create_branch_with_patch('message', 'patch', 'author')
self.assertEqual(len(host.executive.calls), 10)
self.assertEqual(local_branch_name, 'chromium-export-try') self.assertEqual(local_branch_name, 'chromium-export-try')
self.assertEqual(host.executive.calls, [ self.assertEqual(host.executive.calls, [
['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git', '/tmp/wpt'], ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git', '/tmp/wpt'],
['git', 'remote'],
['git', 'remote', 'add', 'github', 'git@github.com:w3c/web-platform-tests.git'],
['git', 'reset', '--hard', 'HEAD'], ['git', 'reset', '--hard', 'HEAD'],
['git', 'clean', '-fdx'], ['git', 'clean', '-fdx'],
['git', 'checkout', 'origin/master'], ['git', 'checkout', 'origin/master'],
......
...@@ -98,6 +98,8 @@ class TestExporterTest(unittest.TestCase): ...@@ -98,6 +98,8 @@ class TestExporterTest(unittest.TestCase):
self.assertIsInstance(commits[0], ChromiumCommit) self.assertIsInstance(commits[0], ChromiumCommit)
self.assertEqual(self.host.executive.calls, [ self.assertEqual(self.host.executive.calls, [
['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git', '/tmp/wpt'], ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git', '/tmp/wpt'],
['git', 'remote'],
['git', 'remote', 'add', 'github', 'git@github.com:w3c/web-platform-tests.git'],
['git', 'rev-parse', '--show-toplevel'], ['git', 'rev-parse', '--show-toplevel'],
['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'], ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'],
['git', 'diff-tree', '--name-only', '--no-commit-id', '-r', 'badbeef8', '--', ['git', 'diff-tree', '--name-only', '--no-commit-id', '-r', 'badbeef8', '--',
...@@ -130,6 +132,8 @@ class TestExporterTest(unittest.TestCase): ...@@ -130,6 +132,8 @@ class TestExporterTest(unittest.TestCase):
self.assertEqual(len(commits), 0) self.assertEqual(len(commits), 0)
self.assertEqual(self.host.executive.calls, [ self.assertEqual(self.host.executive.calls, [
['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git', '/tmp/wpt'], ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git', '/tmp/wpt'],
['git', 'remote'],
['git', 'remote', 'add', 'github', 'git@github.com:w3c/web-platform-tests.git'],
['git', 'rev-parse', '--show-toplevel'], ['git', 'rev-parse', '--show-toplevel'],
['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'], 'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'],
...@@ -150,6 +154,8 @@ class TestExporterTest(unittest.TestCase): ...@@ -150,6 +154,8 @@ class TestExporterTest(unittest.TestCase):
self.assertEqual(len(commits), 0) self.assertEqual(len(commits), 0)
self.assertEqual(self.host.executive.calls, [ self.assertEqual(self.host.executive.calls, [
['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git', '/tmp/wpt'], ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git', '/tmp/wpt'],
['git', 'remote'],
['git', 'remote', 'add', 'github', 'git@github.com:w3c/web-platform-tests.git'],
['git', 'rev-parse', '--show-toplevel'], ['git', 'rev-parse', '--show-toplevel'],
['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'], 'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'],
...@@ -170,6 +176,8 @@ class TestExporterTest(unittest.TestCase): ...@@ -170,6 +176,8 @@ class TestExporterTest(unittest.TestCase):
self.assertEqual(len(commits), 0) self.assertEqual(len(commits), 0)
self.assertEqual(self.host.executive.calls, [ self.assertEqual(self.host.executive.calls, [
['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git', '/tmp/wpt'], ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git', '/tmp/wpt'],
['git', 'remote'],
['git', 'remote', 'add', 'github', 'git@github.com:w3c/web-platform-tests.git'],
['git', 'rev-parse', '--show-toplevel'], ['git', 'rev-parse', '--show-toplevel'],
['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'], 'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment