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 a2a30a36a9b9cc95f96d2fd93be71f042b400669..bf288d5d41d5f778f0a8ce393c4f9a2abb50ae80 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 |
@@ -117,114 +117,99 @@ class TestCopyExistingBaselinesInternal(BaseTestCase): |
options_dict.update(kwargs) |
return optparse.Values(options_dict) |
- def test_copy_baseline_mac(self): |
- port = self.tool.port_factory.get('test-mac-mac10.11') |
+ def baseline_path(self, path_from_layout_test_dir): |
+ port = self.tool.port_factory.get() |
+ return self.tool.filesystem.join(port.layout_tests_dir(), path_from_layout_test_dir) |
+ |
+ # The tests in this class all depend on the fall-back path graph |
+ # that is set up in |TestPort.FALLBACK_PATHS|. |
+ |
+ def test_copy_baseline_mac_newer_to_older_version(self): |
+ # The test-mac-mac10.11 baseline is copied over to the test-mac-mac10.10 |
+ # baseline directory because test-mac-mac10.10 is the "immediate |
+ # predecessor" in the fall-back graph. |
self._write( |
- port.host.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-mac-mac10.11/failures/expected/image-expected.txt'), |
- 'original mac10.11 result') |
+ self.baseline_path('platform/test-mac-mac10.11/failures/expected/image-expected.txt'), |
+ 'original test-mac-mac10.11 result') |
self.assertFalse(self.tool.filesystem.exists( |
- self.tool.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-mac-mac10.10/failures/expected/image-expected.txt'))) |
+ self.baseline_path('platform/test-mac-mac10.10/failures/expected/image-expected.txt'))) |
self.command.execute(self.options(builder='MOCK Mac10.11', test='failures/expected/image.html'), [], self.tool) |
- # The Mac 10.11 baseline is copied over to the Mac 10.10 directory, |
- # because Mac10.10 is the "immediate predecessor" in the fallback tree. |
- # That means that normally for Mac10.10 if there's no Mac10.10-specific |
- # baseline, then we fall back to the Mac10.11 baseline. |
- # The idea is, if in the next step we download new baselines for Mac10.11 |
- # but not Mac10.10, then mac10.10 will still have the correct baseline. |
self.assertEqual( |
- self._read(self.tool.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-mac-mac10.11/failures/expected/image-expected.txt')), |
- 'original mac10.11 result') |
+ self._read(self.baseline_path('platform/test-mac-mac10.11/failures/expected/image-expected.txt')), |
+ 'original test-mac-mac10.11 result') |
self.assertEqual( |
- self._read(self.tool.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-mac-mac10.10/failures/expected/image-expected.txt')), |
- 'original mac10.11 result') |
- |
- def test_copying_overwritten_baseline_to_multiple_locations(self): |
- self.tool.executive = MockExecutive() |
+ self._read(self.baseline_path('platform/test-mac-mac10.10/failures/expected/image-expected.txt')), |
+ 'original test-mac-mac10.11 result') |
- def test_copy_baseline_win7_to_linux_trusty(self): |
- port = self.tool.port_factory.get('test-win-win7') |
+ def test_copy_baseline_win10_to_linux_trusty_and_win7(self): |
+ # The test-win-win10 baseline is copied over to the test-linux-trusty |
+ # and test-win-win7 baseline paths, since both of these are "immediate |
+ # predecessors". |
self._write( |
- self.tool.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-win-win7/failures/expected/image-expected.txt'), |
- 'original win7 result') |
+ self.baseline_path('platform/test-win-win10/failures/expected/image-expected.txt'), |
+ 'original test-win-win10 result') |
self.assertFalse(self.tool.filesystem.exists( |
- self.tool.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-linux-trusty/failures/expected/image-expected.txt'))) |
+ self.baseline_path('platform/test-linux-trusty/failures/expected/image-expected.txt'))) |
- self.command.execute(self.options(builder='MOCK Win7', test='failures/expected/image.html'), [], self.tool) |
+ self.command.execute(self.options(builder='MOCK Win10', test='failures/expected/image.html'), [], self.tool) |
- # The Mac Win7 baseline is copied over to the Linux Trusty directory, |
- # because Linux Trusty is the baseline fallback "immediate predecessor" of Win7. |
self.assertEqual( |
- self._read(self.tool.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-win-win7/failures/expected/image-expected.txt')), |
- 'original win7 result') |
+ self._read(self.baseline_path('platform/test-win-win10/failures/expected/image-expected.txt')), |
+ 'original test-win-win10 result') |
self.assertEqual( |
- self._read(self.tool.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-linux-trusty/failures/expected/image-expected.txt')), |
- 'original win7 result') |
+ self._read(self.baseline_path('platform/test-linux-trusty/failures/expected/image-expected.txt')), |
+ 'original test-win-win10 result') |
+ self.assertEqual( |
+ self._read(self.baseline_path('platform/test-linux-trusty/failures/expected/image-expected.txt')), |
+ 'original test-win-win10 result') |
def test_no_copy_existing_baseline(self): |
- port = self.tool.port_factory.get('test-win-win7') |
+ # If a baseline exists already for an "immediate prdecessor" baseline |
+ # directory, (e.g. test-linux-trusty), then no "immediate successor" |
+ # baselines (e.g. test-win-win10) are copied over. |
self._write( |
- self.tool.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-win-win7/failures/expected/image-expected.txt'), |
- 'original win7 result') |
+ self.baseline_path('platform/test-win-win10/failures/expected/image-expected.txt'), |
+ 'original test-win-win10 result') |
self._write( |
- self.tool.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-linux-trusty/failures/expected/image-expected.txt'), |
- 'original linux trusty result') |
+ self.baseline_path('platform/test-linux-trusty/failures/expected/image-expected.txt'), |
+ 'original test-linux-trusty result') |
- self.command.execute(self.options(builder='MOCK Win7', test='failures/expected/image.html'), [], self.tool) |
+ self.command.execute(self.options(builder='MOCK Win10', test='failures/expected/image.html'), [], self.tool) |
- # Since a baseline existed already for Linux Trusty, the Win7 baseline is not copied over. |
self.assertEqual( |
- self._read(self.tool.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-win-win7/failures/expected/image-expected.txt')), |
- 'original win7 result') |
+ self._read(self.baseline_path('platform/test-win-win10/failures/expected/image-expected.txt')), |
+ 'original test-win-win10 result') |
self.assertEqual( |
- self._read(self.tool.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-linux-trusty/failures/expected/image-expected.txt')), |
- 'original linux trusty result') |
+ self._read(self.baseline_path('platform/test-linux-trusty/failures/expected/image-expected.txt')), |
+ 'original test-linux-trusty result') |
def test_no_copy_skipped_test(self): |
- port = self.tool.port_factory.get('test-win-win7') |
+ # If a test is skipped on some platform, no baselines are copied over |
+ # to that directory. In this example, the test is skipped on linux, |
+ # so the test-win-win10 baseline is not copied over. |
+ port = self.tool.port_factory.get('test-win-win10') |
self._write( |
- self.tool.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-win-win7/failures/expected/image-expected.txt'), |
- 'original win7 result') |
+ self.baseline_path('platform/test-win-win10/failures/expected/image-expected.txt'), |
+ 'original test-win-win10 result') |
self._write( |
port.path_to_generic_test_expectations_file(), |
("[ Win ] failures/expected/image.html [ Failure ]\n" |
"[ Linux ] failures/expected/image.html [ Skip ]\n")) |
- self.command.execute(self.options(builder='MOCK Win7', test='failures/expected/image.html'), [], self.tool) |
+ self.command.execute(self.options(builder='MOCK Win10', test='failures/expected/image.html'), [], self.tool) |
- # The Win7 baseline is not copied over to the Linux Trusty directory |
- # because the test is skipped on linux. |
self.assertFalse( |
- self.tool.filesystem.exists(self.tool.filesystem.join( |
- port.layout_tests_dir(), |
- 'platform/test-linux-trusty/failures/expected/image-expected.txt'))) |
+ self.tool.filesystem.exists(self.baseline_path('platform/test-linux-trusty/failures/expected/image-expected.txt'))) |
+ |
+ def test_port_for_primary_baseline(self): |
+ self.assertEqual(self.command._port_for_primary_baseline('test-linux-trusty').name(), 'test-linux-trusty') |
+ self.assertEqual(self.command._port_for_primary_baseline('test-mac-mac10.11').name(), 'test-mac-mac10.11') |
+ |
+ def test_port_for_primary_baseline_not_found(self): |
+ with self.assertRaises(Exception): |
+ self.command._port_for_primary_baseline('test-foo-foo4.7') |
class TestRebaselineTest(BaseTestCase): |