def test_execute_stuck_on_alternate_rebaseline_branch(self): def blame(_): return """ 6469e754a1 path/to/TestExpectations (<*****@*****.**> 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') self.tool.buildbot.set_results(Build('MOCK Win7'), LayoutTestResults({ "tests": { "fast": { "dom": { "prototype-taco.html": { "expected": "FAIL", "actual": "PASS", "is_unexpected": True } } } } })) 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_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'], ['git', 'cl', 'set_close'], ]) 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_test_passes_everywhere(self): def blame(_): return """ 6469e754a1 path/to/TestExpectations (<*****@*****.**> 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') for builder in ['MOCK Mac10.10', 'MOCK Mac10.11']: self.tool.buildbot.set_results(Build(builder), LayoutTestResults({ "tests": { "fast": { "dom": { "prototype-taco.html": { "expected": "FAIL", "actual": "PASS", "is_unexpected": True } } } } })) 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_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'], ['git', 'cl', 'set_close'], ]) # 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 _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 (<*****@*****.**> 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') for builder in ['MOCK Mac10.10', 'MOCK Mac10.11']: self.tool.buildbot.set_results(Build(builder), LayoutTestResults({ "tests": { "fast": { "dom": { "prototype-taco.html": { "expected": "FAIL", "actual": "PASS", "is_unexpected": True } } } } })) 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_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 ] """)
def test_execute(self): def blame(_): return """ 6469e754a1 path/to/TestExpectations (<*****@*****.**> 2013-06-14 20:18:46 +0000 11) # Test NeedsRebaseline being in a comment doesn't bork parsing. 6469e754a1 path/to/TestExpectations (<*****@*****.**> 2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Debug ] path/to/norebaseline.html [ Failure ] 6469e754a1 path/to/TestExpectations (<*****@*****.**> 2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ] 6469e754a1 path/to/TestExpectations (<*****@*****.**> 2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Mac10.11 ] fast/dom/prototype-strawberry.html [ NeedsRebaseline ] 6469e754a1 path/to/TestExpectations (<*****@*****.**> 2013-04-28 04:52:41 +0000 12) crbug.com/24182 fast/dom/prototype-chocolate.html [ NeedsRebaseline ] 624caaaaaa path/to/TestExpectations (<*****@*****.**> 2013-04-28 04:52:41 +0000 12) crbug.com/24182 path/to/not-cycled-through-bots.html [ NeedsRebaseline ] 0000000000 path/to/TestExpectations (<*****@*****.**> 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') # Have prototype-chocolate only fail on "MOCK Mac10.11", # and pass on "Mock Mac10.10". self.tool.buildbot.set_results( 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 } } } } })) self.tool.buildbot.set_results( Build('MOCK Mac10.10'), LayoutTestResults({ "tests": { "fast": { "dom": { "prototype-taco.html": { "expected": "PASS", "actual": "PASS", }, "prototype-chocolate.html": { "expected": "FAIL", "actual": "FAIL" }, "prototype-strawberry.html": { "expected": "PASS", "actual": "PASS", } } } } })) 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_with_mock_options() self.assertEqual(self.tool.executive.calls, []) self.command.tree_status = lambda: 'open' self.tool.executive.calls = [] self._execute_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', '--suffixes', 'png', 'fast/dom/prototype-strawberry.html' ], [ 'python', 'echo', 'optimize-baselines', '--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 ] """)