Title: [121800] trunk/Tools
Revision
121800
Author
[email protected]
Date
2012-07-03 13:23:41 -0700 (Tue, 03 Jul 2012)

Log Message

Have webkit-patch rebaseline use rebaseline-test-internal
https://bugs.webkit.org/show_bug.cgi?id=90491

Reviewed by Dirk Pranke.

This lets it handle new files, reduces duplicate code and lays the
groundwork for making rebaseline have a richer interface.

* Scripts/webkitpy/common/net/buildbot/buildbot_mock.py:
(MockBuild):
(MockBuild.__init__):
(MockBuilder.build):
* Scripts/webkitpy/tool/commands/rebaseline.py:
(AbstractParallelRebaselineCommand._files_to_add):
(Rebaseline):
(Rebaseline._builder_to_pull_from):
(Rebaseline._tests_to_update):
(Rebaseline.execute):
* Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
(test_overrides_are_included_correctly):
(test_rebaseline):
(test_rebaseline.mock_builder_to_pull_from):
(test_rebaseline.mock_tests_to_update):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (121799 => 121800)


--- trunk/Tools/ChangeLog	2012-07-03 19:30:10 UTC (rev 121799)
+++ trunk/Tools/ChangeLog	2012-07-03 20:23:41 UTC (rev 121800)
@@ -1,5 +1,31 @@
 2012-07-03  Ojan Vafai  <[email protected]>
 
+        Have webkit-patch rebaseline use rebaseline-test-internal
+        https://bugs.webkit.org/show_bug.cgi?id=90491
+
+        Reviewed by Dirk Pranke.
+
+        This lets it handle new files, reduces duplicate code and lays the
+        groundwork for making rebaseline have a richer interface.
+
+        * Scripts/webkitpy/common/net/buildbot/buildbot_mock.py:
+        (MockBuild):
+        (MockBuild.__init__):
+        (MockBuilder.build):
+        * Scripts/webkitpy/tool/commands/rebaseline.py:
+        (AbstractParallelRebaselineCommand._files_to_add):
+        (Rebaseline):
+        (Rebaseline._builder_to_pull_from):
+        (Rebaseline._tests_to_update):
+        (Rebaseline.execute):
+        * Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
+        (test_overrides_are_included_correctly):
+        (test_rebaseline):
+        (test_rebaseline.mock_builder_to_pull_from):
+        (test_rebaseline.mock_tests_to_update):
+
+2012-07-03  Ojan Vafai  <[email protected]>
+
         Rename rebaseline-test to rebaseline-test-internal
         https://bugs.webkit.org/show_bug.cgi?id=90485
 

Modified: trunk/Tools/Scripts/webkitpy/common/net/buildbot/buildbot_mock.py (121799 => 121800)


--- trunk/Tools/Scripts/webkitpy/common/net/buildbot/buildbot_mock.py	2012-07-03 19:30:10 UTC (rev 121799)
+++ trunk/Tools/Scripts/webkitpy/common/net/buildbot/buildbot_mock.py	2012-07-03 20:23:41 UTC (rev 121800)
@@ -27,6 +27,12 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
+class MockBuild(object):
+    def __init__(self, build_number, revision, is_green):
+        self._number = build_number
+        self._revision = revision
+        self._is_green = is_green
+
 class MockBuilder(object):
     def __init__(self, name):
         self._name = name
@@ -34,6 +40,9 @@
     def name(self):
         return self._name
 
+    def build(self, build_number):
+        return MockBuild(build_number=build_number, revision=1234, is_green=False)
+
     def results_url(self):
         return "http://example.com/builders/%s/results" % self.name()
 

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


--- trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py	2012-07-03 19:30:10 UTC (rev 121799)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py	2012-07-03 20:23:41 UTC (rev 121800)
@@ -278,12 +278,19 @@
 
     def _files_to_add(self, command_results):
         files_to_add = set()
-        for output in [result[1] for result in command_results]:
-            try:
-                files_to_add.update(json.loads(output)['add'])
-            except ValueError, e:
-                _log.warning('"%s" is not a JSON object, ignoring' % output)
+        for output in [result[1].split('\n') for result in command_results]:
+            file_added = False
+            for line in output:
+                try:
+                    files_to_add.update(json.loads(line)['add'])
+                    file_added = True
+                except ValueError, e:
+                    _log.debug('"%s" is not a JSON object, ignoring' % line)
 
+            if not file_added:
+                _log.debug('Could not add file based off output "%s"' % output)
+
+
         return list(files_to_add)
 
     def _optimize_baselines(self, test_list):
@@ -360,8 +367,7 @@
             self._update_expectations_file(port_name)
 
 
-# FIXME: Make this use AbstractParallelRebaselineCommand.
-class Rebaseline(AbstractDeclarativeCommand):
+class Rebaseline(AbstractParallelRebaselineCommand):
     name = "rebaseline"
     help_text = "Replaces local expected.txt files with new results from build bots"
 
@@ -377,29 +383,16 @@
             if status["name"] == chosen_name:
                 return (self._tool.buildbot.builder_with_name(chosen_name), status["build_number"])
 
-    def _replace_expectation_with_remote_result(self, local_file, remote_file):
-        (downloaded_file, headers) = urllib.urlretrieve(remote_file)
-        shutil.move(downloaded_file, local_file)
-
     def _tests_to_update(self, build):
         failing_tests = build.layout_test_results().tests_matching_failure_types([test_failures.FailureTextMismatch])
         return self._tool.user.prompt_with_list("Which test(s) to rebaseline:", failing_tests, can_choose_multiple=True)
 
-    def _results_url_for_test(self, build, test):
-        test_base = os.path.splitext(test)[0]
-        actual_path = test_base + "-actual.txt"
-        return build.results_url() + "/" + actual_path
-
     def execute(self, options, args, tool):
         builder, build_number = self._builder_to_pull_from()
         build = builder.build(build_number)
-        port = tool.port_factory.get_from_builder_name(builder.name())
 
+        builder_name = builder.name()
+        test_list = {}
         for test in self._tests_to_update(build):
-            results_url = self._results_url_for_test(build, test)
-            # Port operates with absolute paths.
-            expected_file = port.expected_filename(test, '.txt')
-            _log.info(test)
-            self._replace_expectation_with_remote_result(expected_file, results_url)
-
-        # FIXME: We should handle new results too.
+            test_list[test] = {builder_name: ['txt']}
+        self._rebaseline(options, test_list)

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


--- trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py	2012-07-03 19:30:10 UTC (rev 121799)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py	2012-07-03 20:23:41 UTC (rev 121800)
@@ -32,6 +32,7 @@
 from webkitpy.thirdparty.mock import Mock
 from webkitpy.tool.commands.rebaseline import *
 from webkitpy.tool.mocktool import MockTool, MockOptions
+from webkitpy.common.net.buildbot.buildbot_mock import MockBuilder
 from webkitpy.common.system.executive_mock import MockExecutive
 
 
@@ -331,3 +332,39 @@
         port._filesystem.write_text_file(port.layout_tests_dir() + '/userscripts/another-test.html', '')
         self.assertEquals(command._tests_to_rebaseline(port), {'userscripts/another-test.html': set(['txt'])})
         self.assertEquals(port._filesystem.read_text_file(expectations_path), expectations_contents)
+
+    def test_rebaseline(self):
+        old_exact_matches = builders._exact_matches
+        try:
+            builders._exact_matches = {
+                "MOCK builder": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])},
+            }
+
+            command = Rebaseline()
+            tool = MockTool()
+            command.bind_to_tool(tool)
+
+            for port_name in tool.port_factory.all_port_names():
+                port = tool.port_factory.get(port_name)
+                for path in port.expectations_files():
+                    tool.filesystem.write_text_file(path, '')
+
+            tool.executive = MockExecutive(should_log=True)
+
+            def mock_builder_to_pull_from():
+                return MockBuilder('MOCK builder'), 1234
+
+            def mock_tests_to_update(build):
+                return ['mock/path/to/test.html']
+
+            command._builder_to_pull_from = mock_builder_to_pull_from
+            command._tests_to_update = mock_tests_to_update
+
+            expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'MOCK builder', '--test', 'mock/path/to/test.html'], cwd=/mock-checkout
+MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt', 'mock/path/to/test.html'], cwd=/mock-checkout
+"""
+
+            OutputCapture().assert_outputs(self, command.execute, [MockOptions(optimize=True), [], tool], expected_stderr=expected_stderr)
+
+        finally:
+            builders._exact_matches = old_exact_matches
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to