| OLD | NEW |
| (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 from webkitpy.common.net.buildbot import Build |
| 6 from webkitpy.common.net.layouttestresults import LayoutTestResults |
| 7 from webkitpy.common.system.executive_mock import MockExecutive |
| 8 from webkitpy.layout_tests.builder_list import BuilderList |
| 9 from webkitpy.tool.commands.auto_rebaseline import AutoRebaseline |
| 10 from webkitpy.tool.commands.rebaseline_unittest import BaseTestCase |
| 11 from webkitpy.tool.commands.rebaseline_unittest import MockLineRemovingExecutive |
| 12 from webkitpy.tool.mock_tool import MockOptions |
| 13 |
| 14 |
| 15 class TestAutoRebaseline(BaseTestCase): |
| 16 command_constructor = AutoRebaseline |
| 17 |
| 18 def _write_test_file(self, port, path, contents): |
| 19 abs_path = self.tool.filesystem.join(port.layout_tests_dir(), path) |
| 20 self.tool.filesystem.write_text_file(abs_path, contents) |
| 21 |
| 22 def _execute_with_mock_options(self, auth_refresh_token_json=None, commit_au
thor=None, dry_run=False): |
| 23 self.command.execute( |
| 24 MockOptions(optimize=True, verbose=False, results_directory=False, |
| 25 auth_refresh_token_json=auth_refresh_token_json, |
| 26 commit_author=commit_author, dry_run=dry_run), |
| 27 [], self.tool) |
| 28 |
| 29 def setUp(self): |
| 30 super(TestAutoRebaseline, self).setUp() |
| 31 self.tool.builders = BuilderList({ |
| 32 "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": ["
Mac10.10", "Release"]}, |
| 33 "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": ["
Mac10.11", "Release"]}, |
| 34 "MOCK Precise": {"port_name": "test-linux-precise", "specifiers": ["
Precise", "Release"]}, |
| 35 "MOCK Trusty": {"port_name": "test-linux-trusty", "specifiers": ["Tr
usty", "Release"]}, |
| 36 "MOCK Win7": {"port_name": "test-win-win7", "specifiers": ["Win7", "
Release"]}, |
| 37 "MOCK Win7 (dbg)": {"port_name": "test-win-win7", "specifiers": ["Wi
n7", "Debug"]}, |
| 38 }) |
| 39 |
| 40 self.command.latest_revision_processed_on_all_bots = lambda: 9000 |
| 41 self.command.bot_revision_data = lambda scm: [{"builder": "MOCK Win7", "
revision": "9000"}] |
| 42 |
| 43 def test_release_builders(self): |
| 44 # Testing private method - pylint: disable=protected-access |
| 45 self.tool.builders = BuilderList({ |
| 46 "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": ["
Mac10.10", "Release"]}, |
| 47 "MOCK Mac10.11 (dbg)": {"port_name": "test-mac-mac10.11", "specifier
s": ["Mac10.11", "Debug"]}, |
| 48 "MOCK Mac10.11 ASAN": {"port_name": "test-mac-mac10.11", "specifiers
": ["Mac10.11", "Release"]}, |
| 49 }) |
| 50 self.assertEqual(self.command._release_builders(), ['MOCK Mac10.10']) |
| 51 |
| 52 def test_tests_to_rebaseline(self): |
| 53 def blame(_): |
| 54 return """ |
| 55 624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Debug ] path/to/norebaseline.
html [ Failure ] |
| 56 624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org@
bbb929c8-8fbe-4397-9dbb-9b2b20218538> 2013-06-14 20:18:46 +0000 11) crbug.com/
24182 [ Debug ] path/to/norebaseline-email-with-hash.html [ Failure ] |
| 57 624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-04-28 04:52:41 +0000 13) Bug(foo) path/to/rebaseline-without-bug-number.
html [ NeedsRebaseline ] |
| 58 624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Debug ] path/to/rebaseline-wi
th-modifiers.html [ NeedsRebaseline ] |
| 59 624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-04-28 04:52:41 +0000 12) crbug.com/24182 crbug.com/234 path/to/rebaselin
e-without-modifiers.html [ NeedsRebaseline ] |
| 60 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org@
bbb929c8-8fbe-4397-9dbb-9b2b20218538> 2013-04-28 04:52:41 +0000 12) crbug.com/
24182 path/to/rebaseline-new-revision.html [ NeedsRebaseline ] |
| 61 624caaaaaa path/to/TestExpectations (<foo@chromium.org>
2013-04-28 04:52:41 +0000 12) crbug.com/24182 path/to/not-cycled-through-bots
.html [ NeedsRebaseline ] |
| 62 0000000000 path/to/TestExpectations (<foo@chromium.org@@bbb929
c8-8fbe-4397-9dbb-9b2b20218538> 2013-04-28 04:52:41 +0000 12) crbug.com
/24182 path/to/locally-changed-lined.html [ NeedsRebaseline ] |
| 63 """ |
| 64 self.tool.scm().blame = blame |
| 65 |
| 66 min_revision = 9000 |
| 67 self.assertEqual(self.command.tests_to_rebaseline(self.tool, min_revisio
n, print_revisions=False), ( |
| 68 set(['path/to/rebaseline-without-bug-number.html', |
| 69 'path/to/rebaseline-with-modifiers.html', 'path/to/rebaseline-w
ithout-modifiers.html']), |
| 70 5678, |
| 71 '624c3081c0', |
| 72 'foobarbaz1@chromium.org', |
| 73 set(['24182', '234']), |
| 74 True)) |
| 75 |
| 76 def test_tests_to_rebaseline_over_limit(self): |
| 77 def blame(_): |
| 78 result = "" |
| 79 for i in range(0, self.command.MAX_LINES_TO_REBASELINE + 1): |
| 80 result += ("624c3081c0 path/to/TestExpectations
" |
| 81 "(<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000
13) " |
| 82 "crbug.com/24182 path/to/rebaseline-%s.html [ NeedsRe
baseline ]\n" % i) |
| 83 return result |
| 84 self.tool.scm().blame = blame |
| 85 |
| 86 expected_list_of_tests = [] |
| 87 for i in range(0, self.command.MAX_LINES_TO_REBASELINE): |
| 88 expected_list_of_tests.append("path/to/rebaseline-%s.html" % i) |
| 89 |
| 90 min_revision = 9000 |
| 91 self.assertEqual(self.command.tests_to_rebaseline(self.tool, min_revisio
n, print_revisions=False), ( |
| 92 set(expected_list_of_tests), |
| 93 5678, |
| 94 '624c3081c0', |
| 95 'foobarbaz1@chromium.org', |
| 96 set(['24182']), |
| 97 True)) |
| 98 |
| 99 def test_commit_message(self): |
| 100 author = "foo@chromium.org" |
| 101 revision = 1234 |
| 102 commit = "abcd567" |
| 103 bugs = set() |
| 104 self.assertEqual(self.command.commit_message(author, revision, commit, b
ugs), |
| 105 """Auto-rebaseline for r1234 |
| 106 |
| 107 https://chromium.googlesource.com/chromium/src/+/abcd567 |
| 108 |
| 109 TBR=foo@chromium.org |
| 110 """) |
| 111 |
| 112 bugs = set(["234", "345"]) |
| 113 self.assertEqual(self.command.commit_message(author, revision, commit, b
ugs), |
| 114 """Auto-rebaseline for r1234 |
| 115 |
| 116 https://chromium.googlesource.com/chromium/src/+/abcd567 |
| 117 |
| 118 BUG=234,345 |
| 119 TBR=foo@chromium.org |
| 120 """) |
| 121 |
| 122 def test_no_needs_rebaseline_lines(self): |
| 123 def blame(_): |
| 124 return """ |
| 125 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Debug ] path/to/norebaseline.
html [ Failure ] |
| 126 """ |
| 127 self.tool.scm().blame = blame |
| 128 |
| 129 self._execute_with_mock_options() |
| 130 self.assertEqual(self.tool.executive.calls, []) |
| 131 |
| 132 def test_execute(self): |
| 133 def blame(_): |
| 134 return """ |
| 135 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-06-14 20:18:46 +0000 11) # Test NeedsRebaseline being in a comment doesn
't bork parsing. |
| 136 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Debug ] path/to/norebaseline.
html [ Failure ] |
| 137 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRe
baseline ] |
| 138 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Mac10.11 ] fast/dom/prototype
-strawberry.html [ NeedsRebaseline ] |
| 139 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-04-28 04:52:41 +0000 12) crbug.com/24182 fast/dom/prototype-chocolate.ht
ml [ NeedsRebaseline ] |
| 140 624caaaaaa path/to/TestExpectations (<foo@chromium.org>
2013-04-28 04:52:41 +0000 12) crbug.com/24182 path/to/not-cycled-through-bots
.html [ NeedsRebaseline ] |
| 141 0000000000 path/to/TestExpectations (<foo@chromium.org>
2013-04-28 04:52:41 +0000 12) crbug.com/24182 path/to/locally-changed-lined.h
tml [ NeedsRebaseline ] |
| 142 """ |
| 143 self.tool.scm().blame = blame |
| 144 |
| 145 test_port = self.tool.port_factory.get('test') |
| 146 |
| 147 def build_data(): |
| 148 # Have prototype-chocolate only fail on "MOCK Mac10.11". |
| 149 self._build_data[Build('MOCK Mac10.11')] = LayoutTestResults({ |
| 150 "tests": { |
| 151 "fast": { |
| 152 "dom": { |
| 153 "prototype-taco.html": { |
| 154 "expected": "PASS", |
| 155 "actual": "PASS TEXT", |
| 156 "is_unexpected": True |
| 157 }, |
| 158 "prototype-chocolate.html": { |
| 159 "expected": "FAIL", |
| 160 "actual": "PASS" |
| 161 }, |
| 162 "prototype-strawberry.html": { |
| 163 "expected": "PASS", |
| 164 "actual": "IMAGE PASS", |
| 165 "is_unexpected": True |
| 166 } |
| 167 } |
| 168 } |
| 169 } |
| 170 }) |
| 171 return self._build_data |
| 172 |
| 173 self.command.build_data = build_data |
| 174 |
| 175 self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expe
ctations_file(), """ |
| 176 crbug.com/24182 [ Debug ] path/to/norebaseline.html [ Rebaseline ] |
| 177 Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ] |
| 178 crbug.com/24182 [ Mac10.11 ] fast/dom/prototype-strawberry.html [ NeedsRebaselin
e ] |
| 179 crbug.com/24182 fast/dom/prototype-chocolate.html [ NeedsRebaseline ] |
| 180 crbug.com/24182 path/to/not-cycled-through-bots.html [ NeedsRebaseline ] |
| 181 crbug.com/24182 path/to/locally-changed-lined.html [ NeedsRebaseline ] |
| 182 """) |
| 183 |
| 184 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy
test contents") |
| 185 self._write_test_file(test_port, 'fast/dom/prototype-strawberry.html', "
Dummy test contents") |
| 186 self._write_test_file(test_port, 'fast/dom/prototype-chocolate.html', "D
ummy test contents") |
| 187 |
| 188 self.tool.executive = MockLineRemovingExecutive() |
| 189 |
| 190 self.tool.builders = BuilderList({ |
| 191 "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": ["
Mac10.10", "Release"]}, |
| 192 "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": ["
Mac10.11", "Release"]}, |
| 193 }) |
| 194 |
| 195 self.command.tree_status = lambda: 'closed' |
| 196 self._execute_with_mock_options() |
| 197 self.assertEqual(self.tool.executive.calls, []) |
| 198 |
| 199 self.command.tree_status = lambda: 'open' |
| 200 self.tool.executive.calls = [] |
| 201 self._execute_with_mock_options() |
| 202 |
| 203 self.assertEqual(self.tool.executive.calls, [ |
| 204 [ |
| 205 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix
es', 'png', |
| 206 '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-str
awberry.html'], |
| 207 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix
es', 'txt', |
| 208 '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-tac
o.html'], |
| 209 ], |
| 210 [ |
| 211 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn
g', |
| 212 '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-str
awberry.html'], |
| 213 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', |
| 214 '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-tac
o.html'], |
| 215 ], |
| 216 [ |
| 217 ['python', 'echo', 'optimize-baselines', '--no-modify-scm', |
| 218 '--suffixes', 'png', 'fast/dom/prototype-strawberry.html'], |
| 219 ['python', 'echo', 'optimize-baselines', '--no-modify-scm', |
| 220 '--suffixes', 'txt', 'fast/dom/prototype-taco.html'], |
| 221 ], |
| 222 ['git', 'cl', 'upload', '-f'], |
| 223 ['git', 'pull'], |
| 224 ['git', 'cl', 'land', '-f', '-v'], |
| 225 ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietveldi
ssue'], |
| 226 ]) |
| 227 |
| 228 # The mac ports should both be removed since they're the only ones in bu
ilders._exact_matches. |
| 229 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_to_g
eneric_test_expectations_file()), """ |
| 230 crbug.com/24182 [ Debug ] path/to/norebaseline.html [ Rebaseline ] |
| 231 Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ NeedsRebaseline ] |
| 232 crbug.com/24182 [ Linux Win ] fast/dom/prototype-chocolate.html [ NeedsRebaselin
e ] |
| 233 crbug.com/24182 path/to/not-cycled-through-bots.html [ NeedsRebaseline ] |
| 234 crbug.com/24182 path/to/locally-changed-lined.html [ NeedsRebaseline ] |
| 235 """) |
| 236 |
| 237 def test_execute_git_cl_hangs(self): |
| 238 def blame(_): |
| 239 return """ |
| 240 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRe
baseline ] |
| 241 """ |
| 242 self.tool.scm().blame = blame |
| 243 |
| 244 test_port = self.tool.port_factory.get('test') |
| 245 |
| 246 original_build_data = self.command.build_data |
| 247 |
| 248 def build_data(): |
| 249 original_build_data() |
| 250 # Have prototype-chocolate only fail on "MOCK Mac10.11". |
| 251 self._build_data[Build('MOCK Mac10.11')] = LayoutTestResults({ |
| 252 "tests": { |
| 253 "fast": { |
| 254 "dom": { |
| 255 "prototype-taco.html": { |
| 256 "expected": "PASS", |
| 257 "actual": "PASS TEXT", |
| 258 "is_unexpected": True |
| 259 } |
| 260 } |
| 261 } |
| 262 } |
| 263 }) |
| 264 return self._build_data |
| 265 |
| 266 self.command.build_data = build_data |
| 267 |
| 268 self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expe
ctations_file(), """ |
| 269 Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ] |
| 270 """) |
| 271 |
| 272 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy
test contents") |
| 273 |
| 274 self.tool.builders = BuilderList({ |
| 275 "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": ["
Mac10.11", "Release"]}, |
| 276 }) |
| 277 |
| 278 self.command.SECONDS_BEFORE_GIVING_UP = 0 |
| 279 self.command.tree_status = lambda: 'open' |
| 280 self.tool.executive = MockExecutive() |
| 281 self.tool.executive.calls = [] |
| 282 self._execute_with_mock_options() |
| 283 |
| 284 self.assertEqual(self.tool.executive.calls, [ |
| 285 [ |
| 286 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix
es', 'txt', |
| 287 '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-tac
o.html'], |
| 288 ], |
| 289 [ |
| 290 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', |
| 291 '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-tac
o.html'], |
| 292 ], |
| 293 [['python', 'echo', 'optimize-baselines', '--no-modify-scm', '--suff
ixes', 'txt', 'fast/dom/prototype-taco.html']], |
| 294 ['git', 'cl', 'upload', '-f'], |
| 295 ]) |
| 296 |
| 297 def test_execute_test_passes_everywhere(self): |
| 298 def blame(_): |
| 299 return """ |
| 300 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRe
baseline ] |
| 301 """ |
| 302 self.tool.scm().blame = blame |
| 303 |
| 304 test_port = self.tool.port_factory.get('test') |
| 305 |
| 306 def build_data(): |
| 307 self._build_data[Build('MOCK Mac10.10')] = self._build_data[Build('M
OCK Mac10.11')] = LayoutTestResults({ |
| 308 "tests": { |
| 309 "fast": { |
| 310 "dom": { |
| 311 "prototype-taco.html": { |
| 312 "expected": "FAIL", |
| 313 "actual": "PASS", |
| 314 "is_unexpected": True |
| 315 } |
| 316 } |
| 317 } |
| 318 } |
| 319 }) |
| 320 return self._build_data |
| 321 |
| 322 self.command.build_data = build_data |
| 323 |
| 324 self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expe
ctations_file(), """ |
| 325 Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ] |
| 326 """) |
| 327 |
| 328 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy
test contents") |
| 329 |
| 330 self.tool.executive = MockLineRemovingExecutive() |
| 331 |
| 332 self.tool.builders = BuilderList({ |
| 333 "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": ["
Mac10.10", "Release"]}, |
| 334 "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": ["
Mac10.11", "Release"]}, |
| 335 }) |
| 336 |
| 337 self.command.tree_status = lambda: 'open' |
| 338 self._execute_with_mock_options() |
| 339 self.assertEqual(self.tool.executive.calls, [ |
| 340 ['git', 'cl', 'upload', '-f'], |
| 341 ['git', 'pull'], |
| 342 ['git', 'cl', 'land', '-f', '-v'], |
| 343 ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietveldi
ssue'], |
| 344 ]) |
| 345 |
| 346 # The mac ports should both be removed since they're the only ones in bu
ilders._exact_matches. |
| 347 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_to_g
eneric_test_expectations_file()), """ |
| 348 Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ NeedsRebaseline ] |
| 349 """) |
| 350 |
| 351 def test_execute_use_alternate_rebaseline_branch(self): |
| 352 def blame(_): |
| 353 return """ |
| 354 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRe
baseline ] |
| 355 """ |
| 356 self.tool.scm().blame = blame |
| 357 |
| 358 test_port = self.tool.port_factory.get('test') |
| 359 |
| 360 def build_data(): |
| 361 self._build_data[Build('MOCK Win')] = LayoutTestResults({ |
| 362 "tests": { |
| 363 "fast": { |
| 364 "dom": { |
| 365 "prototype-taco.html": { |
| 366 "expected": "FAIL", |
| 367 "actual": "PASS", |
| 368 "is_unexpected": True |
| 369 } |
| 370 } |
| 371 } |
| 372 } |
| 373 }) |
| 374 return self._build_data |
| 375 |
| 376 self.command.build_data = build_data |
| 377 |
| 378 self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expe
ctations_file(), """ |
| 379 Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ] |
| 380 """) |
| 381 |
| 382 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy
test contents") |
| 383 |
| 384 self.tool.executive = MockLineRemovingExecutive() |
| 385 |
| 386 self.tool.builders = BuilderList({ |
| 387 "MOCK Win7": {"port_name": "test-win-win7", "specifiers": ["Win7", "
Release"]}, |
| 388 }) |
| 389 old_branch_name = self.tool.scm().current_branch_or_ref |
| 390 try: |
| 391 self.command.tree_status = lambda: 'open' |
| 392 self.tool.scm().current_branch_or_ref = lambda: 'auto-rebaseline-tem
porary-branch' |
| 393 self._execute_with_mock_options() |
| 394 self.assertEqual(self.tool.executive.calls, [ |
| 395 ['git', 'cl', 'upload', '-f'], |
| 396 ['git', 'pull'], |
| 397 ['git', 'cl', 'land', '-f', '-v'], |
| 398 ['git', 'config', 'branch.auto-rebaseline-alt-temporary-branch.r
ietveldissue'], |
| 399 ]) |
| 400 |
| 401 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_
to_generic_test_expectations_file()), """ |
| 402 Bug(foo) [ Linux Mac Win10 ] fast/dom/prototype-taco.html [ NeedsRebaseline ] |
| 403 """) |
| 404 finally: |
| 405 self.tool.scm().current_branch_or_ref = old_branch_name |
| 406 |
| 407 def test_execute_stuck_on_alternate_rebaseline_branch(self): |
| 408 def blame(_): |
| 409 return """ |
| 410 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRe
baseline ] |
| 411 """ |
| 412 self.tool.scm().blame = blame |
| 413 |
| 414 test_port = self.tool.port_factory.get('test') |
| 415 |
| 416 def build_data(): |
| 417 self._build_data[Build('MOCK Win')] = LayoutTestResults({ |
| 418 "tests": { |
| 419 "fast": { |
| 420 "dom": { |
| 421 "prototype-taco.html": { |
| 422 "expected": "FAIL", |
| 423 "actual": "PASS", |
| 424 "is_unexpected": True |
| 425 } |
| 426 } |
| 427 } |
| 428 } |
| 429 }) |
| 430 return self._build_data |
| 431 |
| 432 self.command.build_data = build_data |
| 433 |
| 434 self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expe
ctations_file(), """ |
| 435 Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ] |
| 436 """) |
| 437 |
| 438 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy
test contents") |
| 439 |
| 440 self.tool.executive = MockLineRemovingExecutive() |
| 441 |
| 442 self.tool.builders = BuilderList({ |
| 443 "MOCK Win7": {"port_name": "test-win-win7", "specifiers": ["Win7", "
Release"]}, |
| 444 }) |
| 445 |
| 446 old_branch_name = self.tool.scm().current_branch_or_ref |
| 447 try: |
| 448 self.command.tree_status = lambda: 'open' |
| 449 self.tool.scm().current_branch_or_ref = lambda: 'auto-rebaseline-alt
-temporary-branch' |
| 450 self._execute_with_mock_options() |
| 451 self.assertEqual(self.tool.executive.calls, [ |
| 452 ['git', 'cl', 'upload', '-f'], |
| 453 ['git', 'pull'], |
| 454 ['git', 'cl', 'land', '-f', '-v'], |
| 455 ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietv
eldissue'], |
| 456 ]) |
| 457 |
| 458 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_
to_generic_test_expectations_file()), """ |
| 459 Bug(foo) [ Linux Mac Win10 ] fast/dom/prototype-taco.html [ NeedsRebaseline ] |
| 460 """) |
| 461 finally: |
| 462 self.tool.scm().current_branch_or_ref = old_branch_name |
| 463 |
| 464 def _basic_execute_test(self, expected_executive_calls, auth_refresh_token_j
son=None, commit_author=None, dry_run=False): |
| 465 def blame(_): |
| 466 return """ |
| 467 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org>
2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRe
baseline ] |
| 468 """ |
| 469 self.tool.scm().blame = blame |
| 470 |
| 471 test_port = self.tool.port_factory.get('test') |
| 472 |
| 473 def build_data(): |
| 474 self._build_data[Build('MOCK Mac10.10')] = self._build_data[Build('M
OCK Mac10.11')] = LayoutTestResults({ |
| 475 "tests": { |
| 476 "fast": { |
| 477 "dom": { |
| 478 "prototype-taco.html": { |
| 479 "expected": "FAIL", |
| 480 "actual": "PASS", |
| 481 "is_unexpected": True |
| 482 } |
| 483 } |
| 484 } |
| 485 } |
| 486 }) |
| 487 return self._build_data |
| 488 |
| 489 self.command.build_data = build_data |
| 490 |
| 491 self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expe
ctations_file(), """ |
| 492 Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ] |
| 493 """) |
| 494 |
| 495 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy
test contents") |
| 496 |
| 497 self.tool.executive = MockLineRemovingExecutive() |
| 498 |
| 499 self.tool.builders = BuilderList({ |
| 500 "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": ["
Mac10.10", "Release"]}, |
| 501 "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": ["
Mac10.11", "Release"]}, |
| 502 }) |
| 503 |
| 504 self.command.tree_status = lambda: 'open' |
| 505 self._execute_with_mock_options(auth_refresh_token_json=auth_refresh_tok
en_json, |
| 506 commit_author=commit_author, dry_run=dry
_run) |
| 507 self.assertEqual(self.tool.executive.calls, expected_executive_calls) |
| 508 |
| 509 # The mac ports should both be removed since they're the only ones in bu
ilders._exact_matches. |
| 510 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_to_g
eneric_test_expectations_file()), """ |
| 511 Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ NeedsRebaseline ] |
| 512 """) |
| 513 |
| 514 def test_execute_with_rietveld_auth_refresh_token(self): |
| 515 rietveld_refresh_token = '/creds/refresh_tokens/test_rietveld_token' |
| 516 self._basic_execute_test( |
| 517 [ |
| 518 ['git', 'cl', 'upload', '-f', '--auth-refresh-token-json', rietv
eld_refresh_token], |
| 519 ['git', 'pull'], |
| 520 ['git', 'cl', 'land', '-f', '-v', '--auth-refresh-token-json', r
ietveld_refresh_token], |
| 521 ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietv
eldissue'], |
| 522 ], |
| 523 auth_refresh_token_json=rietveld_refresh_token) |
| 524 |
| 525 def test_execute_with_dry_run(self): |
| 526 self._basic_execute_test([], dry_run=True) |
| 527 self.assertEqual(self.tool.scm().local_commits(), []) |
| 528 |
| 529 def test_bot_revision_data(self): |
| 530 self._setup_mock_build_data() |
| 531 self.assertEqual( |
| 532 self.command.bot_revision_data(self.tool.scm()), |
| 533 [{'builder': 'MOCK Win7', 'revision': '9000'}]) |
| OLD | NEW |