| 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.w3c.chromium_commit import ChromiumCommit | 9 from webkitpy.w3c.chromium_commit import ChromiumCommit |
| 10 from webkitpy.w3c.common_unittest import mock_command_exec | 10 from webkitpy.w3c.common_unittest import mock_command_exec |
| 11 | 11 |
| 12 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/external/wpt/' | 12 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/external/wpt/' |
| 13 | 13 |
| 14 | 14 |
| 15 class ChromiumCommitTest(unittest.TestCase): | 15 class ChromiumCommitTest(unittest.TestCase): |
| 16 | 16 |
| 17 def test_accepts_sha(self): | 17 def test_accepts_sha(self): |
| 18 chromium_commit = ChromiumCommit(MockHost(), sha='deadbeefcafe') | 18 chromium_commit = ChromiumCommit(MockHost(), sha='c881563d734a86f7d9cd57
ac509653a61c45c240') |
| 19 | 19 |
| 20 self.assertEqual(chromium_commit.sha, 'deadbeefcafe') | 20 self.assertEqual(chromium_commit.sha, 'c881563d734a86f7d9cd57ac509653a61
c45c240') |
| 21 self.assertIsNone(chromium_commit.position) | 21 self.assertIsNone(chromium_commit.position) |
| 22 | 22 |
| 23 def test_derives_sha_from_position(self): | 23 def test_derives_sha_from_position(self): |
| 24 host = MockHost() | 24 host = MockHost() |
| 25 host.executive = MockExecutive(output='deadbeefcafe') | 25 host.executive = MockExecutive(output='c881563d734a86f7d9cd57ac509653a61
c45c240') |
| 26 pos = 'Cr-Commit-Position: refs/heads/master@{#789}' | 26 pos = 'Cr-Commit-Position: refs/heads/master@{#789}' |
| 27 chromium_commit = ChromiumCommit(host, position=pos) | 27 chromium_commit = ChromiumCommit(host, position=pos) |
| 28 | 28 |
| 29 self.assertEqual(chromium_commit.position, 'refs/heads/master@{#789}') | 29 self.assertEqual(chromium_commit.position, 'refs/heads/master@{#789}') |
| 30 self.assertEqual(chromium_commit.sha, 'deadbeefcafe') | 30 self.assertEqual(chromium_commit.sha, 'c881563d734a86f7d9cd57ac509653a61
c45c240') |
| 31 | 31 |
| 32 def test_filtered_changed_files_blacklist(self): | 32 def test_filtered_changed_files_blacklist(self): |
| 33 host = MockHost() | 33 host = MockHost() |
| 34 | 34 |
| 35 fake_files = ['file1', 'MANIFEST.json', 'file3'] | 35 fake_files = ['file1', 'MANIFEST.json', 'file3'] |
| 36 qualified_fake_files = [CHROMIUM_WPT_DIR + f for f in fake_files] | 36 qualified_fake_files = [CHROMIUM_WPT_DIR + f for f in fake_files] |
| 37 | 37 |
| 38 host.executive = mock_command_exec({ | 38 host.executive = mock_command_exec({ |
| 39 'diff-tree': '\n'.join(qualified_fake_files), | 39 'diff-tree': '\n'.join(qualified_fake_files), |
| 40 'crrev-parse': 'fake rev', | 40 'crrev-parse': 'c881563d734a86f7d9cd57ac509653a61c45c240', |
| 41 }) | 41 }) |
| 42 | 42 |
| 43 position_footer = 'Cr-Commit-Position: refs/heads/master@{#789}' | 43 position_footer = 'Cr-Commit-Position: refs/heads/master@{#789}' |
| 44 chromium_commit = ChromiumCommit(host, position=position_footer) | 44 chromium_commit = ChromiumCommit(host, position=position_footer) |
| 45 | 45 |
| 46 files = chromium_commit.filtered_changed_files() | 46 files = chromium_commit.filtered_changed_files() |
| 47 | 47 |
| 48 expected_files = ['file1', 'file3'] | 48 expected_files = ['file1', 'file3'] |
| 49 qualified_expected_files = [CHROMIUM_WPT_DIR + f for f in expected_files
] | 49 qualified_expected_files = [CHROMIUM_WPT_DIR + f for f in expected_files
] |
| 50 | 50 |
| 51 self.assertEqual(files, qualified_expected_files) | 51 self.assertEqual(files, qualified_expected_files) |
| OLD | NEW |