| 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 import unittest | 5 import unittest |
| 6 | 6 |
| 7 from webkitpy.common.host_mock import MockHost | 7 from webkitpy.common.host_mock import MockHost |
| 8 from webkitpy.common.system.executive_mock import MockExecutive, mock_git_comman
ds | 8 from webkitpy.common.system.executive_mock import MockExecutive, mock_git_comman
ds |
| 9 from webkitpy.common.system.filesystem_mock import MockFileSystem | 9 from webkitpy.common.system.filesystem_mock import MockFileSystem |
| 10 from webkitpy.w3c.local_wpt import LocalWPT | 10 from webkitpy.w3c.local_wpt import LocalWPT |
| 11 | 11 |
| 12 | 12 |
| 13 class LocalWPTTest(unittest.TestCase): | 13 class LocalWPTTest(unittest.TestCase): |
| 14 | 14 |
| 15 def test_fetch_when_wpt_dir_exists(self): | 15 def test_fetch_when_wpt_dir_exists(self): |
| 16 host = MockHost() | 16 host = MockHost() |
| 17 host.filesystem = MockFileSystem(files={ | 17 host.filesystem = MockFileSystem(files={ |
| 18 '/tmp/wpt': '' | 18 '/tmp/wpt': '' |
| 19 }) | 19 }) |
| 20 | 20 |
| 21 local_wpt = LocalWPT(host) | 21 local_wpt = LocalWPT(host) |
| 22 local_wpt.fetch() | 22 local_wpt.fetch() |
| 23 | 23 |
| 24 self.assertEqual(host.executive.calls, [ | 24 self.assertEqual(host.executive.calls, [ |
| 25 ['git', 'fetch', '--all'], | 25 ['git', 'fetch', 'origin'], |
| 26 ['git', 'checkout', 'origin/master'], | 26 ['git', 'checkout', 'origin/master'], |
| 27 ['git', 'remote'], | |
| 28 ['git', 'remote', 'add', 'github', 'git@github.com:w3c/web-platform-
tests.git'] | |
| 29 ]) | 27 ]) |
| 30 | 28 |
| 31 def test_fetch_when_wpt_dir_does_not_exist(self): | 29 def test_fetch_when_wpt_dir_does_not_exist(self): |
| 32 host = MockHost() | 30 host = MockHost() |
| 33 host.filesystem = MockFileSystem() | 31 host.filesystem = MockFileSystem() |
| 34 | 32 |
| 35 local_wpt = LocalWPT(host) | 33 local_wpt = LocalWPT(host) |
| 36 local_wpt.fetch() | 34 local_wpt.fetch() |
| 37 | 35 |
| 38 self.assertEqual(len(host.executive.calls), 3) | 36 self.assertEqual(host.executive.calls, [ |
| 39 self.assertEqual(host.executive.calls[0][1], 'clone') | 37 ['git', 'clone', 'git@github.com:w3c/web-platform-tests.git', '/tmp/
wpt'], |
| 38 ]) |
| 40 | 39 |
| 41 def test_constructor(self): | 40 def test_constructor(self): |
| 42 host = MockHost() | 41 host = MockHost() |
| 43 LocalWPT(host) | 42 LocalWPT(host) |
| 44 self.assertEqual(len(host.executive.calls), 0) | 43 self.assertEqual(len(host.executive.calls), 0) |
| 45 | 44 |
| 46 def test_run(self): | 45 def test_run(self): |
| 47 host = MockHost() | 46 host = MockHost() |
| 48 host.filesystem = MockFileSystem() | 47 host.filesystem = MockFileSystem() |
| 49 local_wpt = LocalWPT(host) | 48 local_wpt = LocalWPT(host) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 77 def test_create_branch_with_patch(self): | 76 def test_create_branch_with_patch(self): |
| 78 host = MockHost() | 77 host = MockHost() |
| 79 host.filesystem = MockFileSystem() | 78 host.filesystem = MockFileSystem() |
| 80 | 79 |
| 81 local_wpt = LocalWPT(host) | 80 local_wpt = LocalWPT(host) |
| 82 local_wpt.fetch() | 81 local_wpt.fetch() |
| 83 | 82 |
| 84 local_branch_name = local_wpt.create_branch_with_patch('message', 'patch
', 'author') | 83 local_branch_name = local_wpt.create_branch_with_patch('message', 'patch
', 'author') |
| 85 self.assertEqual(local_branch_name, 'chromium-export-try') | 84 self.assertEqual(local_branch_name, 'chromium-export-try') |
| 86 self.assertEqual(host.executive.calls, [ | 85 self.assertEqual(host.executive.calls, [ |
| 87 ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web
-platform-tests.git', '/tmp/wpt'], | 86 ['git', 'clone', 'git@github.com:w3c/web-platform-tests.git', '/tmp/
wpt'], |
| 88 ['git', 'remote'], | |
| 89 ['git', 'remote', 'add', 'github', 'git@github.com:w3c/web-platform-
tests.git'], | |
| 90 ['git', 'reset', '--hard', 'HEAD'], | 87 ['git', 'reset', '--hard', 'HEAD'], |
| 91 ['git', 'clean', '-fdx'], | 88 ['git', 'clean', '-fdx'], |
| 92 ['git', 'checkout', 'origin/master'], | 89 ['git', 'checkout', 'origin/master'], |
| 93 ['git', 'branch', '-a'], | 90 ['git', 'branch', '-a'], |
| 94 ['git', 'branch', '-a'], | 91 ['git', 'branch', '-a'], |
| 95 ['git', 'checkout', '-b', 'chromium-export-try'], | 92 ['git', 'checkout', '-b', 'chromium-export-try'], |
| 96 ['git', 'apply', '-'], | 93 ['git', 'apply', '-'], |
| 97 ['git', 'add', '.'], | 94 ['git', 'add', '.'], |
| 98 ['git', 'commit', '--author', 'author', '-am', 'message'], | 95 ['git', 'commit', '--author', 'author', '-am', 'message'], |
| 99 ['git', 'push', '-f', 'github', 'chromium-export-try']]) | 96 ['git', 'push', '-f', 'origin', 'chromium-export-try']]) |
| OLD | NEW |