Title: [109945] trunk/Tools
Revision
109945
Author
[email protected]
Date
2012-03-06 12:11:04 -0800 (Tue, 06 Mar 2012)

Log Message

Add a mechanism to rebaseline new ports
https://bugs.webkit.org/show_bug.cgi?id=80355

Reviewed by Adam Barth.

For a test that's only failing on a new port, we want
to first copy the existing result into the location for the
port it's replacing in order to not break that port.

For example, bringing up the chromium-lion port, if we just
stick the results in the chromium-mac directory, the snow leopard
will start failing. Instead, we first copy the existing result
to the chromium-mac-snowleopard directory.

* Scripts/webkitpy/layout_tests/port/builders.py:
(builder_path_for_port_name):
(fallback_port_name_for_new_port):
* Scripts/webkitpy/tool/commands/rebaseline.py:
(RebaselineTest):
(RebaselineTest._copy_existing_baseline):
(RebaselineTest._rebaseline_test):
(RebaselineTest.execute):
* Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
(TestRebaseline.test_rebaseline_test):
(TestRebaseline):
(TestRebaseline.test_rebaseline_and_copy_test):
(test_rebaseline_and_copy_test_no_existing_result):
(test_rebaseline_and_copy_test_with_lion_result):
(test_rebaseline_and_copy_no_overwrite_test):
* Scripts/webkitpy/tool/servers/gardeningserver.py:
(GardeningHTTPRequestHandler.rebaseline):
* Scripts/webkitpy/tool/servers/gardeningserver_unittest.py:
(GardeningServerTest.test_rebaseline):
(GardeningServerTest):
(GardeningServerTest.test_rebaseline_new_port):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (109944 => 109945)


--- trunk/Tools/ChangeLog	2012-03-06 20:08:56 UTC (rev 109944)
+++ trunk/Tools/ChangeLog	2012-03-06 20:11:04 UTC (rev 109945)
@@ -1,3 +1,41 @@
+2012-03-05  Ojan Vafai  <[email protected]>
+
+        Add a mechanism to rebaseline new ports
+        https://bugs.webkit.org/show_bug.cgi?id=80355
+
+        Reviewed by Adam Barth.
+
+        For a test that's only failing on a new port, we want
+        to first copy the existing result into the location for the
+        port it's replacing in order to not break that port.
+
+        For example, bringing up the chromium-lion port, if we just
+        stick the results in the chromium-mac directory, the snow leopard
+        will start failing. Instead, we first copy the existing result
+        to the chromium-mac-snowleopard directory.
+
+        * Scripts/webkitpy/layout_tests/port/builders.py:
+        (builder_path_for_port_name):
+        (fallback_port_name_for_new_port):
+        * Scripts/webkitpy/tool/commands/rebaseline.py:
+        (RebaselineTest):
+        (RebaselineTest._copy_existing_baseline):
+        (RebaselineTest._rebaseline_test):
+        (RebaselineTest.execute):
+        * Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
+        (TestRebaseline.test_rebaseline_test):
+        (TestRebaseline):
+        (TestRebaseline.test_rebaseline_and_copy_test):
+        (test_rebaseline_and_copy_test_no_existing_result):
+        (test_rebaseline_and_copy_test_with_lion_result):
+        (test_rebaseline_and_copy_no_overwrite_test):
+        * Scripts/webkitpy/tool/servers/gardeningserver.py:
+        (GardeningHTTPRequestHandler.rebaseline):
+        * Scripts/webkitpy/tool/servers/gardeningserver_unittest.py:
+        (GardeningServerTest.test_rebaseline):
+        (GardeningServerTest):
+        (GardeningServerTest.test_rebaseline_new_port):
+
 2012-03-06  Beth Dakin  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=80351

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


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/builders.py	2012-03-06 20:08:56 UTC (rev 109944)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/builders.py	2012-03-06 20:11:04 UTC (rev 109945)
@@ -50,6 +50,7 @@
     "Webkit Mac10.5 (dbg)(2)": {"port_name": "chromium-mac-leopard", "specifiers": set(["leopard", "debug"])},
     "Webkit Mac10.6": {"port_name": "chromium-mac-snowleopard", "specifiers": set(["snowleopard"])},
     "Webkit Mac10.6 (dbg)": {"port_name": "chromium-mac-snowleopard", "specifiers": set(["snowleopard", "debug"])},
+    "Webkit Mac10.7": {"port_name": "chromium-mac-lion", "specifiers": set(["lion"]), "move_overwritten_baselines_to": "chromium-mac-snowleopard"},
     "Webkit Win - GPU": {"port_name": "chromium-gpu-win-xp", "specifiers": set(["xp", "release", "gpu"])},
     "Webkit Win7 - GPU": {"port_name": "chromium-gpu-win-win7", "specifiers": set(["win7", "vista", "release", "gpu"])},
     # FIXME: For some reason, these port names don't work correctly.
@@ -130,3 +131,7 @@
 
 def builder_path_for_port_name(port_name):
     builder_path_from_name(builder_name_for_port_name(port_name))
+
+
+def fallback_port_name_for_new_port(builder_name):
+    return _exact_matches[builder_name].get("move_overwritten_baselines_to")

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


--- trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py	2012-03-06 20:08:56 UTC (rev 109944)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py	2012-03-06 20:11:04 UTC (rev 109945)
@@ -57,7 +57,7 @@
 class RebaselineTest(AbstractDeclarativeCommand):
     name = "rebaseline-test"
     help_text = "Rebaseline a single test from a buildbot.  (Currently works only with build.chromium.org buildbots.)"
-    argument_names = "BUILDER_NAME TEST_NAME"
+    argument_names = "BUILDER_NAME TEST_NAME [PLATFORM_TO_MOVE_EXISTING_BASELINES_TO]"
 
     def _results_url(self, builder_name):
         # FIXME: Generalize this command to work with non-build.chromium.org builders.
@@ -68,6 +68,22 @@
         port = self._tool.port_factory.get_from_builder_name(builder_name)
         return port.baseline_path()
 
+    def _copy_existing_baseline(self, platform_to_move_existing_baselines_to, test_name, suffix):
+        port = self._tool.port_factory.get(platform_to_move_existing_baselines_to)
+        old_baseline = port.expected_filename(test_name, "." + suffix)
+        if not self._tool.filesystem.exists(old_baseline):
+            print("No existing baseline for %s." % test_name)
+            return
+
+        new_baseline = self._tool.filesystem.join(port.baseline_path(), self._file_name_for_expected_result(test_name, suffix))
+        if self._tool.filesystem.exists(new_baseline):
+            print("Existing baseline at %s, not copying over it." % new_baseline)
+        else:
+            print("Copying baseline from %s to %s." % (old_baseline, new_baseline))
+            self._tool.filesystem.copyfile(old_baseline, new_baseline)
+            if not self._tool.scm().exists(new_baseline):
+                self._tool.scm().add(new_baseline)
+
     def _save_baseline(self, data, target_baseline):
         if not data:
             return
@@ -86,21 +102,29 @@
     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, suffix):
+    def _rebaseline_test(self, builder_name, test_name, platform_to_move_existing_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 = os.path.join(baseline_directory, self._file_name_for_expected_result(test_name, suffix))
+        target_baseline = self._tool.filesystem.join(baseline_directory, self._file_name_for_expected_result(test_name, suffix))
 
+        if platform_to_move_existing_baselines_to:
+            self._copy_existing_baseline(platform_to_move_existing_baselines_to, test_name, suffix)
+
         print "Retrieving %s." % source_baseline
         self._save_baseline(self._tool.web.get_binary(source_baseline, convert_404_to_None=True), target_baseline)
 
     def execute(self, options, args, tool):
         for suffix in _baseline_suffix_list:
-            self._rebaseline_test(args[0], args[1], suffix)
+            if len(args) > 2:
+                platform_to_move_existing_baselines_to = args[2]
+            else:
+                platform_to_move_existing_baselines_to = None
 
+            self._rebaseline_test(args[0], args[1], platform_to_move_existing_baselines_to, suffix)
 
+
 class OptimizeBaselines(AbstractDeclarativeCommand):
     name = "optimize-baselines"
     help_text = "Reshuffles the baselines for the given tests to use as litte space on disk as possible."

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


--- trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py	2012-03-06 20:08:56 UTC (rev 109944)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py	2012-03-06 20:11:04 UTC (rev 109945)
@@ -46,8 +46,60 @@
         command = RebaselineTest()
         command.bind_to_tool(MockTool())
         expected_stdout = "Retrieving http://example.com/f/builders/Webkit Linux/results/layout-test-results/userscripts/another-test-actual.txt.\n"
-        OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Linux", "userscripts/another-test.html", "txt"], expected_stdout=expected_stdout)
+        OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Linux", "userscripts/another-test.html", None, "txt"], expected_stdout=expected_stdout)
 
+    def test_rebaseline_and_copy_test(self):
+        command = RebaselineTest()
+        tool = MockTool()
+        command.bind_to_tool(tool)
+
+        lion_port = tool.port_factory.get_from_builder_name("Webkit Mac10.7")
+        tool.filesystem.write_text_file(os.path.join(lion_port.layout_tests_dir(), "userscripts/another-test-expected.txt"), "Dummy expected result")
+
+        expected_stdout = """Copying baseline from /mock-checkout/LayoutTests/userscripts/another-test-expected.txt to /mock-checkout/LayoutTests/platform/chromium-mac-snowleopard/userscripts/another-test-expected.txt.
+Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.txt.
+"""
+        OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Mac10.7", "userscripts/another-test.html", "chromium-mac-snowleopard", "txt"], expected_stdout=expected_stdout)
+
+    def test_rebaseline_and_copy_test_no_existing_result(self):
+        command = RebaselineTest()
+        tool = MockTool()
+        command.bind_to_tool(tool)
+
+        expected_stdout = """No existing baseline for userscripts/another-test.html.
+Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.txt.
+"""
+        OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Mac10.7", "userscripts/another-test.html", "chromium-mac-snowleopard", "txt"], expected_stdout=expected_stdout)
+
+    def test_rebaseline_and_copy_test_with_lion_result(self):
+        command = RebaselineTest()
+        tool = MockTool()
+        command.bind_to_tool(tool)
+
+        lion_port = tool.port_factory.get_from_builder_name("Webkit Mac10.7")
+        tool.filesystem.write_text_file(os.path.join(lion_port.baseline_path(), "userscripts/another-test-expected.txt"), "Dummy expected result")
+
+        expected_stdout = """Copying baseline from /mock-checkout/LayoutTests/platform/chromium-mac/userscripts/another-test-expected.txt to /mock-checkout/LayoutTests/platform/chromium-mac-snowleopard/userscripts/another-test-expected.txt.
+Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.txt.
+"""
+        OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Mac10.7", "userscripts/another-test.html", "chromium-mac-snowleopard", "txt"], expected_stdout=expected_stdout)
+
+    def test_rebaseline_and_copy_no_overwrite_test(self):
+        command = RebaselineTest()
+        tool = MockTool()
+        command.bind_to_tool(tool)
+
+        lion_port = tool.port_factory.get_from_builder_name("Webkit Mac10.7")
+        tool.filesystem.write_text_file(os.path.join(lion_port.baseline_path(), "userscripts/another-test-expected.txt"), "Dummy expected result")
+
+        snowleopard_port = tool.port_factory.get_from_builder_name("Webkit Mac10.6")
+        tool.filesystem.write_text_file(os.path.join(snowleopard_port.baseline_path(), "userscripts/another-test-expected.txt"), "Dummy expected result")
+
+        expected_stdout = """Existing baseline at /mock-checkout/LayoutTests/platform/chromium-mac-snowleopard/userscripts/another-test-expected.txt, not copying over it.
+Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.txt.
+"""
+        OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Mac10.7", "userscripts/another-test.html", "chromium-mac-snowleopard", "txt"], expected_stdout=expected_stdout)
+
     def test_rebaseline_expectations(self):
         command = RebaselineExpectations()
         tool = MockTool()
@@ -72,6 +124,9 @@
 Retrieving results for chromium-mac-leopard from Webkit Mac10.5.
     userscripts/another-test.html
     userscripts/images.svg
+Retrieving results for chromium-mac-lion from Webkit Mac10.7.
+    userscripts/another-test.html
+    userscripts/images.svg
 Retrieving results for chromium-mac-snowleopard from Webkit Mac10.6.
     userscripts/another-test.html
     userscripts/images.svg
@@ -92,6 +147,8 @@
 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/images.svg'], cwd=/mock-checkout
 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/another-test.html'], cwd=/mock-checkout
 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/images.svg'], cwd=/mock-checkout
+MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.7', 'userscripts/another-test.html'], cwd=/mock-checkout
+MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.7', 'userscripts/images.svg'], cwd=/mock-checkout
 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/another-test.html'], cwd=/mock-checkout
 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/images.svg'], cwd=/mock-checkout
 MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/another-test.html'], cwd=/mock-checkout

Modified: trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py (109944 => 109945)


--- trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py	2012-03-06 20:08:56 UTC (rev 109944)
+++ trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py	2012-03-06 20:11:04 UTC (rev 109945)
@@ -142,6 +142,7 @@
             'rebaseline-test',
             builder,
             test,
+            builders.fallback_port_name_for_new_port(builder),
         ])
         self._serve_text('success')
 

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


--- trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py	2012-03-06 20:08:56 UTC (rev 109944)
+++ trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py	2012-03-06 20:11:04 UTC (rev 109945)
@@ -31,6 +31,7 @@
 
 from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.layout_tests.models.test_configuration import *
+from webkitpy.layout_tests.port import builders
 from webkitpy.thirdparty.mock import Mock
 from webkitpy.tool.mocktool import MockTool
 from webkitpy.common.system.executive_mock import MockExecutive
@@ -182,10 +183,17 @@
         self._post_to_path("/rollout?revision=2314&reason=MOCK+rollout+reason", expected_stderr=expected_stderr, expected_stdout=expected_stdout)
 
     def test_rebaseline(self):
-        expected_stderr = "MOCK run_command: ['echo', 'rebaseline-test', 'MOCK builder', 'user-scripts/another-test.html'], cwd=/mock-checkout\n"
+        builders._exact_matches = {"MOCK builder": {"port_name": "mock-port-name", "specifiers": set(["mock-specifier"])}}
+        expected_stderr = "MOCK run_command: ['echo', 'rebaseline-test', 'MOCK builder', 'user-scripts/another-test.html', None], cwd=/mock-checkout\n"
         expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n"
         self._post_to_path("/rebaseline?builder=MOCK+builder&test=user-scripts/another-test.html", expected_stderr=expected_stderr, expected_stdout=expected_stdout)
 
+    def test_rebaseline_new_port(self):
+        builders._exact_matches = {"MOCK builder": {"port_name": "mock-port-name", "specifiers": set(["mock-specifier"]), "move_overwritten_baselines_to": "mock-port-fallback"}}
+        expected_stderr = "MOCK run_command: ['echo', 'rebaseline-test', 'MOCK builder', 'user-scripts/another-test.html', 'mock-port-fallback'], cwd=/mock-checkout\n"
+        expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n"
+        self._post_to_path("/rebaseline?builder=MOCK+builder&test=user-scripts/another-test.html", expected_stderr=expected_stderr, expected_stdout=expected_stdout)
+
     def test_optimizebaselines(self):
         expected_stderr = "MOCK run_command: ['echo', 'optimize-baselines', 'user-scripts/another-test.html'], cwd=/mock-checkout\n"
         expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n"
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to