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

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py

Issue 2191423003: Extract AutoRebaseline out of rebaseline.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py
index 355b47097313712fa4250a4a0411e7578688138e..8031248894b79051bdff14e3efd63cea956ccb4f 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py
@@ -5,11 +5,17 @@
import unittest
from webkitpy.common.net.layouttestresults import LayoutTestResults
+from webkitpy.common.net.rietveld import Build
from webkitpy.common.system.executive_mock import MockExecutive
from webkitpy.common.system.executive_mock import MockExecutive2
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.layout_tests.builder_list import BuilderList
-from webkitpy.tool.commands.rebaseline import *
+from webkitpy.tool.commands.rebaseline import CopyExistingBaselinesInternal
+from webkitpy.tool.commands.rebaseline import RebaselineExpectations
+from webkitpy.tool.commands.rebaseline import Rebaseline
+from webkitpy.tool.commands.rebaseline import RebaselineJson
+from webkitpy.tool.commands.rebaseline import RebaselineTest
+from webkitpy.tool.commands.rebaseline import AbstractParallelRebaselineCommand
from webkitpy.tool.mock_tool import MockWebKitPatch, MockOptions
@@ -253,7 +259,6 @@ Bug(A) [ Debug ] : fast/css/large-list-of-rules-crash.html [ Failure ]
self.options.suffixes = "png,wav,txt"
self.command._rebaseline_test_and_update_expectations(self.options)
- self.maxDiff = None
self.assertItemsEqual(self.tool.web.urls_fetched,
[self.WEB_PREFIX + '/userscripts/another-test-actual.png',
self.WEB_PREFIX + '/userscripts/another-test-actual.wav',
@@ -572,24 +577,6 @@ class TestRebaseline(BaseTestCase):
])
-class MockLineRemovingExecutive(MockExecutive):
-
- def run_in_parallel(self, commands):
- assert len(commands)
-
- num_previous_calls = len(self.calls)
- command_outputs = []
- for cmd_line, cwd in commands:
- out = self.run_command(cmd_line, cwd=cwd)
- if 'rebaseline-test-internal' in cmd_line:
- out = '{"add": [], "remove-lines": [{"test": "%s", "builder": "%s"}], "delete": []}\n' % (cmd_line[8], cmd_line[6])
- command_outputs.append([0, out, ''])
-
- new_calls = self.calls[num_previous_calls:]
- self.calls = self.calls[:num_previous_calls]
- self.calls.append(new_calls)
- return command_outputs
-
class TestRebaselineExpectations(BaseTestCase):
command_constructor = RebaselineExpectations
@@ -855,519 +842,20 @@ Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ Rebaseline ]
])
-class TestAutoRebaseline(BaseTestCase):
- command_constructor = AutoRebaseline
-
- def _write_test_file(self, port, path, contents):
- abs_path = self.tool.filesystem.join(port.layout_tests_dir(), path)
- self.tool.filesystem.write_text_file(abs_path, contents)
-
- def _execute_command_with_mock_options(self, auth_refresh_token_json=None, commit_author=None, dry_run=False):
- self.command.execute(
- MockOptions(optimize=True, verbose=False, results_directory=False,
- auth_refresh_token_json=auth_refresh_token_json,
- commit_author=commit_author, dry_run=dry_run),
- [], self.tool)
-
- def setUp(self):
- super(TestAutoRebaseline, self).setUp()
- self.tool.builders = BuilderList({
- "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": ["Mac10.10", "Release"]},
- "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": ["Mac10.11", "Release"]},
- "MOCK Precise": {"port_name": "test-linux-precise", "specifiers": ["Precise", "Release"]},
- "MOCK Trusty": {"port_name": "test-linux-trusty", "specifiers": ["Trusty", "Release"]},
- "MOCK Win7": {"port_name": "test-win-win7", "specifiers": ["Win7", "Release"]},
- "MOCK Win7 (dbg)": {"port_name": "test-win-win7", "specifiers": ["Win7", "Debug"]},
- })
-
- self.command.latest_revision_processed_on_all_bots = lambda: 9000
- self.command.bot_revision_data = lambda scm: [{"builder": "MOCK Win7", "revision": "9000"}]
-
- def test_release_builders(self):
- self.tool.builders = BuilderList({
- "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": ["Mac10.10", "Release"]},
- "MOCK Mac10.11 (dbg)": {"port_name": "test-mac-mac10.11", "specifiers": ["Mac10.11", "Debug"]},
- "MOCK Mac10.11 ASAN": {"port_name": "test-mac-mac10.11", "specifiers": ["Mac10.11", "Release"]},
- })
- self.assertEqual(self.command._release_builders(), ['MOCK Mac10.10'])
-
- def test_tests_to_rebaseline(self):
- def blame(_):
- return """
-624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Debug ] path/to/norebaseline.html [ Failure ]
-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 ]
-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 ]
-624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Debug ] path/to/rebaseline-with-modifiers.html [ NeedsRebaseline ]
-624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 12) crbug.com/24182 crbug.com/234 path/to/rebaseline-without-modifiers.html [ NeedsRebaseline ]
-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 ]
-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 ]
-0000000000 path/to/TestExpectations (<foo@chromium.org@@bbb929c8-8fbe-4397-9dbb-9b2b20218538> 2013-04-28 04:52:41 +0000 12) crbug.com/24182 path/to/locally-changed-lined.html [ NeedsRebaseline ]
-"""
- self.tool.scm().blame = blame
-
- min_revision = 9000
- self.assertEqual(self.command.tests_to_rebaseline(self.tool, min_revision, print_revisions=False), (
- set(['path/to/rebaseline-without-bug-number.html',
- 'path/to/rebaseline-with-modifiers.html', 'path/to/rebaseline-without-modifiers.html']),
- 5678,
- '624c3081c0',
- 'foobarbaz1@chromium.org',
- set(['24182', '234']),
- True))
-
- def test_tests_to_rebaseline_over_limit(self):
- def blame(_):
- result = ""
- for i in range(0, self.command.MAX_LINES_TO_REBASELINE + 1):
- result += "624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) crbug.com/24182 path/to/rebaseline-%s.html [ NeedsRebaseline ]\n" % i
- return result
- self.tool.scm().blame = blame
-
- expected_list_of_tests = []
- for i in range(0, self.command.MAX_LINES_TO_REBASELINE):
- expected_list_of_tests.append("path/to/rebaseline-%s.html" % i)
-
- min_revision = 9000
- self.assertEqual(self.command.tests_to_rebaseline(self.tool, min_revision, print_revisions=False), (
- set(expected_list_of_tests),
- 5678,
- '624c3081c0',
- 'foobarbaz1@chromium.org',
- set(['24182']),
- True))
-
- def test_commit_message(self):
- author = "foo@chromium.org"
- revision = 1234
- commit = "abcd567"
- bugs = set()
- self.assertEqual(self.command.commit_message(author, revision, commit, bugs),
- """Auto-rebaseline for r1234
-
-https://chromium.googlesource.com/chromium/src/+/abcd567
-
-TBR=foo@chromium.org
-""")
-
- bugs = set(["234", "345"])
- self.assertEqual(self.command.commit_message(author, revision, commit, bugs),
- """Auto-rebaseline for r1234
-
-https://chromium.googlesource.com/chromium/src/+/abcd567
-
-BUG=234,345
-TBR=foo@chromium.org
-""")
-
- def test_no_needs_rebaseline_lines(self):
- def blame(_):
- return """
-6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Debug ] path/to/norebaseline.html [ Failure ]
-"""
- self.tool.scm().blame = blame
-
- self._execute_command_with_mock_options()
- self.assertEqual(self.tool.executive.calls, [])
-
- def test_execute(self):
- def blame(_):
- return """
-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.
-6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Debug ] path/to/norebaseline.html [ Failure ]
-6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
-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 ]
-6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 12) crbug.com/24182 fast/dom/prototype-chocolate.html [ NeedsRebaseline ]
-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 ]
-0000000000 path/to/TestExpectations (<foo@chromium.org> 2013-04-28 04:52:41 +0000 12) crbug.com/24182 path/to/locally-changed-lined.html [ NeedsRebaseline ]
-"""
- self.tool.scm().blame = blame
-
- test_port = self.tool.port_factory.get('test')
-
- def build_data():
- # Have prototype-chocolate only fail on "MOCK Mac10.11".
- self._build_data[Build('MOCK Mac10.11')] = LayoutTestResults({
- "tests": {
- "fast": {
- "dom": {
- "prototype-taco.html": {
- "expected": "PASS",
- "actual": "PASS TEXT",
- "is_unexpected": True
- },
- "prototype-chocolate.html": {
- "expected": "FAIL",
- "actual": "PASS"
- },
- "prototype-strawberry.html": {
- "expected": "PASS",
- "actual": "IMAGE PASS",
- "is_unexpected": True
- }
- }
- }
- }
- })
- return self._build_data
-
- self.command.build_data = build_data
-
- self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expectations_file(), """
-crbug.com/24182 [ Debug ] path/to/norebaseline.html [ Rebaseline ]
-Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
-crbug.com/24182 [ Mac10.11 ] fast/dom/prototype-strawberry.html [ NeedsRebaseline ]
-crbug.com/24182 fast/dom/prototype-chocolate.html [ NeedsRebaseline ]
-crbug.com/24182 path/to/not-cycled-through-bots.html [ NeedsRebaseline ]
-crbug.com/24182 path/to/locally-changed-lined.html [ NeedsRebaseline ]
-""")
-
- self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy test contents")
- self._write_test_file(test_port, 'fast/dom/prototype-strawberry.html', "Dummy test contents")
- self._write_test_file(test_port, 'fast/dom/prototype-chocolate.html', "Dummy test contents")
-
- self.tool.executive = MockLineRemovingExecutive()
-
- self.tool.builders = BuilderList({
- "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": ["Mac10.10", "Release"]},
- "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": ["Mac10.11", "Release"]},
- })
-
- self.command.tree_status = lambda: 'closed'
- self._execute_command_with_mock_options()
- self.assertEqual(self.tool.executive.calls, [])
-
- self.command.tree_status = lambda: 'open'
- self.tool.executive.calls = []
- self._execute_command_with_mock_options()
-
- self.assertEqual(self.tool.executive.calls, [
- [
- ['python', 'echo', 'copy-existing-baselines-internal', '--suffixes', 'png',
- '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-strawberry.html'],
- ['python', 'echo', 'copy-existing-baselines-internal', '--suffixes', 'txt',
- '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-taco.html'],
- ],
- [
- ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'png',
- '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-strawberry.html'],
- ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'txt',
- '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-taco.html'],
- ],
- [
- ['python', 'echo', 'optimize-baselines', '--no-modify-scm',
- '--suffixes', 'png', 'fast/dom/prototype-strawberry.html'],
- ['python', 'echo', 'optimize-baselines', '--no-modify-scm',
- '--suffixes', 'txt', 'fast/dom/prototype-taco.html'],
- ],
- ['git', 'cl', 'upload', '-f'],
- ['git', 'pull'],
- ['git', 'cl', 'land', '-f', '-v'],
- ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietveldissue'],
- ])
-
- # The mac ports should both be removed since they're the only ones in builders._exact_matches.
- self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_to_generic_test_expectations_file()), """
-crbug.com/24182 [ Debug ] path/to/norebaseline.html [ Rebaseline ]
-Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ NeedsRebaseline ]
-crbug.com/24182 [ Linux Win ] fast/dom/prototype-chocolate.html [ NeedsRebaseline ]
-crbug.com/24182 path/to/not-cycled-through-bots.html [ NeedsRebaseline ]
-crbug.com/24182 path/to/locally-changed-lined.html [ NeedsRebaseline ]
-""")
-
- def test_execute_git_cl_hangs(self):
- def blame(_):
- return """
-6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
-"""
- self.tool.scm().blame = blame
-
- test_port = self.tool.port_factory.get('test')
-
- original_build_data = self.command.build_data
-
- def build_data():
- original_build_data()
- # Have prototype-chocolate only fail on "MOCK Mac10.11".
- self._build_data[Build('MOCK Mac10.11')] = LayoutTestResults({
- "tests": {
- "fast": {
- "dom": {
- "prototype-taco.html": {
- "expected": "PASS",
- "actual": "PASS TEXT",
- "is_unexpected": True
- }
- }
- }
- }
- })
- return self._build_data
-
- self.command.build_data = build_data
-
- self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expectations_file(), """
-Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
-""")
-
- self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy test contents")
-
- self.tool.builders = BuilderList({
- "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": ["Mac10.11", "Release"]},
- })
-
- self.command.SECONDS_BEFORE_GIVING_UP = 0
- self.command.tree_status = lambda: 'open'
- self.tool.executive = MockExecutive()
- self.tool.executive.calls = []
- self._execute_command_with_mock_options()
-
- self.assertEqual(self.tool.executive.calls, [
- [
- ['python', 'echo', 'copy-existing-baselines-internal', '--suffixes', 'txt',
- '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-taco.html'],
- ],
- [
- ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'txt',
- '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-taco.html'],
- ],
- [['python', 'echo', 'optimize-baselines', '--no-modify-scm', '--suffixes', 'txt', 'fast/dom/prototype-taco.html']],
- ['git', 'cl', 'upload', '-f'],
- ])
-
- def test_execute_test_passes_everywhere(self):
- def blame(_):
- return """
-6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
-"""
- self.tool.scm().blame = blame
-
- test_port = self.tool.port_factory.get('test')
-
- def build_data():
- self._build_data[Build('MOCK Mac10.10')] = self._build_data[Build('MOCK Mac10.11')] = LayoutTestResults({
- "tests": {
- "fast": {
- "dom": {
- "prototype-taco.html": {
- "expected": "FAIL",
- "actual": "PASS",
- "is_unexpected": True
- }
- }
- }
- }
- })
- return self._build_data
-
- self.command.build_data = build_data
-
- self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expectations_file(), """
-Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
-""")
-
- self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy test contents")
-
- self.tool.executive = MockLineRemovingExecutive()
-
- self.tool.builders = BuilderList({
- "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": ["Mac10.10", "Release"]},
- "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": ["Mac10.11", "Release"]},
- })
-
- self.command.tree_status = lambda: 'open'
- self._execute_command_with_mock_options()
- self.assertEqual(self.tool.executive.calls, [
- ['git', 'cl', 'upload', '-f'],
- ['git', 'pull'],
- ['git', 'cl', 'land', '-f', '-v'],
- ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietveldissue'],
- ])
-
- # The mac ports should both be removed since they're the only ones in builders._exact_matches.
- self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_to_generic_test_expectations_file()), """
-Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ NeedsRebaseline ]
-""")
-
- def test_execute_use_alternate_rebaseline_branch(self):
- def blame(_):
- return """
-6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
-"""
- self.tool.scm().blame = blame
-
- test_port = self.tool.port_factory.get('test')
-
- def build_data():
- self._build_data[Build('MOCK Win')] = LayoutTestResults({
- "tests": {
- "fast": {
- "dom": {
- "prototype-taco.html": {
- "expected": "FAIL",
- "actual": "PASS",
- "is_unexpected": True
- }
- }
- }
- }
- })
- return self._build_data
-
- self.command.build_data = build_data
-
- self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expectations_file(), """
-Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
-""")
-
- self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy test contents")
-
- self.tool.executive = MockLineRemovingExecutive()
-
- self.tool.builders = BuilderList({
- "MOCK Win7": {"port_name": "test-win-win7", "specifiers": ["Win7", "Release"]},
- })
- old_branch_name = self.tool.scm().current_branch_or_ref
- try:
- self.command.tree_status = lambda: 'open'
- self.tool.scm().current_branch_or_ref = lambda: 'auto-rebaseline-temporary-branch'
- self._execute_command_with_mock_options()
- self.assertEqual(self.tool.executive.calls, [
- ['git', 'cl', 'upload', '-f'],
- ['git', 'pull'],
- ['git', 'cl', 'land', '-f', '-v'],
- ['git', 'config', 'branch.auto-rebaseline-alt-temporary-branch.rietveldissue'],
- ])
-
- self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_to_generic_test_expectations_file()), """
-Bug(foo) [ Linux Mac Win10 ] fast/dom/prototype-taco.html [ NeedsRebaseline ]
-""")
- finally:
- self.tool.scm().current_branch_or_ref = old_branch_name
-
- def test_execute_stuck_on_alternate_rebaseline_branch(self):
- def blame(_):
- return """
-6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
-"""
- self.tool.scm().blame = blame
-
- test_port = self.tool.port_factory.get('test')
-
- def build_data():
- self._build_data[Build('MOCK Win')] = LayoutTestResults({
- "tests": {
- "fast": {
- "dom": {
- "prototype-taco.html": {
- "expected": "FAIL",
- "actual": "PASS",
- "is_unexpected": True
- }
- }
- }
- }
- })
- return self._build_data
-
- self.command.build_data = build_data
-
- self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expectations_file(), """
-Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
-""")
-
- self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy test contents")
-
- self.tool.executive = MockLineRemovingExecutive()
-
- self.tool.builders = BuilderList({
- "MOCK Win7": {"port_name": "test-win-win7", "specifiers": ["Win7", "Release"]},
- })
-
- old_branch_name = self.tool.scm().current_branch_or_ref
- try:
- self.command.tree_status = lambda: 'open'
- self.tool.scm().current_branch_or_ref = lambda: 'auto-rebaseline-alt-temporary-branch'
- self._execute_command_with_mock_options()
- self.assertEqual(self.tool.executive.calls, [
- ['git', 'cl', 'upload', '-f'],
- ['git', 'pull'],
- ['git', 'cl', 'land', '-f', '-v'],
- ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietveldissue'],
- ])
-
- self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_to_generic_test_expectations_file()), """
-Bug(foo) [ Linux Mac Win10 ] fast/dom/prototype-taco.html [ NeedsRebaseline ]
-""")
- finally:
- self.tool.scm().current_branch_or_ref = old_branch_name
-
- def _basic_execute_test(self, expected_executive_calls, auth_refresh_token_json=None, commit_author=None, dry_run=False):
- def blame(_):
- return """
-6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
-"""
- self.tool.scm().blame = blame
-
- test_port = self.tool.port_factory.get('test')
-
- def build_data():
- self._build_data[Build('MOCK Mac10.10')] = self._build_data[Build('MOCK Mac10.11')] = LayoutTestResults({
- "tests": {
- "fast": {
- "dom": {
- "prototype-taco.html": {
- "expected": "FAIL",
- "actual": "PASS",
- "is_unexpected": True
- }
- }
- }
- }
- })
- return self._build_data
-
- self.command.build_data = build_data
-
- self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expectations_file(), """
-Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
-""")
-
- self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy test contents")
-
- self.tool.executive = MockLineRemovingExecutive()
-
- self.tool.builders = BuilderList({
- "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": ["Mac10.10", "Release"]},
- "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": ["Mac10.11", "Release"]},
- })
-
- self.command.tree_status = lambda: 'open'
- self._execute_command_with_mock_options(auth_refresh_token_json=auth_refresh_token_json,
- commit_author=commit_author, dry_run=dry_run)
- self.assertEqual(self.tool.executive.calls, expected_executive_calls)
-
- # The mac ports should both be removed since they're the only ones in builders._exact_matches.
- self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_to_generic_test_expectations_file()), """
-Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ NeedsRebaseline ]
-""")
+class MockLineRemovingExecutive(MockExecutive):
- def test_execute_with_rietveld_auth_refresh_token(self):
- RIETVELD_REFRESH_TOKEN = '/creds/refresh_tokens/test_rietveld_token'
- self._basic_execute_test(
- [
- ['git', 'cl', 'upload', '-f', '--auth-refresh-token-json', RIETVELD_REFRESH_TOKEN],
- ['git', 'pull'],
- ['git', 'cl', 'land', '-f', '-v', '--auth-refresh-token-json', RIETVELD_REFRESH_TOKEN],
- ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietveldissue'],
- ],
- auth_refresh_token_json=RIETVELD_REFRESH_TOKEN)
+ def run_in_parallel(self, commands):
+ assert len(commands)
- def test_execute_with_dry_run(self):
- self._basic_execute_test([], dry_run=True)
- self.assertEqual(self.tool.scm().local_commits(), [])
+ num_previous_calls = len(self.calls)
+ command_outputs = []
+ for cmd_line, cwd in commands:
+ out = self.run_command(cmd_line, cwd=cwd)
+ if 'rebaseline-test-internal' in cmd_line:
+ out = '{"add": [], "remove-lines": [{"test": "%s", "builder": "%s"}], "delete": []}\n' % (cmd_line[8], cmd_line[6])
+ command_outputs.append([0, out, ''])
- def test_bot_revision_data(self):
- self._setup_mock_build_data()
- self.assertEqual(
- self.command.bot_revision_data(self.tool.scm()),
- [{'builder': 'MOCK Win7', 'revision': '9000'}])
+ new_calls = self.calls[num_previous_calls:]
+ self.calls = self.calls[:num_previous_calls]
+ self.calls.append(new_calls)
+ return command_outputs

Powered by Google App Engine
This is Rietveld 408576698