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

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

Issue 2579193002: Merge ChromiumWPT functionality into TestExporter, use ChromiumCommits (Closed)
Patch Set: Address CL feedback Created 4 years 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
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 MockExecutive2 8 from webkitpy.common.system.executive_mock import MockExecutive2
9 from webkitpy.w3c.chromium_commit import ChromiumCommit
9 from webkitpy.w3c.test_exporter import TestExporter 10 from webkitpy.w3c.test_exporter import TestExporter
10 from webkitpy.w3c.wpt_github_mock import MockWPTGitHub 11 from webkitpy.w3c.wpt_github_mock import MockWPTGitHub
11 12
12 13
14 def mock_command_exec(vals):
15 def run_fn(args):
16 sub_command = args[1]
17 return vals.get(sub_command, '')
18 return MockExecutive2(run_command_fn=run_fn)
19
20
21
13 class TestExporterTest(unittest.TestCase): 22 class TestExporterTest(unittest.TestCase):
14 23
24 def setUp(self):
25 self.host = MockHost()
26 self.wpt_github = MockWPTGitHub(pull_requests=[])
27
15 def test_stops_if_more_than_one_pr_is_in_flight(self): 28 def test_stops_if_more_than_one_pr_is_in_flight(self):
16 host = MockHost() 29 host = MockHost()
17 wpt_github = MockWPTGitHub(pull_requests=[{'id': 1}, {'id': 2}]) 30 wpt_github = MockWPTGitHub(pull_requests=[{'id': 1}, {'id': 2}])
18 31
19 # TODO: make Exception more specific 32 # TODO: make Exception more specific
20 with self.assertRaises(Exception): 33 with self.assertRaises(Exception):
21 TestExporter(host, wpt_github).run() 34 TestExporter(host, wpt_github).run()
22 35
23 def test_if_pr_exists_merges_it(self): 36 def test_if_pr_exists_merges_it(self):
24 host = MockHost() 37 host = MockHost()
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return '' 75 return ''
63 76
64 host.executive = MockExecutive2(run_command_fn=mock_command) 77 host.executive = MockExecutive2(run_command_fn=mock_command)
65 wpt_github = MockWPTGitHub(pull_requests=[]) 78 wpt_github = MockWPTGitHub(pull_requests=[])
66 79
67 TestExporter(host, wpt_github).run() 80 TestExporter(host, wpt_github).run()
68 81
69 self.assertEqual(wpt_github.calls, ['in_flight_pull_requests', 'create_p r']) 82 self.assertEqual(wpt_github.calls, ['in_flight_pull_requests', 'create_p r'])
70 self.assertEqual(wpt_github.pull_requests_created, 83 self.assertEqual(wpt_github.pull_requests_created,
71 [('chromium-export-try', 'older fake text', 'older fake text')]) 84 [('chromium-export-try', 'older fake text', 'older fake text')])
85
86 def test_exportable_commits_since(self):
87 self.host.executive = mock_command_exec({
88 'show': 'fake message',
89 'rev-list': 'badbeef8',
90 'rev-parse': 'badbeef8',
91 'crrev-parse': 'badbeef8',
92 'diff': 'fake diff',
93 'diff-tree': 'some\nfiles',
94 'format-patch': 'hey I\'m a patch',
95 'footers': 'cr-rev-position',
96 })
97 test_exporter = TestExporter(self.host, self.wpt_github)
98
99 commits = test_exporter.exportable_commits_since('beefcafe')
100 self.assertEqual(len(commits), 1)
101 self.assertIsInstance(commits[0], ChromiumCommit)
102 self.assertEqual(self.host.executive.calls, [
103 ['git', 'rev-parse', '--show-toplevel'],
104 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/t hird_party/WebKit/LayoutTests/imported/wpt/'],
105 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8'],
106 ['git', 'diff-tree', '--no-commit-id', '--name-only', '-r', 'badbeef 8']])
107
108 def test_ignores_commits_with_noexport_true(self):
109 self.host.executive = mock_command_exec({
110 'show': 'Commit message\nNOEXPORT=true',
111 'rev-list': 'badbeef8',
112 'rev-parse': 'badbeef8',
113 'footers': 'cr-rev-position',
114 })
115 test_exporter = TestExporter(self.host, self.wpt_github)
116
117 commits = test_exporter.exportable_commits_since('beefcafe')
118 self.assertEqual(len(commits), 0)
119 self.assertEqual(self.host.executive.calls, [
120 ['git', 'rev-parse', '--show-toplevel'],
121 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/t hird_party/WebKit/LayoutTests/imported/wpt/'],
122 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']])
123
124 def test_ignores_reverted_commits_with_noexport_true(self):
125 self.host.executive = mock_command_exec({
126 'show': 'Commit message\n> NOEXPORT=true',
127 'rev-list': 'badbeef8',
128 'rev-parse': 'badbeef8',
129 'footers': 'cr-rev-position',
130 })
131 wpt_github = MockWPTGitHub(pull_requests=[])
132 test_exporter = TestExporter(self.host, wpt_github)
133
134 commits = test_exporter.exportable_commits_since('beefcafe')
135 self.assertEqual(len(commits), 0)
136 self.assertEqual(self.host.executive.calls, [
137 ['git', 'rev-parse', '--show-toplevel'],
138 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/t hird_party/WebKit/LayoutTests/imported/wpt/'],
139 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']])
140
141 def test_ignores_commits_that_start_with_import(self):
142 self.host.executive = mock_command_exec({
143 'show': 'Import rutabaga@deadbeef',
144 'rev-list': 'badbeef8',
145 'rev-parse': 'badbeef8',
146 'footers': 'cr-rev-position',
147 })
148 wpt_github = MockWPTGitHub(pull_requests=[])
149 test_exporter = TestExporter(self.host, wpt_github)
150
151 commits = test_exporter.exportable_commits_since('beefcafe')
152 self.assertEqual(len(commits), 0)
153 self.assertEqual(self.host.executive.calls, [
154 ['git', 'rev-parse', '--show-toplevel'],
155 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/t hird_party/WebKit/LayoutTests/imported/wpt/'],
156 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']])
OLDNEW
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698