| OLD | NEW |
| 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 optparse | 5 import optparse |
| 6 import unittest | 6 import unittest |
| 7 | 7 |
| 8 from webkitpy.common.net.buildbot import Build | 8 from webkitpy.common.net.buildbot import Build |
| 9 from webkitpy.common.net.layouttestresults import LayoutTestResults | 9 from webkitpy.common.net.layouttestresults import LayoutTestResults |
| 10 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2 | 10 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 })) | 103 })) |
| 104 | 104 |
| 105 | 105 |
| 106 class TestCopyExistingBaselinesInternal(BaseTestCase): | 106 class TestCopyExistingBaselinesInternal(BaseTestCase): |
| 107 command_constructor = CopyExistingBaselinesInternal | 107 command_constructor = CopyExistingBaselinesInternal |
| 108 | 108 |
| 109 def setUp(self): | 109 def setUp(self): |
| 110 super(TestCopyExistingBaselinesInternal, self).setUp() | 110 super(TestCopyExistingBaselinesInternal, self).setUp() |
| 111 | 111 |
| 112 def test_copying_overwritten_baseline(self): | 112 def options(self, **kwargs): |
| 113 self.tool.executive = MockExecutive2() | 113 options_dict = { |
| 114 'results_directory': None, |
| 115 'suffixes': 'txt', |
| 116 'verbose': False, |
| 117 } |
| 118 options_dict.update(kwargs) |
| 119 return optparse.Values(options_dict) |
| 114 | 120 |
| 115 port = self.tool.port_factory.get('test-mac-mac10.10') | 121 def test_copy_baseline_mac(self): |
| 122 port = self.tool.port_factory.get('test-mac-mac10.11') |
| 116 self._write( | 123 self._write( |
| 117 port.host.filesystem.join( | 124 port.host.filesystem.join( |
| 118 port.layout_tests_dir(), | 125 port.layout_tests_dir(), |
| 119 'platform/test-mac-mac10.10/failures/expected/image-expected.txt
'), | 126 'platform/test-mac-mac10.11/failures/expected/image-expected.txt
'), |
| 120 'original mac10.11 result') | 127 'original mac10.11 result') |
| 128 self.assertFalse(self.tool.filesystem.exists( |
| 129 self.tool.filesystem.join( |
| 130 port.layout_tests_dir(), |
| 131 'platform/test-mac-mac10.10/failures/expected/image-expected.txt
'))) |
| 121 | 132 |
| 122 oc = OutputCapture() | 133 self.command.execute(self.options(builder='MOCK Mac10.11', test='failure
s/expected/image.html'), [], self.tool) |
| 123 try: | |
| 124 options = optparse.Values({ | |
| 125 'builder': "MOCK Mac10.11", | |
| 126 'suffixes': 'txt', | |
| 127 'verbose': True, | |
| 128 'test': "failures/expected/image.html", | |
| 129 'results_directory': None | |
| 130 }) | |
| 131 oc.capture_output() | |
| 132 self.command.execute(options, [], self.tool) | |
| 133 finally: | |
| 134 out, _, _ = oc.restore_output() | |
| 135 | 134 |
| 136 self.assertMultiLineEqual( | 135 # The Mac 10.11 baseline is copied over to the Mac 10.10 directory, |
| 136 # because Mac10.10 is the "immediate predecessor" in the fallback tree. |
| 137 # That means that normally for Mac10.10 if there's no Mac10.10-specific |
| 138 # baseline, then we fall back to the Mac10.11 baseline. |
| 139 # The idea is, if in the next step we download new baselines for Mac10.1
1 |
| 140 # but not Mac10.10, then mac10.10 will still have the correct baseline. |
| 141 self.assertEqual( |
| 142 self._read(self.tool.filesystem.join( |
| 143 port.layout_tests_dir(), |
| 144 'platform/test-mac-mac10.11/failures/expected/image-expected.txt
')), |
| 145 'original mac10.11 result') |
| 146 self.assertEqual( |
| 137 self._read(self.tool.filesystem.join( | 147 self._read(self.tool.filesystem.join( |
| 138 port.layout_tests_dir(), | 148 port.layout_tests_dir(), |
| 139 'platform/test-mac-mac10.10/failures/expected/image-expected.txt
')), | 149 'platform/test-mac-mac10.10/failures/expected/image-expected.txt
')), |
| 140 'original mac10.11 result') | 150 'original mac10.11 result') |
| 141 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": [], "delete"
: []}\n') | |
| 142 | 151 |
| 143 def test_copying_overwritten_baseline_to_multiple_locations(self): | 152 def test_copy_baseline_win7_to_linux_trusty(self): |
| 144 self.tool.executive = MockExecutive2() | |
| 145 | |
| 146 port = self.tool.port_factory.get('test-win-win7') | 153 port = self.tool.port_factory.get('test-win-win7') |
| 147 self._write( | 154 self._write( |
| 148 port.host.filesystem.join(port.layout_tests_dir(), 'platform/test-wi
n-win7/failures/expected/image-expected.txt'), | 155 self.tool.filesystem.join( |
| 156 port.layout_tests_dir(), |
| 157 'platform/test-win-win7/failures/expected/image-expected.txt'), |
| 149 'original win7 result') | 158 'original win7 result') |
| 159 self.assertFalse(self.tool.filesystem.exists( |
| 160 self.tool.filesystem.join( |
| 161 port.layout_tests_dir(), |
| 162 'platform/test-linux-trusty/failures/expected/image-expected.txt
'))) |
| 150 | 163 |
| 151 oc = OutputCapture() | 164 self.command.execute(self.options(builder='MOCK Win7', test='failures/ex
pected/image.html'), [], self.tool) |
| 152 try: | |
| 153 options = optparse.Values({ | |
| 154 'builder': "MOCK Win7", | |
| 155 'suffixes': "txt", | |
| 156 'verbose': True, | |
| 157 'test': "failures/expected/image.html", | |
| 158 'results_directory': None | |
| 159 }) | |
| 160 oc.capture_output() | |
| 161 self.command.execute(options, [], self.tool) | |
| 162 finally: | |
| 163 out, _, _ = oc.restore_output() | |
| 164 | 165 |
| 165 self.assertMultiLineEqual( | 166 # The Mac Win7 baseline is copied over to the Linux Trusty directory, |
| 167 # because Linux Trusty is the baseline fallback "immediate predecessor"
of Win7. |
| 168 self.assertEqual( |
| 169 self._read(self.tool.filesystem.join( |
| 170 port.layout_tests_dir(), |
| 171 'platform/test-win-win7/failures/expected/image-expected.txt')), |
| 172 'original win7 result') |
| 173 self.assertEqual( |
| 166 self._read(self.tool.filesystem.join( | 174 self._read(self.tool.filesystem.join( |
| 167 port.layout_tests_dir(), | 175 port.layout_tests_dir(), |
| 168 'platform/test-linux-trusty/failures/expected/image-expected.txt
')), | 176 'platform/test-linux-trusty/failures/expected/image-expected.txt
')), |
| 169 'original win7 result') | 177 'original win7 result') |
| 170 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join( | |
| 171 port.layout_tests_dir(), 'platform/test-linux-precise/userscripts/an
other-test-expected.txt'))) | |
| 172 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join( | |
| 173 port.layout_tests_dir(), 'platform/test-mac-mac10.10/userscripts/ano
ther-test-expected.txt'))) | |
| 174 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": [], "delete"
: []}\n') | |
| 175 | 178 |
| 176 def test_no_copy_existing_baseline(self): | 179 def test_no_copy_existing_baseline(self): |
| 177 self.tool.executive = MockExecutive2() | |
| 178 | |
| 179 port = self.tool.port_factory.get('test-win-win7') | 180 port = self.tool.port_factory.get('test-win-win7') |
| 180 self._write( | 181 self._write( |
| 181 port.host.filesystem.join( | 182 self.tool.filesystem.join( |
| 182 port.layout_tests_dir(), | 183 port.layout_tests_dir(), |
| 183 'platform/test-win-win7/failures/expected/image-expected.txt'), | 184 'platform/test-win-win7/failures/expected/image-expected.txt'), |
| 184 'original win7 result') | 185 'original win7 result') |
| 186 self._write( |
| 187 self.tool.filesystem.join( |
| 188 port.layout_tests_dir(), |
| 189 'platform/test-linux-trusty/failures/expected/image-expected.txt
'), |
| 190 'original linux trusty result') |
| 185 | 191 |
| 186 oc = OutputCapture() | 192 self.command.execute(self.options(builder='MOCK Win7', test='failures/ex
pected/image.html'), [], self.tool) |
| 187 try: | |
| 188 options = optparse.Values({ | |
| 189 'builder': "MOCK Win7", | |
| 190 'suffixes': "txt", | |
| 191 'verbose': True, | |
| 192 'test': "failures/expected/image.html", | |
| 193 'results_directory': None | |
| 194 }) | |
| 195 oc.capture_output() | |
| 196 self.command.execute(options, [], self.tool) | |
| 197 finally: | |
| 198 out, _, _ = oc.restore_output() | |
| 199 | 193 |
| 200 self.assertMultiLineEqual( | 194 # Since a baseline existed already for Linux Trusty, the Win7 baseline i
s not copied over. |
| 201 self._read(self.tool.filesystem.join( | 195 self.assertEqual( |
| 202 port.layout_tests_dir(), | |
| 203 'platform/test-linux-trusty/failures/expected/image-expected.txt
')), | |
| 204 'original win7 result') | |
| 205 self.assertMultiLineEqual( | |
| 206 self._read(self.tool.filesystem.join( | 196 self._read(self.tool.filesystem.join( |
| 207 port.layout_tests_dir(), | 197 port.layout_tests_dir(), |
| 208 'platform/test-win-win7/failures/expected/image-expected.txt')), | 198 'platform/test-win-win7/failures/expected/image-expected.txt')), |
| 209 'original win7 result') | 199 'original win7 result') |
| 210 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join( | 200 self.assertEqual( |
| 211 port.layout_tests_dir(), 'platform/test-mac-mac10.10/userscripts/ano
ther-test-expected.txt'))) | 201 self._read(self.tool.filesystem.join( |
| 212 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": [], "delete"
: []}\n') | 202 port.layout_tests_dir(), |
| 203 'platform/test-linux-trusty/failures/expected/image-expected.txt
')), |
| 204 'original linux trusty result') |
| 213 | 205 |
| 214 def test_no_copy_skipped_test(self): | 206 def test_no_copy_skipped_test(self): |
| 215 self.tool.executive = MockExecutive2() | |
| 216 port = self.tool.port_factory.get('test-win-win7') | 207 port = self.tool.port_factory.get('test-win-win7') |
| 217 fs = self.tool.filesystem | |
| 218 self._write( | 208 self._write( |
| 219 fs.join( | 209 self.tool.filesystem.join( |
| 220 port.layout_tests_dir(), | 210 port.layout_tests_dir(), |
| 221 'platform/test-win-win7/failures/expected/image-expected.txt'), | 211 'platform/test-win-win7/failures/expected/image-expected.txt'), |
| 222 'original win7 result') | 212 'original win7 result') |
| 223 expectations_path = fs.join(port.path_to_generic_test_expectations_file(
)) | |
| 224 self._write( | 213 self._write( |
| 225 expectations_path, | 214 port.path_to_generic_test_expectations_file(), |
| 226 ("[ Win ] failures/expected/image.html [ Failure ]\n" | 215 ("[ Win ] failures/expected/image.html [ Failure ]\n" |
| 227 "[ Linux ] failures/expected/image.html [ Skip ]\n")) | 216 "[ Linux ] failures/expected/image.html [ Skip ]\n")) |
| 228 oc = OutputCapture() | |
| 229 try: | |
| 230 options = optparse.Values({ | |
| 231 'builder': "MOCK Win7", | |
| 232 'suffixes': "txt", 'verbose': True, | |
| 233 'test': "failures/expected/image.html", | |
| 234 'results_directory': None | |
| 235 }) | |
| 236 oc.capture_output() | |
| 237 self.command.execute(options, [], self.tool) | |
| 238 finally: | |
| 239 oc.restore_output() | |
| 240 | 217 |
| 218 self.command.execute(self.options(builder='MOCK Win7', test='failures/ex
pected/image.html'), [], self.tool) |
| 219 |
| 220 # The Win7 baseline is not copied over to the Linux Trusty directory |
| 221 # because the test is skipped on linux. |
| 241 self.assertFalse( | 222 self.assertFalse( |
| 242 fs.exists(fs.join( | 223 self.tool.filesystem.exists(self.tool.filesystem.join( |
| 243 port.layout_tests_dir(), | |
| 244 'platform/test-mac-mac10.10/failures/expected/image-expected.txt
'))) | |
| 245 self.assertFalse( | |
| 246 fs.exists(fs.join( | |
| 247 port.layout_tests_dir(), | 224 port.layout_tests_dir(), |
| 248 'platform/test-linux-trusty/failures/expected/image-expected.txt
'))) | 225 'platform/test-linux-trusty/failures/expected/image-expected.txt
'))) |
| 249 self.assertFalse( | |
| 250 fs.exists(fs.join( | |
| 251 port.layout_tests_dir(), | |
| 252 'platform/test-linux-precise/failures/expected/image-expected.tx
t'))) | |
| 253 self.assertEqual( | |
| 254 self._read(fs.join(port.layout_tests_dir(), 'platform/test-win-win7/
failures/expected/image-expected.txt')), | |
| 255 'original win7 result') | |
| 256 | 226 |
| 257 | 227 |
| 258 class TestRebaselineTest(BaseTestCase): | 228 class TestRebaselineTest(BaseTestCase): |
| 259 command_constructor = RebaselineTest # AKA webkit-patch rebaseline-test-int
ernal | 229 command_constructor = RebaselineTest # AKA webkit-patch rebaseline-test-int
ernal |
| 260 | 230 |
| 261 def setUp(self): | 231 def setUp(self): |
| 262 super(TestRebaselineTest, self).setUp() | 232 super(TestRebaselineTest, self).setUp() |
| 263 | 233 |
| 264 @staticmethod | 234 @staticmethod |
| 265 def options(**kwargs): | 235 def options(**kwargs): |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 for cmd_line, cwd in commands: | 906 for cmd_line, cwd in commands: |
| 937 out = self.run_command(cmd_line, cwd=cwd) | 907 out = self.run_command(cmd_line, cwd=cwd) |
| 938 if 'rebaseline-test-internal' in cmd_line: | 908 if 'rebaseline-test-internal' in cmd_line: |
| 939 out = '{"add": [], "remove-lines": [{"test": "%s", "builder": "%
s"}], "delete": []}\n' % (cmd_line[8], cmd_line[6]) | 909 out = '{"add": [], "remove-lines": [{"test": "%s", "builder": "%
s"}], "delete": []}\n' % (cmd_line[8], cmd_line[6]) |
| 940 command_outputs.append([0, out, '']) | 910 command_outputs.append([0, out, '']) |
| 941 | 911 |
| 942 new_calls = self.calls[num_previous_calls:] | 912 new_calls = self.calls[num_previous_calls:] |
| 943 self.calls = self.calls[:num_previous_calls] | 913 self.calls = self.calls[:num_previous_calls] |
| 944 self.calls.append(new_calls) | 914 self.calls.append(new_calls) |
| 945 return command_outputs | 915 return command_outputs |
| OLD | NEW |