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