| OLD | NEW |
| 1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import webkitpy.thirdparty.unittest2 as unittest | 29 import webkitpy.thirdparty.unittest2 as unittest |
| 30 | 30 |
| 31 from webkitpy.common.system.outputcapture import OutputCapture | |
| 32 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer | 31 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer |
| 32 from webkitpy.common.checkout.scm.scm_mock import MockSCM |
| 33 from webkitpy.common.host_mock import MockHost |
| 33 from webkitpy.common.net.buildbot.buildbot_mock import MockBuilder | 34 from webkitpy.common.net.buildbot.buildbot_mock import MockBuilder |
| 34 from webkitpy.common.net.layouttestresults import LayoutTestResults | 35 from webkitpy.common.net.layouttestresults import LayoutTestResults |
| 35 from webkitpy.common.system.executive_mock import MockExecutive2 | 36 from webkitpy.common.system.executive_mock import MockExecutive2 |
| 37 from webkitpy.common.system.outputcapture import OutputCapture |
| 36 from webkitpy.thirdparty.mock import Mock | 38 from webkitpy.thirdparty.mock import Mock |
| 37 from webkitpy.tool.commands.rebaseline import * | 39 from webkitpy.tool.commands.rebaseline import * |
| 38 from webkitpy.tool.mocktool import MockTool, MockOptions | 40 from webkitpy.tool.mocktool import MockTool, MockOptions |
| 39 | 41 |
| 40 | 42 |
| 41 class _BaseTestCase(unittest.TestCase): | 43 class _BaseTestCase(unittest.TestCase): |
| 42 MOCK_WEB_RESULT = 'MOCK Web result, convert 404 to None=True' | 44 MOCK_WEB_RESULT = 'MOCK Web result, convert 404 to None=True' |
| 43 WEB_PREFIX = 'http://example.com/f/builders/WebKit Mac10.7/results/layout-te
st-results' | 45 WEB_PREFIX = 'http://example.com/f/builders/WebKit Mac10.7/results/layout-te
st-results' |
| 44 | 46 |
| 45 command_constructor = None | 47 command_constructor = None |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 119 |
| 118 options = MockOptions(builder="MOCK SnowLeopard", suffixes="txt", ve
rbose=True, test="failures/expected/image.html", results_directory=None) | 120 options = MockOptions(builder="MOCK SnowLeopard", suffixes="txt", ve
rbose=True, test="failures/expected/image.html", results_directory=None) |
| 119 | 121 |
| 120 oc.capture_output() | 122 oc.capture_output() |
| 121 self.command.execute(options, [], self.tool) | 123 self.command.execute(options, [], self.tool) |
| 122 finally: | 124 finally: |
| 123 out, _, _ = oc.restore_output() | 125 out, _, _ = oc.restore_output() |
| 124 builders._exact_matches = old_exact_matches | 126 builders._exact_matches = old_exact_matches |
| 125 | 127 |
| 126 self.assertMultiLineEqual(self._read(self.tool.filesystem.join(port.layo
ut_tests_dir(), 'platform/test-mac-leopard/failures/expected/image-expected.txt'
)), 'original snowleopard result') | 128 self.assertMultiLineEqual(self._read(self.tool.filesystem.join(port.layo
ut_tests_dir(), 'platform/test-mac-leopard/failures/expected/image-expected.txt'
)), 'original snowleopard result') |
| 127 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": []}\n') | 129 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": [], "delete"
: []}\n') |
| 128 | 130 |
| 129 def test_copying_overwritten_baseline_to_multiple_locations(self): | 131 def test_copying_overwritten_baseline_to_multiple_locations(self): |
| 130 self.tool.executive = MockExecutive2() | 132 self.tool.executive = MockExecutive2() |
| 131 | 133 |
| 132 # FIXME: crbug.com/279494. it's confusing that this is the test- port, a
nd not the regular win port. Really all of the tests should be using the test po
rts. | 134 # FIXME: crbug.com/279494. it's confusing that this is the test- port, a
nd not the regular win port. Really all of the tests should be using the test po
rts. |
| 133 port = self.tool.port_factory.get('test-win-win7') | 135 port = self.tool.port_factory.get('test-win-win7') |
| 134 self._write(port._filesystem.join(port.layout_tests_dir(), 'platform/tes
t-win-win7/failures/expected/image-expected.txt'), 'original win7 result') | 136 self._write(port._filesystem.join(port.layout_tests_dir(), 'platform/tes
t-win-win7/failures/expected/image-expected.txt'), 'original win7 result') |
| 135 | 137 |
| 136 old_exact_matches = builders._exact_matches | 138 old_exact_matches = builders._exact_matches |
| 137 oc = OutputCapture() | 139 oc = OutputCapture() |
| 138 try: | 140 try: |
| 139 builders._exact_matches = { | 141 builders._exact_matches = { |
| 140 "MOCK Leopard": {"port_name": "test-mac-leopard", "specifiers":
set(["mock-specifier"])}, | 142 "MOCK Leopard": {"port_name": "test-mac-leopard", "specifiers":
set(["mock-specifier"])}, |
| 141 "MOCK Linux": {"port_name": "test-linux-x86_64", "specifiers": s
et(["mock-specifier"])}, | 143 "MOCK Linux": {"port_name": "test-linux-x86_64", "specifiers": s
et(["mock-specifier"])}, |
| 142 "MOCK Win7": {"port_name": "test-win-win7", "specifiers": set(["
mock-specifier"])}, | 144 "MOCK Win7": {"port_name": "test-win-win7", "specifiers": set(["
mock-specifier"])}, |
| 143 } | 145 } |
| 144 | 146 |
| 145 options = MockOptions(builder="MOCK Win7", suffixes="txt", verbose=T
rue, test="failures/expected/image.html", results_directory=None) | 147 options = MockOptions(builder="MOCK Win7", suffixes="txt", verbose=T
rue, test="failures/expected/image.html", results_directory=None) |
| 146 | 148 |
| 147 oc.capture_output() | 149 oc.capture_output() |
| 148 self.command.execute(options, [], self.tool) | 150 self.command.execute(options, [], self.tool) |
| 149 finally: | 151 finally: |
| 150 out, _, _ = oc.restore_output() | 152 out, _, _ = oc.restore_output() |
| 151 builders._exact_matches = old_exact_matches | 153 builders._exact_matches = old_exact_matches |
| 152 | 154 |
| 153 self.assertMultiLineEqual(self._read(self.tool.filesystem.join(port.layo
ut_tests_dir(), 'platform/test-linux-x86_64/failures/expected/image-expected.txt
')), 'original win7 result') | 155 self.assertMultiLineEqual(self._read(self.tool.filesystem.join(port.layo
ut_tests_dir(), 'platform/test-linux-x86_64/failures/expected/image-expected.txt
')), 'original win7 result') |
| 154 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(p
ort.layout_tests_dir(), 'platform/mac-leopard/userscripts/another-test-expected.
txt'))) | 156 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(p
ort.layout_tests_dir(), 'platform/mac-leopard/userscripts/another-test-expected.
txt'))) |
| 155 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": []}\n') | 157 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": [], "delete"
: []}\n') |
| 156 | 158 |
| 157 def test_no_copy_existing_baseline(self): | 159 def test_no_copy_existing_baseline(self): |
| 158 self.tool.executive = MockExecutive2() | 160 self.tool.executive = MockExecutive2() |
| 159 | 161 |
| 160 # FIXME: it's confusing that this is the test- port, and not the regular
win port. Really all of the tests should be using the test ports. | 162 # FIXME: it's confusing that this is the test- port, and not the regular
win port. Really all of the tests should be using the test ports. |
| 161 port = self.tool.port_factory.get('test-win-win7') | 163 port = self.tool.port_factory.get('test-win-win7') |
| 162 self._write(port._filesystem.join(port.layout_tests_dir(), 'platform/tes
t-win-win7/failures/expected/image-expected.txt'), 'original win7 result') | 164 self._write(port._filesystem.join(port.layout_tests_dir(), 'platform/tes
t-win-win7/failures/expected/image-expected.txt'), 'original win7 result') |
| 163 | 165 |
| 164 old_exact_matches = builders._exact_matches | 166 old_exact_matches = builders._exact_matches |
| 165 oc = OutputCapture() | 167 oc = OutputCapture() |
| 166 try: | 168 try: |
| 167 builders._exact_matches = { | 169 builders._exact_matches = { |
| 168 "MOCK Leopard": {"port_name": "test-mac-leopard", "specifiers":
set(["mock-specifier"])}, | 170 "MOCK Leopard": {"port_name": "test-mac-leopard", "specifiers":
set(["mock-specifier"])}, |
| 169 "MOCK Linux": {"port_name": "test-linux-x86_64", "specifiers": s
et(["mock-specifier"])}, | 171 "MOCK Linux": {"port_name": "test-linux-x86_64", "specifiers": s
et(["mock-specifier"])}, |
| 170 "MOCK Win7": {"port_name": "test-win-win7", "specifiers": set(["
mock-specifier"])}, | 172 "MOCK Win7": {"port_name": "test-win-win7", "specifiers": set(["
mock-specifier"])}, |
| 171 } | 173 } |
| 172 | 174 |
| 173 options = MockOptions(builder="MOCK Win7", suffixes="txt", verbose=T
rue, test="failures/expected/image.html", results_directory=None) | 175 options = MockOptions(builder="MOCK Win7", suffixes="txt", verbose=T
rue, test="failures/expected/image.html", results_directory=None) |
| 174 | 176 |
| 175 oc.capture_output() | 177 oc.capture_output() |
| 176 self.command.execute(options, [], self.tool) | 178 self.command.execute(options, [], self.tool) |
| 177 finally: | 179 finally: |
| 178 out, _, _ = oc.restore_output() | 180 out, _, _ = oc.restore_output() |
| 179 builders._exact_matches = old_exact_matches | 181 builders._exact_matches = old_exact_matches |
| 180 | 182 |
| 181 self.assertMultiLineEqual(self._read(self.tool.filesystem.join(port.layo
ut_tests_dir(), 'platform/test-linux-x86_64/failures/expected/image-expected.txt
')), 'original win7 result') | 183 self.assertMultiLineEqual(self._read(self.tool.filesystem.join(port.layo
ut_tests_dir(), 'platform/test-linux-x86_64/failures/expected/image-expected.txt
')), 'original win7 result') |
| 182 self.assertMultiLineEqual(self._read(self.tool.filesystem.join(port.layo
ut_tests_dir(), 'platform/test-win-win7/failures/expected/image-expected.txt')),
'original win7 result') | 184 self.assertMultiLineEqual(self._read(self.tool.filesystem.join(port.layo
ut_tests_dir(), 'platform/test-win-win7/failures/expected/image-expected.txt')),
'original win7 result') |
| 183 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(p
ort.layout_tests_dir(), 'platform/mac-leopard/userscripts/another-test-expected.
txt'))) | 185 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(p
ort.layout_tests_dir(), 'platform/mac-leopard/userscripts/another-test-expected.
txt'))) |
| 184 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": []}\n') | 186 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": [], "delete"
: []}\n') |
| 185 | 187 |
| 186 def test_no_copy_skipped_test(self): | 188 def test_no_copy_skipped_test(self): |
| 187 self.tool.executive = MockExecutive2() | 189 self.tool.executive = MockExecutive2() |
| 188 | 190 |
| 189 port = self.tool.port_factory.get('test-win-win7') | 191 port = self.tool.port_factory.get('test-win-win7') |
| 190 fs = self.tool.filesystem | 192 fs = self.tool.filesystem |
| 191 self._write(fs.join(port.layout_tests_dir(), 'platform/test-win-win7/fai
lures/expected/image-expected.txt'), 'original win7 result') | 193 self._write(fs.join(port.layout_tests_dir(), 'platform/test-win-win7/fai
lures/expected/image-expected.txt'), 'original win7 result') |
| 192 expectations_path = fs.join(port.path_to_generic_test_expectations_file(
)) | 194 expectations_path = fs.join(port.path_to_generic_test_expectations_file(
)) |
| 193 self._write(expectations_path, ( | 195 self._write(expectations_path, ( |
| 194 "[ Win ] failures/expected/image.html [ Failure ]\n" | 196 "[ Win ] failures/expected/image.html [ Failure ]\n" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 self._write(self.lion_expectations_path, "Bug(x) [ Mac ] userscripts/ano
ther-test.html [ ImageOnlyFailure ]\nbug(z) [ Linux ] userscripts/another-test.h
tml [ ImageOnlyFailure ]\n") | 259 self._write(self.lion_expectations_path, "Bug(x) [ Mac ] userscripts/ano
ther-test.html [ ImageOnlyFailure ]\nbug(z) [ Linux ] userscripts/another-test.h
tml [ ImageOnlyFailure ]\n") |
| 258 self.options.results_directory = '/tmp' | 260 self.options.results_directory = '/tmp' |
| 259 self.command._rebaseline_test_and_update_expectations(self.options) | 261 self.command._rebaseline_test_and_update_expectations(self.options) |
| 260 self.assertItemsEqual(self.tool.web.urls_fetched, ['file:///tmp/userscri
pts/another-test-actual.txt']) | 262 self.assertItemsEqual(self.tool.web.urls_fetched, ['file:///tmp/userscri
pts/another-test-actual.txt']) |
| 261 | 263 |
| 262 def test_rebaseline_reftest(self): | 264 def test_rebaseline_reftest(self): |
| 263 self._write("userscripts/another-test.html", "test data") | 265 self._write("userscripts/another-test.html", "test data") |
| 264 self._write("userscripts/another-test-expected.html", "generic result") | 266 self._write("userscripts/another-test-expected.html", "generic result") |
| 265 OutputCapture().assert_outputs(self, self.command._rebaseline_test_and_u
pdate_expectations, args=[self.options], | 267 OutputCapture().assert_outputs(self, self.command._rebaseline_test_and_u
pdate_expectations, args=[self.options], |
| 266 expected_logs="Cannot rebaseline reftest: userscripts/another-test.h
tml\n") | 268 expected_logs="Cannot rebaseline reftest: userscripts/another-test.h
tml\n") |
| 267 self.assertDictEqual(self.command._scm_changes, {'add': [], 'remove-line
s': []}) | 269 self.assertDictEqual(self.command._scm_changes, {'add': [], 'remove-line
s': [], "delete": []}) |
| 268 | 270 |
| 269 def test_rebaseline_test_and_print_scm_changes(self): | 271 def test_rebaseline_test_and_print_scm_changes(self): |
| 270 self.command._print_scm_changes = True | 272 self.command._print_scm_changes = True |
| 271 self.command._scm_changes = {'add': [], 'delete': []} | 273 self.command._scm_changes = {'add': [], 'delete': []} |
| 272 self.tool._scm.exists = lambda x: False | 274 self.tool._scm.exists = lambda x: False |
| 273 | 275 |
| 274 self.command._rebaseline_test("WebKit Linux", "userscripts/another-test.
html", "txt", None) | 276 self.command._rebaseline_test("WebKit Linux", "userscripts/another-test.
html", "txt", None) |
| 275 | 277 |
| 276 self.assertDictEqual(self.command._scm_changes, {'add': ['/mock-checkout
/third_party/WebKit/LayoutTests/platform/linux/userscripts/another-test-expected
.txt'], 'delete': []}) | 278 self.assertDictEqual(self.command._scm_changes, {'add': ['/mock-checkout
/third_party/WebKit/LayoutTests/platform/linux/userscripts/another-test-expected
.txt'], 'delete': []}) |
| 277 | 279 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 294 verbose=True, test="failures/expected/image.html", results_direc
tory=None) | 296 verbose=True, test="failures/expected/image.html", results_direc
tory=None) |
| 295 | 297 |
| 296 oc.capture_output() | 298 oc.capture_output() |
| 297 self.command.execute(options, [], self.tool) | 299 self.command.execute(options, [], self.tool) |
| 298 finally: | 300 finally: |
| 299 out, _, _ = oc.restore_output() | 301 out, _, _ = oc.restore_output() |
| 300 builders._exact_matches = old_exact_matches | 302 builders._exact_matches = old_exact_matches |
| 301 | 303 |
| 302 self.assertMultiLineEqual(self._read(self.tool.filesystem.join(port.layo
ut_tests_dir(), 'platform/test-win-win7/failures/expected/image-expected.txt')),
'MOCK Web result, convert 404 to None=True') | 304 self.assertMultiLineEqual(self._read(self.tool.filesystem.join(port.layo
ut_tests_dir(), 'platform/test-win-win7/failures/expected/image-expected.txt')),
'MOCK Web result, convert 404 to None=True') |
| 303 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(p
ort.layout_tests_dir(), 'platform/test-win-xp/failures/expected/image-expected.t
xt'))) | 305 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(p
ort.layout_tests_dir(), 'platform/test-win-xp/failures/expected/image-expected.t
xt'))) |
| 304 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": [{"test": "f
ailures/expected/image.html", "builder": "MOCK Win7"}]}\n') | 306 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": [{"test": "f
ailures/expected/image.html", "builder": "MOCK Win7"}], "delete": []}\n') |
| 305 | 307 |
| 306 | 308 |
| 307 class TestAbstractParallelRebaselineCommand(_BaseTestCase): | 309 class TestAbstractParallelRebaselineCommand(_BaseTestCase): |
| 308 command_constructor = AbstractParallelRebaselineCommand | 310 command_constructor = AbstractParallelRebaselineCommand |
| 309 | 311 |
| 310 def test_builders_to_fetch_from(self): | 312 def test_builders_to_fetch_from(self): |
| 311 old_exact_matches = builders._exact_matches | 313 old_exact_matches = builders._exact_matches |
| 312 try: | 314 try: |
| 313 builders._exact_matches = { | 315 builders._exact_matches = { |
| 314 "MOCK XP": {"port_name": "test-win-xp"}, | 316 "MOCK XP": {"port_name": "test-win-xp"}, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 return self.command._builder_data | 358 return self.command._builder_data |
| 357 | 359 |
| 358 self.command.builder_data = builder_data | 360 self.command.builder_data = builder_data |
| 359 | 361 |
| 360 options = MockOptions(optimize=True, verbose=True, results_directory=Non
e) | 362 options = MockOptions(optimize=True, verbose=True, results_directory=Non
e) |
| 361 self._write("userscripts/first-test.html", "Dummy test contents") | 363 self._write("userscripts/first-test.html", "Dummy test contents") |
| 362 self.command._rebaseline(options, {"userscripts/first-test.html": {"MOC
K builder": ["txt", "png"]}}) | 364 self.command._rebaseline(options, {"userscripts/first-test.html": {"MOC
K builder": ["txt", "png"]}}) |
| 363 | 365 |
| 364 # Note that we have one run_in_parallel() call followed by a run_command
() | 366 # Note that we have one run_in_parallel() call followed by a run_command
() |
| 365 self.assertEqual(self.tool.executive.calls, | 367 self.assertEqual(self.tool.executive.calls, |
| 366 [['echo', '--verbose', 'optimize-baselines', '--suffixes', '', 'user
scripts/first-test.html']]) | 368 [[['echo', 'optimize-baselines', '--no-modify-scm', '--suffixes', ''
, 'userscripts/first-test.html', '--verbose']]]) |
| 367 | 369 |
| 368 def test_rebaseline_all(self): | 370 def test_rebaseline_all(self): |
| 369 self._setup_mock_builder_data() | 371 self._setup_mock_builder_data() |
| 370 | 372 |
| 371 options = MockOptions(optimize=True, verbose=True, results_directory=Non
e) | 373 options = MockOptions(optimize=True, verbose=True, results_directory=Non
e) |
| 372 self._write("userscripts/first-test.html", "Dummy test contents") | 374 self._write("userscripts/first-test.html", "Dummy test contents") |
| 373 self.command._rebaseline(options, {"userscripts/first-test.html": {"MOC
K builder": ["txt", "png"]}}) | 375 self.command._rebaseline(options, {"userscripts/first-test.html": {"MOC
K builder": ["txt", "png"]}}) |
| 374 | 376 |
| 375 # Note that we have one run_in_parallel() call followed by a run_command
() | 377 # Note that we have one run_in_parallel() call followed by a run_command
() |
| 376 self.assertEqual(self.tool.executive.calls, | 378 self.assertEqual(self.tool.executive.calls, |
| 377 [[['echo', 'copy-existing-baselines-internal', '--suffixes', 'txt,pn
g', '--builder', 'MOCK builder', '--test', 'userscripts/first-test.html', '--ver
bose']], | 379 [[['echo', 'copy-existing-baselines-internal', '--suffixes', 'txt,pn
g', '--builder', 'MOCK builder', '--test', 'userscripts/first-test.html', '--ver
bose']], |
| 378 [['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', '--b
uilder', 'MOCK builder', '--test', 'userscripts/first-test.html', '--verbose']], | 380 [['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', '--b
uilder', 'MOCK builder', '--test', 'userscripts/first-test.html', '--verbose']], |
| 379 ['echo', '--verbose', 'optimize-baselines', '--suffixes', 'txt,png'
, 'userscripts/first-test.html']]) | 381 [['echo', 'optimize-baselines', '--no-modify-scm', '--suffixes', 't
xt,png', 'userscripts/first-test.html', '--verbose']]]) |
| 380 | 382 |
| 381 def test_rebaseline_debug(self): | 383 def test_rebaseline_debug(self): |
| 382 self._setup_mock_builder_data() | 384 self._setup_mock_builder_data() |
| 383 | 385 |
| 384 options = MockOptions(optimize=True, verbose=True, results_directory=Non
e) | 386 options = MockOptions(optimize=True, verbose=True, results_directory=Non
e) |
| 385 self._write("userscripts/first-test.html", "Dummy test contents") | 387 self._write("userscripts/first-test.html", "Dummy test contents") |
| 386 self.command._rebaseline(options, {"userscripts/first-test.html": {"MOC
K builder (Debug)": ["txt", "png"]}}) | 388 self.command._rebaseline(options, {"userscripts/first-test.html": {"MOC
K builder (Debug)": ["txt", "png"]}}) |
| 387 | 389 |
| 388 # Note that we have one run_in_parallel() call followed by a run_command
() | 390 # Note that we have one run_in_parallel() call followed by a run_command
() |
| 389 self.assertEqual(self.tool.executive.calls, | 391 self.assertEqual(self.tool.executive.calls, |
| 390 [[['echo', 'copy-existing-baselines-internal', '--suffixes', 'txt,pn
g', '--builder', 'MOCK builder (Debug)', '--test', 'userscripts/first-test.html'
, '--verbose']], | 392 [[['echo', 'copy-existing-baselines-internal', '--suffixes', 'txt,pn
g', '--builder', 'MOCK builder (Debug)', '--test', 'userscripts/first-test.html'
, '--verbose']], |
| 391 [['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', '--b
uilder', 'MOCK builder (Debug)', '--test', 'userscripts/first-test.html', '--ver
bose']], | 393 [['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', '--b
uilder', 'MOCK builder (Debug)', '--test', 'userscripts/first-test.html', '--ver
bose']], |
| 392 ['echo', '--verbose', 'optimize-baselines', '--suffixes', 'txt,png'
, 'userscripts/first-test.html']]) | 394 [['echo', 'optimize-baselines', '--no-modify-scm', '--suffixes', 't
xt,png', 'userscripts/first-test.html', '--verbose']]]) |
| 393 | 395 |
| 394 def test_no_optimize(self): | 396 def test_no_optimize(self): |
| 395 self._setup_mock_builder_data() | 397 self._setup_mock_builder_data() |
| 396 | 398 |
| 397 options = MockOptions(optimize=False, verbose=True, results_directory=No
ne) | 399 options = MockOptions(optimize=False, verbose=True, results_directory=No
ne) |
| 398 self._write("userscripts/first-test.html", "Dummy test contents") | 400 self._write("userscripts/first-test.html", "Dummy test contents") |
| 399 self.command._rebaseline(options, {"userscripts/first-test.html": {"MOC
K builder (Debug)": ["txt", "png"]}}) | 401 self.command._rebaseline(options, {"userscripts/first-test.html": {"MOC
K builder (Debug)": ["txt", "png"]}}) |
| 400 | 402 |
| 401 # Note that we have only one run_in_parallel() call | 403 # Note that we have only one run_in_parallel() call |
| 402 self.assertEqual(self.tool.executive.calls, | 404 self.assertEqual(self.tool.executive.calls, |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 self.assertDictEqual(self.command._tests_to_rebaseline(self.lion_port),
{'userscripts/another-test.html': ('png', 'wav', 'txt')}) | 666 self.assertDictEqual(self.command._tests_to_rebaseline(self.lion_port),
{'userscripts/another-test.html': ('png', 'wav', 'txt')}) |
| 665 | 667 |
| 666 | 668 |
| 667 class _FakeOptimizer(BaselineOptimizer): | 669 class _FakeOptimizer(BaselineOptimizer): |
| 668 def read_results_by_directory(self, baseline_name): | 670 def read_results_by_directory(self, baseline_name): |
| 669 if baseline_name.endswith('txt'): | 671 if baseline_name.endswith('txt'): |
| 670 return {'LayoutTests/passes/text.html': '123456'} | 672 return {'LayoutTests/passes/text.html': '123456'} |
| 671 return {} | 673 return {} |
| 672 | 674 |
| 673 | 675 |
| 676 class TestOptimizeBaselines(_BaseTestCase): |
| 677 command_constructor = OptimizeBaselines |
| 678 |
| 679 def _write_test_file(self, port, path, contents): |
| 680 abs_path = self.tool.filesystem.join(port.layout_tests_dir(), path) |
| 681 self.tool.filesystem.write_text_file(abs_path, contents) |
| 682 |
| 683 def setUp(self): |
| 684 super(TestOptimizeBaselines, self).setUp() |
| 685 |
| 686 def test_modify_scm(self): |
| 687 # FIXME: This is a hack to get the unittest and the BaselineOptimize to
both use /mock-checkout |
| 688 # instead of one using /mock-checkout and one using /test-checkout. |
| 689 default_port = self.tool.port_factory.get() |
| 690 self.tool.port_factory.get = lambda port_name=None: default_port |
| 691 |
| 692 test_port = self.tool.port_factory.get('test') |
| 693 self._write_test_file(test_port, 'another/test.html', "Dummy test conten
ts") |
| 694 self._write_test_file(test_port, 'platform/mac-snowleopard/another/test-
expected.txt', "result A") |
| 695 self._write_test_file(test_port, 'another/test-expected.txt', "result A"
) |
| 696 |
| 697 old_exact_matches = builders._exact_matches |
| 698 try: |
| 699 builders._exact_matches = { |
| 700 "MOCK Leopard Debug": {"port_name": "test-mac-snowleopard", "spe
cifiers": set(["mock-specifier"])}, |
| 701 } |
| 702 OutputCapture().assert_outputs(self, self.command.execute, args=[ |
| 703 MockOptions(suffixes='txt', no_modify_scm=False, platform='test-
mac-snowleopard'), |
| 704 ['another/test.html'], |
| 705 self.tool, |
| 706 ], expected_stdout='{"add": [], "remove-lines": [], "delete": []}\n'
) |
| 707 finally: |
| 708 builders._exact_matches = old_exact_matches |
| 709 |
| 710 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(t
est_port.layout_tests_dir(), 'platform/mac/another/test-expected.txt'))) |
| 711 self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join(te
st_port.layout_tests_dir(), 'another/test-expected.txt'))) |
| 712 |
| 713 def test_no_modify_scm(self): |
| 714 # FIXME: This is a hack to get the unittest and the BaselineOptimize to
both use /mock-checkout |
| 715 # instead of one using /mock-checkout and one using /test-checkout. |
| 716 default_port = self.tool.port_factory.get() |
| 717 self.tool.port_factory.get = lambda port_name=None: default_port |
| 718 |
| 719 test_port = self.tool.port_factory.get('test') |
| 720 self._write_test_file(test_port, 'another/test.html', "Dummy test conten
ts") |
| 721 self._write_test_file(test_port, 'platform/mac-snowleopard/another/test-
expected.txt', "result A") |
| 722 self._write_test_file(test_port, 'another/test-expected.txt', "result A"
) |
| 723 |
| 724 old_exact_matches = builders._exact_matches |
| 725 try: |
| 726 builders._exact_matches = { |
| 727 "MOCK Leopard Debug": {"port_name": "test-mac-snowleopard", "spe
cifiers": set(["mock-specifier"])}, |
| 728 } |
| 729 OutputCapture().assert_outputs(self, self.command.execute, args=[ |
| 730 MockOptions(suffixes='txt', no_modify_scm=True, platform='test-m
ac-snowleopard'), |
| 731 ['another/test.html'], |
| 732 self.tool, |
| 733 ], expected_stdout='{"add": [], "remove-lines": [], "delete": ["/moc
k-checkout/third_party/WebKit/LayoutTests/platform/mac-snowleopard/another/test-
expected.txt"]}\n') |
| 734 finally: |
| 735 builders._exact_matches = old_exact_matches |
| 736 |
| 737 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(t
est_port.layout_tests_dir(), 'platform/mac/another/test-expected.txt'))) |
| 738 self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join(te
st_port.layout_tests_dir(), 'another/test-expected.txt'))) |
| 739 |
| 740 |
| 674 class TestAnalyzeBaselines(_BaseTestCase): | 741 class TestAnalyzeBaselines(_BaseTestCase): |
| 675 command_constructor = AnalyzeBaselines | 742 command_constructor = AnalyzeBaselines |
| 676 | 743 |
| 677 def setUp(self): | 744 def setUp(self): |
| 678 super(TestAnalyzeBaselines, self).setUp() | 745 super(TestAnalyzeBaselines, self).setUp() |
| 679 self.port = self.tool.port_factory.get('test') | 746 self.port = self.tool.port_factory.get('test') |
| 680 self.tool.port_factory.get = (lambda port_name=None, options=None: self.
port) | 747 self.tool.port_factory.get = (lambda port_name=None, options=None: self.
port) |
| 681 self.lines = [] | 748 self.lines = [] |
| 682 self.command._optimizer_class = _FakeOptimizer | 749 self.command._optimizer_class = _FakeOptimizer |
| 683 self.command._write = (lambda msg: self.lines.append(msg)) # pylint bug
warning about unnecessary lambda? pylint: disable=W0108 | 750 self.command._write = (lambda msg: self.lines.append(msg)) # pylint bug
warning about unnecessary lambda? pylint: disable=W0108 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 ['echo', 'copy-existing-baselines-internal', '--suffixes', '
png', '--builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-strawberry.
html'], | 954 ['echo', 'copy-existing-baselines-internal', '--suffixes', '
png', '--builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-strawberry.
html'], |
| 888 ['echo', 'copy-existing-baselines-internal', '--suffixes', '
txt', '--builder', 'MOCK Leopard', '--test', 'fast/dom/prototype-taco.html'], | 955 ['echo', 'copy-existing-baselines-internal', '--suffixes', '
txt', '--builder', 'MOCK Leopard', '--test', 'fast/dom/prototype-taco.html'], |
| 889 ['echo', 'copy-existing-baselines-internal', '--suffixes', '
txt', '--builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-taco.html']
, | 956 ['echo', 'copy-existing-baselines-internal', '--suffixes', '
txt', '--builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-taco.html']
, |
| 890 ], | 957 ], |
| 891 [ | 958 [ |
| 892 ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png'
, '--builder', 'MOCK Leopard', '--test', 'fast/dom/prototype-chocolate.html'], | 959 ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png'
, '--builder', 'MOCK Leopard', '--test', 'fast/dom/prototype-chocolate.html'], |
| 893 ['echo', 'rebaseline-test-internal', '--suffixes', 'png', '-
-builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-strawberry.html'], | 960 ['echo', 'rebaseline-test-internal', '--suffixes', 'png', '-
-builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-strawberry.html'], |
| 894 ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '-
-builder', 'MOCK Leopard', '--test', 'fast/dom/prototype-taco.html'], | 961 ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '-
-builder', 'MOCK Leopard', '--test', 'fast/dom/prototype-taco.html'], |
| 895 ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '-
-builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-taco.html'], | 962 ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '-
-builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-taco.html'], |
| 896 ], | 963 ], |
| 897 ['echo', 'optimize-baselines', '--suffixes', 'txt,png', 'fast/do
m/prototype-chocolate.html'], | 964 [ |
| 898 ['echo', 'optimize-baselines', '--suffixes', 'png', 'fast/dom/pr
ototype-strawberry.html'], | 965 ['echo', 'optimize-baselines', '--no-modify-scm', '--suffixe
s', 'txt,png', 'fast/dom/prototype-chocolate.html'], |
| 899 ['echo', 'optimize-baselines', '--suffixes', 'txt', 'fast/dom/pr
ototype-taco.html'], | 966 ['echo', 'optimize-baselines', '--no-modify-scm', '--suffixe
s', 'png', 'fast/dom/prototype-strawberry.html'], |
| 967 ['echo', 'optimize-baselines', '--no-modify-scm', '--suffixe
s', 'txt', 'fast/dom/prototype-taco.html'], |
| 968 ], |
| 900 ['git', 'cl', 'upload', '-f'], | 969 ['git', 'cl', 'upload', '-f'], |
| 901 ['git', 'pull'], | 970 ['git', 'pull'], |
| 902 ['git', 'cl', 'dcommit', '-f'], | 971 ['git', 'cl', 'dcommit', '-f'], |
| 903 ['git', 'cl', 'set_close'], | 972 ['git', 'cl', 'set_close'], |
| 904 ]) | 973 ]) |
| 905 | 974 |
| 906 # The mac ports should both be removed since they're the only ones i
n builders._exact_matches. | 975 # The mac ports should both be removed since they're the only ones i
n builders._exact_matches. |
| 907 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_
to_generic_test_expectations_file()), """ | 976 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_
to_generic_test_expectations_file()), """ |
| 908 crbug.com/24182 [ Debug ] path/to/norebaseline.html [ Rebaseline ] | 977 crbug.com/24182 [ Debug ] path/to/norebaseline.html [ Rebaseline ] |
| 909 Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ NeedsRebaseline ] | 978 Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ NeedsRebaseline ] |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 self.tool.executive.calls = [] | 1031 self.tool.executive.calls = [] |
| 963 self.command.execute(MockOptions(optimize=True, verbose=False, move_
overwritten_baselines=False, results_directory=False, log_server=None), [], self
.tool) | 1032 self.command.execute(MockOptions(optimize=True, verbose=False, move_
overwritten_baselines=False, results_directory=False, log_server=None), [], self
.tool) |
| 964 | 1033 |
| 965 self.assertEqual(self.tool.executive.calls, [ | 1034 self.assertEqual(self.tool.executive.calls, [ |
| 966 [ | 1035 [ |
| 967 ['echo', 'copy-existing-baselines-internal', '--suffixes', '
txt', '--builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-taco.html']
, | 1036 ['echo', 'copy-existing-baselines-internal', '--suffixes', '
txt', '--builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-taco.html']
, |
| 968 ], | 1037 ], |
| 969 [ | 1038 [ |
| 970 ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '-
-builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-taco.html'], | 1039 ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '-
-builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-taco.html'], |
| 971 ], | 1040 ], |
| 972 ['echo', 'optimize-baselines', '--suffixes', 'txt', 'fast/dom/pr
ototype-taco.html'], | 1041 [['echo', 'optimize-baselines', '--no-modify-scm', '--suffixes',
'txt', 'fast/dom/prototype-taco.html']], |
| 973 ['git', 'cl', 'upload', '-f'], | 1042 ['git', 'cl', 'upload', '-f'], |
| 974 ['git', 'cl', 'set_close'], | 1043 ['git', 'cl', 'set_close'], |
| 975 ]) | 1044 ]) |
| 976 finally: | 1045 finally: |
| 977 builders._exact_matches = old_exact_matches | 1046 builders._exact_matches = old_exact_matches |
| 978 | 1047 |
| 979 def test_execute_test_passes_everywhere(self): | 1048 def test_execute_test_passes_everywhere(self): |
| 980 def blame(path): | 1049 def blame(path): |
| 981 return """ | 1050 return """ |
| 982 6469e754a1 path/to/TestExpectations (foobarbaz1@chromium.org 2
013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsReba
seline ] | 1051 6469e754a1 path/to/TestExpectations (foobarbaz1@chromium.org 2
013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsReba
seline ] |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 self.command.execute(MockOptions(optimize=True, verbose=False, move_
overwritten_baselines=False, results_directory=False, log_server=None), [], self
.tool) | 1091 self.command.execute(MockOptions(optimize=True, verbose=False, move_
overwritten_baselines=False, results_directory=False, log_server=None), [], self
.tool) |
| 1023 self.assertEqual(self.tool.executive.calls, [ | 1092 self.assertEqual(self.tool.executive.calls, [ |
| 1024 [ | 1093 [ |
| 1025 ['echo', 'copy-existing-baselines-internal', '--suffixes', '
txt', '--builder', 'MOCK Leopard', '--test', 'fast/dom/prototype-taco.html'], | 1094 ['echo', 'copy-existing-baselines-internal', '--suffixes', '
txt', '--builder', 'MOCK Leopard', '--test', 'fast/dom/prototype-taco.html'], |
| 1026 ['echo', 'copy-existing-baselines-internal', '--suffixes', '
txt', '--builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-taco.html']
, | 1095 ['echo', 'copy-existing-baselines-internal', '--suffixes', '
txt', '--builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-taco.html']
, |
| 1027 ], | 1096 ], |
| 1028 [ | 1097 [ |
| 1029 ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '-
-builder', 'MOCK Leopard', '--test', 'fast/dom/prototype-taco.html'], | 1098 ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '-
-builder', 'MOCK Leopard', '--test', 'fast/dom/prototype-taco.html'], |
| 1030 ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '-
-builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-taco.html'], | 1099 ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '-
-builder', 'MOCK SnowLeopard', '--test', 'fast/dom/prototype-taco.html'], |
| 1031 ], | 1100 ], |
| 1032 ['echo', 'optimize-baselines', '--suffixes', 'txt', 'fast/dom/pr
ototype-taco.html'], | 1101 [['echo', 'optimize-baselines', '--no-modify-scm', '--suffixes',
'txt', 'fast/dom/prototype-taco.html']], |
| 1033 ['git', 'cl', 'upload', '-f'], | 1102 ['git', 'cl', 'upload', '-f'], |
| 1034 ['git', 'pull'], | 1103 ['git', 'pull'], |
| 1035 ['git', 'cl', 'dcommit', '-f'], | 1104 ['git', 'cl', 'dcommit', '-f'], |
| 1036 ['git', 'cl', 'set_close'], | 1105 ['git', 'cl', 'set_close'], |
| 1037 ]) | 1106 ]) |
| 1038 | 1107 |
| 1039 # The mac ports should both be removed since they're the only ones i
n builders._exact_matches. | 1108 # The mac ports should both be removed since they're the only ones i
n builders._exact_matches. |
| 1040 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_
to_generic_test_expectations_file()), """ | 1109 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_
to_generic_test_expectations_file()), """ |
| 1041 Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ NeedsRebaseline ] | 1110 Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ NeedsRebaseline ] |
| 1042 """) | 1111 """) |
| 1043 finally: | 1112 finally: |
| 1044 builders._exact_matches = old_exact_matches | 1113 builders._exact_matches = old_exact_matches |
| OLD | NEW |