Title: [131856] trunk/Tools
Revision
131856
Author
[email protected]
Date
2012-10-18 22:32:18 -0700 (Thu, 18 Oct 2012)

Log Message

make move_overwritten_baselines_to work again while rebaselining
https://bugs.webkit.org/show_bug.cgi?id=99793

Reviewed by Ojan Vafai.

We used to have code that would help when rebaselining results
for new ports (e.g., when moving from Lion to Mountain Lion) but
it appears that code bitrotted during all the refactoring since
the last time we needed this. This patch makes things work
again, adds more tests that will hopefully make clearer what
is supposed to work, and renames various parameters to be
consistent.

* Scripts/webkitpy/layout_tests/port/builders.py:
(move_overwritten_baselines_to):
(builder_path_for_port_name):
* Scripts/webkitpy/tool/commands/rebaseline.py:
(RebaselineTest.__init__):
(RebaselineTest._copy_existing_baseline):
(RebaselineTest._rebaseline_test):
(RebaselineTest.execute):
(AbstractParallelRebaselineCommand._rebaseline_commands):
* Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
(test_rebaseline_json_with_move_overwritten_baselines_to):
(test_rebaseline_test_internal_with_move_overwritten_baselines_to):
* Scripts/webkitpy/tool/servers/gardeningserver_unittest.py:
(GardeningServerTest.test_rebaselineall):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (131855 => 131856)


--- trunk/Tools/ChangeLog	2012-10-19 05:17:28 UTC (rev 131855)
+++ trunk/Tools/ChangeLog	2012-10-19 05:32:18 UTC (rev 131856)
@@ -1,3 +1,33 @@
+2012-10-18  Dirk Pranke  <[email protected]>
+
+        make move_overwritten_baselines_to work again while rebaselining
+        https://bugs.webkit.org/show_bug.cgi?id=99793
+
+        Reviewed by Ojan Vafai.
+
+        We used to have code that would help when rebaselining results
+        for new ports (e.g., when moving from Lion to Mountain Lion) but
+        it appears that code bitrotted during all the refactoring since
+        the last time we needed this. This patch makes things work
+        again, adds more tests that will hopefully make clearer what
+        is supposed to work, and renames various parameters to be
+        consistent.
+
+        * Scripts/webkitpy/layout_tests/port/builders.py:
+        (move_overwritten_baselines_to):
+        (builder_path_for_port_name):
+        * Scripts/webkitpy/tool/commands/rebaseline.py:
+        (RebaselineTest.__init__):
+        (RebaselineTest._copy_existing_baseline):
+        (RebaselineTest._rebaseline_test):
+        (RebaselineTest.execute):
+        (AbstractParallelRebaselineCommand._rebaseline_commands):
+        * Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
+        (test_rebaseline_json_with_move_overwritten_baselines_to):
+        (test_rebaseline_test_internal_with_move_overwritten_baselines_to):
+        * Scripts/webkitpy/tool/servers/gardeningserver_unittest.py:
+        (GardeningServerTest.test_rebaselineall):
+
 2012-10-18  Roger Fong  <[email protected]>
 
         Unreviewed. Skip really old flaky failing jscore date test. 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/builders.py (131855 => 131856)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/builders.py	2012-10-19 05:17:28 UTC (rev 131855)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/builders.py	2012-10-19 05:32:18 UTC (rev 131856)
@@ -35,6 +35,16 @@
 # In this dictionary, each item stores:
 # * port_name -- a fully qualified port name
 # * specifiers -- a set of specifiers, representing configurations covered by this builder.
+# * move_overwritten_baselines_to -- (optional) list of platform directories that we will copy an existing
+#      baseline to before pulling down a new baseline during rebaselining. This is useful
+#      for bringing up a new port, for example when adding a Lion was the most recent Mac version and
+#      we wanted to bring up Mountain Lion, we would want to copy an existing baseline in platform/mac
+#      to platform/mac-mountainlion before updating the platform/mac entry.
+# * rebaseline_override_dir -- (optional) directory to put baselines in instead of where you would normally put them.
+#      This is useful when we don't have bots that cover particular configurations; so, e.g., you might
+#      support mac-mountainlion but not have a mac-mountainlion bot yet, so you'd want to put the mac-lion
+#      results into platform/mac temporarily.
+
 _exact_matches = {
     # These builders are on build.chromium.org.
     "WebKit XP": {"port_name": "chromium-win-xp", "specifiers": set(["xp", "release"])},
@@ -118,6 +128,10 @@
     return _exact_matches[builder_name].get("rebaseline_override_dir", None)
 
 
+def move_overwritten_baselines_to(builder_name):
+    return _exact_matches[builder_name].get("move_overwritten_baselines_to", [])
+
+
 def port_name_for_builder_name(builder_name):
     if builder_name in _exact_matches:
         return _exact_matches[builder_name]["port_name"]
@@ -136,7 +150,3 @@
 
 def builder_path_for_port_name(port_name):
     builder_path_from_name(builder_name_for_port_name(port_name))
-
-
-def fallback_port_names_for_new_port(builder_name):
-    return _exact_matches[builder_name].get("move_overwritten_baselines_to", [])

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py (131855 => 131856)


--- trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py	2012-10-19 05:17:28 UTC (rev 131855)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py	2012-10-19 05:32:18 UTC (rev 131856)
@@ -74,7 +74,8 @@
     def __init__(self):
         options = [
             optparse.make_option("--builder", help="Builder to pull new baselines from"),
-            optparse.make_option("--platform-to-move-to", help="Platform to move existing baselines to before rebaselining. This is for dealing with bringing up new ports that interact with non-tree portions of the fallback graph."),
+            optparse.make_option("--move-overwritten-baselines-to", action="" default=[],
+                help="Platform to move existing baselines to before rebaselining. This is for bringing up new ports."),
             optparse.make_option("--test", help="Test to rebaseline"),
         ]
         AbstractRebaseliningCommand.__init__(self, options=options)
@@ -90,13 +91,13 @@
             return self._tool.filesystem.join(port.layout_tests_dir(), 'platform', override_dir)
         return port.baseline_version_dir()
 
-    def _copy_existing_baseline(self, platforms_to_move_existing_baselines_to, test_name, suffix):
+    def _copy_existing_baseline(self, move_overwritten_baselines_to, test_name, suffix):
         old_baselines = []
         new_baselines = []
 
         # Need to gather all the baseline paths before modifying the filesystem since
         # the modifications can affect the results of port.expected_filename.
-        for platform in platforms_to_move_existing_baselines_to:
+        for platform in move_overwritten_baselines_to:
             port = self._tool.port_factory.get(platform)
             old_baseline = port.expected_filename(test_name, "." + suffix)
             if not self._tool.filesystem.exists(old_baseline):
@@ -152,15 +153,15 @@
     def _file_name_for_expected_result(self, test_name, suffix):
         return "%s-expected.%s" % (self._test_root(test_name), suffix)
 
-    def _rebaseline_test(self, builder_name, test_name, platforms_to_move_existing_baselines_to, suffix):
+    def _rebaseline_test(self, builder_name, test_name, move_overwritten_baselines_to, suffix):
         results_url = self._results_url(builder_name)
         baseline_directory = self._baseline_directory(builder_name)
 
         source_baseline = "%s/%s" % (results_url, self._file_name_for_actual_result(test_name, suffix))
         target_baseline = self._tool.filesystem.join(baseline_directory, self._file_name_for_expected_result(test_name, suffix))
 
-        if platforms_to_move_existing_baselines_to:
-            self._copy_existing_baseline(platforms_to_move_existing_baselines_to, test_name, suffix)
+        if move_overwritten_baselines_to:
+            self._copy_existing_baseline(move_overwritten_baselines_to, test_name, suffix)
 
         _log.info("Retrieving %s." % source_baseline)
         self._save_baseline(self._tool.web.get_binary(source_baseline, convert_404_to_None=True), target_baseline)
@@ -172,7 +173,7 @@
 
     def execute(self, options, args, tool):
         self._baseline_suffix_list = options.suffixes.split(',')
-        self._rebaseline_test_and_update_expectations(options.builder, options.test, options.platform_to_move_to)
+        self._rebaseline_test_and_update_expectations(options.builder, options.test, options.move_overwritten_baselines_to)
         print json.dumps(self._scm_changes)
 
 
@@ -269,6 +270,9 @@
             for builder in self._builders_to_fetch_from(test_list[test]):
                 suffixes = ','.join(test_list[test][builder])
                 cmd_line = [path_to_webkit_patch, 'rebaseline-test-internal', '--suffixes', suffixes, '--builder', builder, '--test', test]
+                move_overwritten_baselines_to = builders.move_overwritten_baselines_to(builder)
+                for platform in move_overwritten_baselines_to:
+                    cmd_line.extend(['--move-overwritten-baselines-to', platform])
                 commands.append(tuple([cmd_line, cwd]))
         return commands
 

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py (131855 => 131856)


--- trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py	2012-10-19 05:17:28 UTC (rev 131855)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py	2012-10-19 05:32:18 UTC (rev 131856)
@@ -456,3 +456,60 @@
 
         finally:
             builders._exact_matches = old_exact_matches
+
+    def test_rebaseline_json_with_move_overwritten_baselines_to(self):
+        old_exact_matches = builders._exact_matches
+        try:
+            builders._exact_matches = {
+                "MOCK builder": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])},
+                "MOCK builder2": {"port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier2"]),
+                                  "move_overwritten_baselines_to": ["test-mac-leopard"]},
+            }
+
+            command = Rebaseline()
+            tool = MockTool()
+            tool.executive = MockExecutive(should_log=True)
+            command.bind_to_tool(tool)
+
+            expected_stdout = """rebaseline-json: {'mock/path/to/test.html': {'MOCK builder2': ['txt', 'png']}}\n"""
+            expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', '--builder', 'MOCK builder2', '--test', 'mock/path/to/test.html', '--move-overwritten-baselines-to', 'test-mac-leopard'], cwd=/mock-checkout
+MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt,png', 'mock/path/to/test.html'], cwd=/mock-checkout
+"""
+
+            options = MockOptions(optimize=True, builders=["MOCK builder2"], suffixes=["txt,png"], verbose=True)
+            OutputCapture().assert_outputs(self, command.execute, [options, ["mock/path/to/test.html"], tool],
+                expected_stdout=expected_stdout, expected_stderr=expected_stderr)
+        finally:
+            builders._exact_matches = old_exact_matches
+
+    def test_rebaseline_test_internal_with_move_overwritten_baselines_to(self):
+        old_exact_matches = builders._exact_matches
+        try:
+            builders._exact_matches = {
+                "MOCK Leopard": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])},
+                "MOCK SnowLeopard": {"port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier"])},
+            }
+
+            command = RebaselineTest()
+            tool = MockTool()
+            tool.executive = MockExecutive(should_log=True)
+            command.bind_to_tool(tool)
+
+            port = tool.port_factory.get('test-mac-snowleopard')
+            tool.filesystem.write_text_file(tool.filesystem.join(port.baseline_version_dir(), 'failures', 'expected', 'image-expected.txt'), '')
+
+            options = MockOptions(optimize=True, builder="MOCK SnowLeopard", suffixes="txt",
+                move_overwritten_baselines_to=["test-mac-leopard"], verbose=True, test="failures/expected/image.html")
+
+            oc = OutputCapture()
+            oc.capture_output()
+            try:
+                logs = ''
+                command.execute(options, [], tool)
+            finally:
+                _, _, logs = oc.restore_output()
+
+            self.assertTrue("Copying baseline from /test.checkout/LayoutTests/platform/test-mac-snowleopard/failures/expected/image-expected.txt to /test.checkout/LayoutTests/platform/test-mac-leopard/failures/expected/image-expected.txt.\n" in logs)
+
+        finally:
+            builders._exact_matches = old_exact_matches

Modified: trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py (131855 => 131856)


--- trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py	2012-10-19 05:17:28 UTC (rev 131855)
+++ trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py	2012-10-19 05:32:18 UTC (rev 131856)
@@ -121,9 +121,3 @@
         self._post_to_path("/rebaselineall", body='{"user-scripts/another-test.html":{"MOCK builder": ["txt","png"]}}', expected_stderr=expected_stderr % ('MOCK builder', '"txt","png"'), expected_stdout=expected_stdout, server=server)
 
         self._post_to_path("/rebaselineall", body='{"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt","png"]}}', expected_stderr=expected_stderr % ('MOCK builder (Debug)', '"txt","png"'), expected_stdout=expected_stdout)
-
-    def test_rebaseline_new_port(self):
-        builders._exact_matches = {"MOCK builder": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"]), "move_overwritten_baselines_to": ["mock-port-fallback", "mock-port-fallback2"]}}
-        expected_stderr = 'MOCK run_command: [\'echo\', \'rebaseline-json\'], cwd=/mock-checkout, input={"user-scripts/another-test.html":{"MOCK builder": ["txt","png"]}}\n'
-        expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n"
-        self._post_to_path("/rebaselineall", body='{"user-scripts/another-test.html":{"MOCK builder": ["txt","png"]}}', expected_stderr=expected_stderr, expected_stdout=expected_stdout)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to