| 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 | 8 from webkitpy.common.system.executive_mock import MockExecutive |
| 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 from webkitpy.w3c.common_unittest import mock_command_exec_strict |
| 11 | 12 |
| 12 | 13 |
| 13 class LocalWPTTest(unittest.TestCase): | 14 class LocalWPTTest(unittest.TestCase): |
| 14 | 15 |
| 15 def test_fetch_when_wpt_dir_exists(self): | 16 def test_fetch_when_wpt_dir_exists(self): |
| 16 host = MockHost() | 17 host = MockHost() |
| 17 host.filesystem = MockFileSystem(files={ | 18 host.filesystem = MockFileSystem(files={ |
| 18 '/tmp/wpt': '' | 19 '/tmp/wpt': '' |
| 19 }) | 20 }) |
| 20 | 21 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 32 host = MockHost() | 33 host = MockHost() |
| 33 host.filesystem = MockFileSystem() | 34 host.filesystem = MockFileSystem() |
| 34 | 35 |
| 35 local_wpt = LocalWPT(host) | 36 local_wpt = LocalWPT(host) |
| 36 local_wpt.fetch() | 37 local_wpt.fetch() |
| 37 | 38 |
| 38 self.assertEqual(len(host.executive.calls), 3) | 39 self.assertEqual(len(host.executive.calls), 3) |
| 39 self.assertEqual(host.executive.calls[0][1], 'clone') | 40 self.assertEqual(host.executive.calls[0][1], 'clone') |
| 40 | 41 |
| 41 def test_constructor(self): | 42 def test_constructor(self): |
| 42 # | |
| 43 host = MockHost() | 43 host = MockHost() |
| 44 LocalWPT(host) | 44 LocalWPT(host) |
| 45 self.assertEqual(len(host.executive.calls), 0) | 45 self.assertEqual(len(host.executive.calls), 0) |
| 46 | 46 |
| 47 def test_run(self): | 47 def test_run(self): |
| 48 host = MockHost() | 48 host = MockHost() |
| 49 host.filesystem = MockFileSystem() | 49 host.filesystem = MockFileSystem() |
| 50 local_wpt = LocalWPT(host) | 50 local_wpt = LocalWPT(host) |
| 51 local_wpt.run(['echo', 'rutabaga']) | 51 local_wpt.run(['echo', 'rutabaga']) |
| 52 self.assertEqual(host.executive.calls, [['echo', 'rutabaga']]) | 52 self.assertEqual(host.executive.calls, [['echo', 'rutabaga']]) |
| 53 | 53 |
| 54 def test_last_wpt_exported_commit(self): | 54 def test_last_wpt_exported_commit(self): |
| 55 host = MockHost() | 55 host = MockHost() |
| 56 return_vals = [ | 56 host.executive = mock_command_exec_strict({ |
| 57 'deadbeefcafe', | 57 'rev-list': '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8', |
| 58 '123', | 58 'footers': 'Cr-Commit-Position: 123', |
| 59 '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8', | 59 'crrev-parse': 'add087a97844f4b9e307d9a216940582d96db306', |
| 60 ] | 60 }) |
| 61 host.executive = MockExecutive(run_command_fn=lambda _: return_vals.pop(
)) | |
| 62 host.filesystem = MockFileSystem() | 61 host.filesystem = MockFileSystem() |
| 63 local_wpt = LocalWPT(host) | 62 local_wpt = LocalWPT(host) |
| 64 | 63 |
| 65 wpt_sha, chromium_commit = local_wpt.most_recent_chromium_commit() | 64 wpt_sha, chromium_commit = local_wpt.most_recent_chromium_commit() |
| 66 self.assertEqual(wpt_sha, '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8') | 65 self.assertEqual(wpt_sha, '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8') |
| 67 self.assertEqual(chromium_commit.position, '123') | 66 self.assertEqual(chromium_commit.position, '123') |
| 68 self.assertEqual(chromium_commit.sha, 'deadbeefcafe') | 67 self.assertEqual(chromium_commit.sha, 'add087a97844f4b9e307d9a216940582d
96db306') |
| 69 | 68 |
| 70 def test_last_wpt_exported_commit_not_found(self): | 69 def test_last_wpt_exported_commit_not_found(self): |
| 71 host = MockHost() | 70 host = MockHost() |
| 72 host.executive = MockExecutive(run_command_fn=lambda _: '') | 71 host.executive = MockExecutive(run_command_fn=lambda _: '') |
| 73 host.filesystem = MockFileSystem() | 72 host.filesystem = MockFileSystem() |
| 74 local_wpt = LocalWPT(host) | 73 local_wpt = LocalWPT(host) |
| 75 | 74 |
| 76 commit = local_wpt.most_recent_chromium_commit() | 75 commit = local_wpt.most_recent_chromium_commit() |
| 77 self.assertEqual(commit, (None, None)) | 76 self.assertEqual(commit, (None, None)) |
| 78 | 77 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 92 ['git', 'reset', '--hard', 'HEAD'], | 91 ['git', 'reset', '--hard', 'HEAD'], |
| 93 ['git', 'clean', '-fdx'], | 92 ['git', 'clean', '-fdx'], |
| 94 ['git', 'checkout', 'origin/master'], | 93 ['git', 'checkout', 'origin/master'], |
| 95 ['git', 'branch', '-a'], | 94 ['git', 'branch', '-a'], |
| 96 ['git', 'branch', '-a'], | 95 ['git', 'branch', '-a'], |
| 97 ['git', 'checkout', '-b', 'chromium-export-try'], | 96 ['git', 'checkout', '-b', 'chromium-export-try'], |
| 98 ['git', 'apply', '-'], | 97 ['git', 'apply', '-'], |
| 99 ['git', 'add', '.'], | 98 ['git', 'add', '.'], |
| 100 ['git', 'commit', '--author', 'author', '-am', 'message'], | 99 ['git', 'commit', '--author', 'author', '-am', 'message'], |
| 101 ['git', 'push', '-f', 'github', 'chromium-export-try']]) | 100 ['git', 'push', '-f', 'github', 'chromium-export-try']]) |
| OLD | NEW |