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

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

Issue 2583723002: Use LocalWPT.test_patch when filtering exportable commits (Closed)
Patch Set: Fix test_exporter_unittest Created 3 years, 12 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
« 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.chromium_commit import ChromiumCommit
10 from webkitpy.w3c.test_exporter import TestExporter 10 from webkitpy.w3c.test_exporter import TestExporter
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 host.executive = MockExecutive2(output='beefcafe') 53 host.executive = MockExecutive2(output='beefcafe')
54 wpt_github = MockWPTGitHub(pull_requests=[{'number': 1, 'title': 'abc'}] ) 54 wpt_github = MockWPTGitHub(pull_requests=[{'number': 1, 'title': 'abc'}] )
55 TestExporter(host, wpt_github, dry_run=True).run() 55 TestExporter(host, wpt_github, dry_run=True).run()
56 56
57 self.assertEqual(wpt_github.calls, ['in_flight_pull_requests']) 57 self.assertEqual(wpt_github.calls, ['in_flight_pull_requests'])
58 58
59 def test_creates_pull_request_for_earliest_commit(self): 59 def test_creates_pull_request_for_earliest_commit(self):
60 host = MockHost() 60 host = MockHost()
61 61
62 def mock_command(args): 62 def mock_command(args):
63 git_command = args[1] 63 canned_git_outputs = {
64 if git_command == 'rev-list': 64 'show': 'newer fake text' if 'cafedad5' in args else 'older fake text',
65 return 'facebeef\ncafedad5' 65 'rev-list': 'facebeef\ncafedad5',
66 elif git_command == 'footers': 66 'footers': 'fake-cr-position',
67 return 'fake-cr-position' 67 'remote': 'github',
68 elif git_command == 'show': 68 'format-patch': 'fake patch',
69 if 'cafedad5' in args: 69 'diff': 'fake patch diff',
70 return 'newer fake text' 70 'diff-tree': 'fake\n\files\nchanged',
71 elif 'facebeef' in args: 71 }
72 return 'older fake text' 72 return canned_git_outputs.get(args[1], '')
73 else:
74 return ''
75 73
76 host.executive = MockExecutive2(run_command_fn=mock_command) 74 host.executive = MockExecutive2(run_command_fn=mock_command)
77 wpt_github = MockWPTGitHub(pull_requests=[]) 75 wpt_github = MockWPTGitHub(pull_requests=[])
78 76
79 TestExporter(host, wpt_github).run() 77 TestExporter(host, wpt_github).run()
80 78
81 self.assertEqual(wpt_github.calls, ['in_flight_pull_requests', 'create_p r']) 79 self.assertEqual(wpt_github.calls, ['in_flight_pull_requests', 'create_p r'])
82 self.assertEqual(wpt_github.pull_requests_created, 80 self.assertEqual(wpt_github.pull_requests_created,
83 [('chromium-export-try', 'older fake text', 'older fake text')]) 81 [('chromium-export-try', 'older fake text', 'older fake text')])
84 82
85 def test_exportable_commits_since(self): 83 def test_exportable_commits_since(self):
86 self.host.executive = mock_command_exec({ 84 self.host.executive = mock_command_exec({
87 'show': 'fake message', 85 'show': 'fake message',
88 'rev-list': 'badbeef8', 86 'rev-list': 'badbeef8',
89 'rev-parse': 'badbeef8', 87 'rev-parse': 'badbeef8',
90 'crrev-parse': 'badbeef8', 88 'crrev-parse': 'badbeef8',
91 'diff': 'fake diff', 89 'diff': 'fake diff',
92 'diff-tree': 'some\nfiles', 90 'diff-tree': 'some\nfiles',
93 'format-patch': 'hey I\'m a patch', 91 'format-patch': 'hey I\'m a patch',
94 'footers': 'cr-rev-position', 92 'footers': 'cr-rev-position',
95 }) 93 })
96 test_exporter = TestExporter(self.host, self.wpt_github) 94 test_exporter = TestExporter(self.host, self.wpt_github)
97 95
98 commits = test_exporter.exportable_commits_since('beefcafe') 96 commits = test_exporter.exportable_commits_since('beefcafe')
99 self.assertEqual(len(commits), 1) 97 self.assertEqual(len(commits), 1)
100 self.assertIsInstance(commits[0], ChromiumCommit) 98 self.assertIsInstance(commits[0], ChromiumCommit)
101 self.assertEqual(self.host.executive.calls, [ 99 self.assertEqual(self.host.executive.calls, [
100 ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web -platform-tests.git', '/tmp/wpt'],
102 ['git', 'rev-parse', '--show-toplevel'], 101 ['git', 'rev-parse', '--show-toplevel'],
103 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/t hird_party/WebKit/LayoutTests/imported/wpt/'], 102 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
103 'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'],
104 ['git', 'diff-tree', '--name-only', '--no-commit-id', '-r',
105 'badbeef8', '--', '/mock-checkout/third_party/WebKit/LayoutTests/im ported/wpt'],
106 ['git', 'format-patch', '-1', '--stdout', 'badbeef8', '--', 'some', 'files'],
107 ['git', 'reset', '--hard', 'HEAD'],
108 ['git', 'clean', '-fdx'],
109 ['git', 'checkout', 'origin/master'],
110 ['git', 'apply', '-'],
111 ['git', 'add', '.'],
112 ['git', 'diff', 'origin/master'],
113 ['git', 'reset', '--hard', 'HEAD'],
114 ['git', 'clean', '-fdx'],
115 ['git', 'checkout', 'origin/master'],
104 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8'], 116 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8'],
105 ['git', 'diff-tree', '--no-commit-id', '--name-only', '-r', 'badbeef 8']]) 117 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']])
106 118
107 def test_ignores_commits_with_noexport_true(self): 119 def test_ignores_commits_with_noexport_true(self):
108 self.host.executive = mock_command_exec({ 120 self.host.executive = mock_command_exec({
109 'show': 'Commit message\nNOEXPORT=true', 121 'show': 'Commit message\nNOEXPORT=true',
110 'rev-list': 'badbeef8', 122 'rev-list': 'badbeef8',
111 'rev-parse': 'badbeef8', 123 'rev-parse': 'badbeef8',
112 'footers': 'cr-rev-position', 124 'footers': 'cr-rev-position',
113 }) 125 })
114 test_exporter = TestExporter(self.host, self.wpt_github) 126 test_exporter = TestExporter(self.host, self.wpt_github)
115 127
116 commits = test_exporter.exportable_commits_since('beefcafe') 128 commits = test_exporter.exportable_commits_since('beefcafe')
117 self.assertEqual(len(commits), 0) 129 self.assertEqual(len(commits), 0)
118 self.assertEqual(self.host.executive.calls, [ 130 self.assertEqual(self.host.executive.calls, [
131 ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web -platform-tests.git', '/tmp/wpt'],
119 ['git', 'rev-parse', '--show-toplevel'], 132 ['git', 'rev-parse', '--show-toplevel'],
120 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/t hird_party/WebKit/LayoutTests/imported/wpt/'], 133 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
121 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']]) 134 'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'],
135 ['git', 'diff-tree', '--name-only', '--no-commit-id', '-r', 'badbeef 8', '--',
136 '/mock-checkout/third_party/WebKit/LayoutTests/imported/wpt']])
122 137
123 def test_ignores_reverted_commits_with_noexport_true(self): 138 def test_ignores_reverted_commits_with_noexport_true(self):
124 self.host.executive = mock_command_exec({ 139 self.host.executive = mock_command_exec({
125 'show': 'Commit message\n> NOEXPORT=true', 140 'show': 'Commit message\n> NOEXPORT=true',
126 'rev-list': 'badbeef8', 141 'rev-list': 'badbeef8',
127 'rev-parse': 'badbeef8', 142 'rev-parse': 'badbeef8',
128 'footers': 'cr-rev-position', 143 'footers': 'cr-rev-position',
129 }) 144 })
130 wpt_github = MockWPTGitHub(pull_requests=[]) 145 wpt_github = MockWPTGitHub(pull_requests=[])
131 test_exporter = TestExporter(self.host, wpt_github) 146 test_exporter = TestExporter(self.host, wpt_github)
132 147
133 commits = test_exporter.exportable_commits_since('beefcafe') 148 commits = test_exporter.exportable_commits_since('beefcafe')
134 self.assertEqual(len(commits), 0) 149 self.assertEqual(len(commits), 0)
135 self.assertEqual(self.host.executive.calls, [ 150 self.assertEqual(self.host.executive.calls, [
151 ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web -platform-tests.git', '/tmp/wpt'],
136 ['git', 'rev-parse', '--show-toplevel'], 152 ['git', 'rev-parse', '--show-toplevel'],
137 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/t hird_party/WebKit/LayoutTests/imported/wpt/'], 153 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
138 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']]) 154 'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'],
155 ['git', 'diff-tree', '--name-only', '--no-commit-id', '-r', 'badbeef 8', '--',
156 '/mock-checkout/third_party/WebKit/LayoutTests/imported/wpt']])
139 157
140 def test_ignores_commits_that_start_with_import(self): 158 def test_ignores_commits_that_start_with_import(self):
141 self.host.executive = mock_command_exec({ 159 self.host.executive = mock_command_exec({
142 'show': 'Import rutabaga@deadbeef', 160 'show': 'Import rutabaga@deadbeef',
143 'rev-list': 'badbeef8', 161 'rev-list': 'badbeef8',
144 'rev-parse': 'badbeef8', 162 'rev-parse': 'badbeef8',
145 'footers': 'cr-rev-position', 163 'footers': 'cr-rev-position',
146 }) 164 })
147 wpt_github = MockWPTGitHub(pull_requests=[]) 165 wpt_github = MockWPTGitHub(pull_requests=[])
148 test_exporter = TestExporter(self.host, wpt_github) 166 test_exporter = TestExporter(self.host, wpt_github)
149 167
150 commits = test_exporter.exportable_commits_since('beefcafe') 168 commits = test_exporter.exportable_commits_since('beefcafe')
151 self.assertEqual(len(commits), 0) 169 self.assertEqual(len(commits), 0)
152 self.assertEqual(self.host.executive.calls, [ 170 self.assertEqual(self.host.executive.calls, [
171 ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web -platform-tests.git', '/tmp/wpt'],
153 ['git', 'rev-parse', '--show-toplevel'], 172 ['git', 'rev-parse', '--show-toplevel'],
154 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/t hird_party/WebKit/LayoutTests/imported/wpt/'], 173 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
155 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']]) 174 'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'],
175 ['git', 'diff-tree', '--name-only', '--no-commit-id', '-r', 'badbeef 8', '--',
176 '/mock-checkout/third_party/WebKit/LayoutTests/imported/wpt']])
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