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 from webkitpy.common.host_mock import MockHost | 6 from webkitpy.common.host_mock import MockHost |
7 from webkitpy.common.system.executive_mock import MockExecutive2 | 7 from webkitpy.common.system.executive_mock import MockExecutive2 |
8 from webkitpy.w3c.chromium_commit import ChromiumCommit | 8 from webkitpy.w3c.chromium_commit import ChromiumCommit |
9 from webkitpy.w3c.test_exporter import CHROMIUM_WPT_DIR | |
10 from webkitpy.w3c.test_exporter_unittest import mock_command_exec | |
9 | 11 |
10 | 12 |
11 class ChromiumCommitTest(unittest.TestCase): | 13 class ChromiumCommitTest(unittest.TestCase): |
12 | 14 |
13 def test_accepts_sha(self): | 15 def test_accepts_sha(self): |
14 chromium_commit = ChromiumCommit(MockHost(), sha='deadbeefcafe') | 16 chromium_commit = ChromiumCommit(MockHost(), sha='deadbeefcafe') |
15 | 17 |
16 self.assertEqual(chromium_commit.sha, 'deadbeefcafe') | 18 self.assertEqual(chromium_commit.sha, 'deadbeefcafe') |
17 self.assertIsNone(chromium_commit.position) | 19 self.assertIsNone(chromium_commit.position) |
18 | 20 |
19 def test_derives_sha_from_position(self): | 21 def test_derives_sha_from_position(self): |
20 host = MockHost() | 22 host = MockHost() |
21 host.executive = MockExecutive2(output='deadbeefcafe') | 23 host.executive = MockExecutive2(output='deadbeefcafe') |
22 pos = 'Cr-Commit-Position: refs/heads/master@{#789}' | 24 pos = 'Cr-Commit-Position: refs/heads/master@{#789}' |
23 chromium_commit = ChromiumCommit(host, position=pos) | 25 chromium_commit = ChromiumCommit(host, position=pos) |
24 | 26 |
25 self.assertEqual(chromium_commit.position, 'refs/heads/master@{#789}') | 27 self.assertEqual(chromium_commit.position, 'refs/heads/master@{#789}') |
26 self.assertEqual(chromium_commit.sha, 'deadbeefcafe') | 28 self.assertEqual(chromium_commit.sha, 'deadbeefcafe') |
29 | |
30 def test_filtered_changed_files_blacklist(self): | |
31 host = MockHost() | |
32 | |
33 fake_files = ['file1', 'MANIFEST.json', 'file3'] | |
34 qualified_fake_files = [CHROMIUM_WPT_DIR + f for f in fake_files] | |
35 | |
36 host.executive = mock_command_exec({ | |
37 'diff-tree': '\n'.join(qualified_fake_files), | |
38 'crrev-parse': 'fake rev', | |
39 }) | |
40 | |
41 pos = 'Cr-Commit-Position: refs/heads/master@{#789}' | |
qyearsley
2016/12/21 00:24:46
Nit: if you want to avoid abbreviation variable na
jeffcarp
2016/12/21 19:12:52
Done, abbreviated variables begone! I chose to nam
qyearsley
2016/12/21 19:19:56
Yeah -- the main reason I've heard before is that
| |
42 chromium_commit = ChromiumCommit(host, position=pos) | |
43 | |
44 files = chromium_commit.filtered_changed_files() | |
45 | |
46 expected_files = ['file1', 'file3'] | |
47 qualified_expected_files = [CHROMIUM_WPT_DIR + f for f in expected_files ] | |
48 | |
49 self.assertEqual(files, qualified_expected_files) | |
OLD | NEW |