Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/common_unittest.py

Issue 2648783004: Move exportable_commits_since to webkitpy/w3c/common.py. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import unittest
6
7 from webkitpy.common.host_mock import MockHost
8 from webkitpy.common.system.executive_mock import MockExecutive
9 from webkitpy.w3c.chromium_commit import ChromiumCommit
10 from webkitpy.w3c.common import exportable_commits_since
11
12
13 # TODO(qyearsley): Move this to executive_mock.
jeffcarp 2017/01/20 22:22:55 Would it be cleaner if we integrated this function
qyearsley 2017/01/20 22:40:02 Yeah, that sounds like a good idea - in this case
14 def mock_command_exec(vals):
15 def run_fn(args):
16 sub_command = args[1]
17 return vals.get(sub_command, '')
18 return MockExecutive(run_command_fn=run_fn)
19
20
21 class MockLocalWPT(object):
22
23 def test_patch(self, _):
24 return True
25
26
27 class CommonTest(unittest.TestCase):
28
29 def test_exportable_commits_since(self):
30 host = MockHost()
31 host.executive = mock_command_exec({
32 'show': 'fake message',
33 'rev-list': 'badbeef8',
34 'rev-parse': 'badbeef8',
35 'crrev-parse': 'badbeef8',
36 'diff': 'fake diff',
37 'diff-tree': 'some\nfiles',
38 'format-patch': 'hey I\'m a patch',
39 'footers': 'cr-rev-position',
40 })
41
42 commits = exportable_commits_since('beefcafe', host, MockLocalWPT())
43 self.assertEqual(len(commits), 1)
44 self.assertIsInstance(commits[0], ChromiumCommit)
45 self.assertEqual(host.executive.calls, [
46 ['git', 'rev-parse', '--show-toplevel'],
47 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/t hird_party/WebKit/LayoutTests/external/wpt/'],
48 ['git', 'diff-tree', '--name-only', '--no-commit-id', '-r', 'badbeef 8', '--',
49 '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt'],
50 ['git', 'format-patch', '-1', '--stdout', 'badbeef8', '--', 'some', 'files'],
51 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8'],
52 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']
53 ])
54
55 def test_ignores_commits_with_noexport_true(self):
56 host = MockHost()
57 host.executive = mock_command_exec({
58 'show': 'Commit message\nNOEXPORT=true',
59 'rev-list': 'badbeef8',
60 'rev-parse': 'badbeef8',
61 'footers': 'cr-rev-position',
62 })
63
64 commits = exportable_commits_since('beefcafe', host, MockLocalWPT())
65 self.assertEqual(commits, [])
66 self.assertEqual(host.executive.calls, [
67 ['git', 'rev-parse', '--show-toplevel'],
68 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
69 'badbeef8/third_party/WebKit/LayoutTests/external/wpt/'],
70 ['git', 'diff-tree', '--name-only', '--no-commit-id', '-r', 'badbeef 8', '--',
71 '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt']
72 ])
73
74 def test_ignores_reverted_commits_with_noexport_true(self):
75 host = MockHost()
76 host.executive = mock_command_exec({
77 'show': 'Commit message\n> NOEXPORT=true',
78 'rev-list': 'badbeef8',
79 'rev-parse': 'badbeef8',
80 'footers': 'cr-rev-position',
81 })
82
83 commits = exportable_commits_since('beefcafe', host, MockLocalWPT())
84 self.assertEqual(len(commits), 0)
85 self.assertEqual(host.executive.calls, [
86 ['git', 'rev-parse', '--show-toplevel'],
87 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
88 'badbeef8/third_party/WebKit/LayoutTests/external/wpt/'],
89 ['git', 'diff-tree', '--name-only', '--no-commit-id', '-r', 'badbeef 8', '--',
90 '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt']])
91
92 def test_ignores_commits_that_start_with_import(self):
93 host = MockHost()
94 host.executive = mock_command_exec({
95 'show': 'Import rutabaga@deadbeef',
96 'rev-list': 'badbeef8',
97 'rev-parse': 'badbeef8',
98 'footers': 'cr-rev-position',
99 })
100
101 commits = exportable_commits_since('beefcafe', host, MockLocalWPT())
102 self.assertEqual(commits, [])
103 self.assertEqual(host.executive.calls, [
104 ['git', 'rev-parse', '--show-toplevel'],
105 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
106 'badbeef8/third_party/WebKit/LayoutTests/external/wpt/'],
107 ['git', 'diff-tree', '--name-only', '--no-commit-id', '-r', 'badbeef 8', '--',
108 '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt']
109 ])
OLDNEW
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/w3c/common.py ('k') | third_party/WebKit/Tools/Scripts/webkitpy/w3c/deps_updater.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698