1 # Copyright (C) 2010 Google Inc. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 from webkitpy.common.system.outputcapture import OutputCapture
32 from webkitpy.thirdparty.mock import Mock
33 from webkitpy.tool.commands.rebaseline import *
34 from webkitpy.tool.mocktool import MockTool
35 from webkitpy.common.system.executive_mock import MockExecutive
38 class TestRebaseline(unittest.TestCase):
39 def test_tests_to_update(self):
40 command = Rebaseline()
41 command.bind_to_tool(MockTool())
43 OutputCapture().assert_outputs(self, command._tests_to_update, [build])
45 def test_rebaseline_test(self):
46 command = RebaselineTest()
47 command.bind_to_tool(MockTool())
48 expected_stdout = "Retrieving http://example.com/f/builders/Webkit Linux/results/layout-test-results/userscripts/another-test-actual.txt.\n"
49 OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Linux", "userscripts/another-test.html", "txt"], expected_stdout=expected_stdout)
51 def test_rebaseline_expectations(self):
52 command = RebaselineExpectations()
54 command.bind_to_tool(tool)
56 for port_name in tool.port_factory.all_port_names():
57 port = tool.port_factory.get(port_name)
58 tool.filesystem.write_text_file(port.path_to_test_expectations_file(), '')
60 # Don't enable logging until after we create the mock expectation files as some Port.__init__'s run subcommands.
61 tool.executive = MockExecutive(should_log=True)
63 expected_stdout = """Retrieving results for chromium-cg-mac-leopard from Webkit Mac10.5 (CG).
64 userscripts/another-test.html
65 userscripts/images.svg
66 Retrieving results for chromium-cg-mac-snowleopard from Webkit Mac10.6 (CG).
67 userscripts/another-test.html
68 userscripts/images.svg
69 Retrieving results for chromium-gpu-cg-mac-leopard from Webkit Mac10.5 (CG) - GPU.
70 Retrieving results for chromium-gpu-cg-mac-snowleopard from Webkit Mac10.6 (CG) - GPU.
71 Retrieving results for chromium-gpu-mac-snowleopard from Webkit Mac10.6 - GPU.
72 Retrieving results for chromium-gpu-win-win7 from Webkit Win7 - GPU.
73 Retrieving results for chromium-gpu-win-xp from Webkit Win - GPU.
74 Retrieving results for chromium-linux-x86 from Webkit Linux 32.
75 userscripts/another-test.html
76 userscripts/images.svg
77 Retrieving results for chromium-linux-x86_64 from Webkit Linux.
78 userscripts/another-test.html
79 userscripts/images.svg
80 Retrieving results for chromium-mac-leopard from Webkit Mac10.5.
81 userscripts/another-test.html
82 userscripts/images.svg
83 Retrieving results for chromium-mac-snowleopard from Webkit Mac10.6.
84 userscripts/another-test.html
85 userscripts/images.svg
86 Retrieving results for chromium-win-vista from Webkit Vista.
87 userscripts/another-test.html
88 userscripts/images.svg
89 Retrieving results for chromium-win-win7 from Webkit Win7.
90 userscripts/another-test.html
91 userscripts/images.svg
92 Retrieving results for chromium-win-xp from Webkit Win.
93 userscripts/another-test.html
94 userscripts/images.svg
95 Optimizing baselines for userscripts/another-test.html.
96 Optimizing baselines for userscripts/images.svg.
98 expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5 (CG)', 'userscripts/another-test.html'], cwd=/mock-checkout
99 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5 (CG)', 'userscripts/images.svg'], cwd=/mock-checkout
100 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6 (CG)', 'userscripts/another-test.html'], cwd=/mock-checkout
101 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6 (CG)', 'userscripts/images.svg'], cwd=/mock-checkout
102 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/another-test.html'], cwd=/mock-checkout
103 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/images.svg'], cwd=/mock-checkout
104 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/another-test.html'], cwd=/mock-checkout
105 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/images.svg'], cwd=/mock-checkout
106 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/another-test.html'], cwd=/mock-checkout
107 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/images.svg'], cwd=/mock-checkout
108 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/another-test.html'], cwd=/mock-checkout
109 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/images.svg'], cwd=/mock-checkout
110 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/another-test.html'], cwd=/mock-checkout
111 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/images.svg'], cwd=/mock-checkout
112 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/another-test.html'], cwd=/mock-checkout
113 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/images.svg'], cwd=/mock-checkout
114 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/another-test.html'], cwd=/mock-checkout
115 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/images.svg'], cwd=/mock-checkout
116 MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/another-test.html'], cwd=/mock-checkout
117 MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/images.svg'], cwd=/mock-checkout
119 command._tests_to_rebaseline = lambda port: [] if not port.name().find('-gpu-') == -1 else ['userscripts/another-test.html', 'userscripts/images.svg']
120 OutputCapture().assert_outputs(self, command.execute, [None, [], tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr)