summaryrefslogtreecommitdiff
path: root/Tools/Scripts/webkitpy/tool/commands/rebaseline.py
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-06-01 10:36:58 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-06-01 10:36:58 +0200
commitb1e9e47fa11f608ae16bc07f97a2acf95bf80272 (patch)
treec88c45e80c9c44506e7cdf9a3bb39ebf82a8cd5b /Tools/Scripts/webkitpy/tool/commands/rebaseline.py
parentbe01689f43cf6882cf670d33df49ead1f570c53a (diff)
downloadqtwebkit-b1e9e47fa11f608ae16bc07f97a2acf95bf80272.tar.gz
Imported WebKit commit 499c84c99aa98e9870fa7eaa57db476c6d160d46 (http://svn.webkit.org/repository/webkit/trunk@119200)
Weekly update :). Particularly relevant changes for Qt are the use of the WebCore image decoders and direct usage of libpng/libjpeg if available in the system.
Diffstat (limited to 'Tools/Scripts/webkitpy/tool/commands/rebaseline.py')
-rw-r--r--Tools/Scripts/webkitpy/tool/commands/rebaseline.py51
1 files changed, 37 insertions, 14 deletions
diff --git a/Tools/Scripts/webkitpy/tool/commands/rebaseline.py b/Tools/Scripts/webkitpy/tool/commands/rebaseline.py
index 30409783f..5a184f19e 100644
--- a/Tools/Scripts/webkitpy/tool/commands/rebaseline.py
+++ b/Tools/Scripts/webkitpy/tool/commands/rebaseline.py
@@ -26,6 +26,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import json
+import logging
import optparse
import os.path
import re
@@ -51,16 +53,19 @@ from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
_baseline_suffix_list = ['png', 'wav', 'txt']
+_log = logging.getLogger(__name__)
+
# FIXME: Should TestResultWriter know how to compute this string?
def _baseline_name(fs, test_name, suffix):
return fs.splitext(test_name)[0] + TestResultWriter.FILENAME_SUFFIX_EXPECTED + "." + suffix
class AbstractRebaseliningCommand(AbstractDeclarativeCommand):
- def __init__(self):
- options = [
+ def __init__(self, options=None):
+ options = options or []
+ options.extend([
optparse.make_option('--suffixes', default=','.join(_baseline_suffix_list), action='store',
- help='file types to rebaseline')]
+ help='file types to rebaseline')])
AbstractDeclarativeCommand.__init__(self, options=options)
self._baseline_suffix_list = _baseline_suffix_list
@@ -70,6 +75,14 @@ class RebaselineTest(AbstractRebaseliningCommand):
help_text = "Rebaseline a single test from a buildbot. (Currently works only with build.chromium.org buildbots.)"
argument_names = "BUILDER_NAME TEST_NAME [PLATFORMS_TO_MOVE_EXISTING_BASELINES_TO]"
+ def __init__(self):
+ options = [
+ optparse.make_option("--print-scm-changes", action="store_true", help="Print modifcations to the scm (as a json dict) rather than actually modifying the scm"),
+ ]
+ AbstractRebaseliningCommand.__init__(self, options=options)
+ self._print_scm_changes = False
+ self._scm_changes = {}
+
def _results_url(self, builder_name):
# FIXME: Generalize this command to work with non-build.chromium.org builders.
builder = self._tool.chromium_buildbot().builder_with_name(builder_name)
@@ -89,12 +102,12 @@ class RebaselineTest(AbstractRebaseliningCommand):
port = self._tool.port_factory.get(platform)
old_baseline = port.expected_filename(test_name, "." + suffix)
if not self._tool.filesystem.exists(old_baseline):
- print("No existing baseline for %s." % test_name)
+ _log.info("No existing baseline for %s." % test_name)
continue
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)
+ _log.info("Existing baseline at %s, not copying over it." % new_baseline)
continue
old_baselines.append(old_baseline)
@@ -104,11 +117,11 @@ class RebaselineTest(AbstractRebaseliningCommand):
old_baseline = old_baselines[i]
new_baseline = new_baselines[i]
- print("Copying baseline from %s to %s." % (old_baseline, new_baseline))
+ _log.info("Copying baseline from %s to %s." % (old_baseline, new_baseline))
self._tool.filesystem.maybe_make_directory(self._tool.filesystem.dirname(new_baseline))
self._tool.filesystem.copyfile(old_baseline, new_baseline)
if not self._tool.scm().exists(new_baseline):
- self._tool.scm().add(new_baseline)
+ self._add_to_scm(new_baseline)
def _save_baseline(self, data, target_baseline):
if not data:
@@ -117,7 +130,13 @@ class RebaselineTest(AbstractRebaseliningCommand):
filesystem.maybe_make_directory(filesystem.dirname(target_baseline))
filesystem.write_binary_file(target_baseline, data)
if not self._tool.scm().exists(target_baseline):
- self._tool.scm().add(target_baseline)
+ self._add_to_scm(target_baseline)
+
+ def _add_to_scm(self, path):
+ if self._print_scm_changes:
+ self._scm_changes['add'].append(path)
+ else:
+ self._tool.scm().add(path)
def _update_expectations_file(self, builder_name, test_name):
port = self._tool.port_factory.get_from_builder_name(builder_name)
@@ -148,7 +167,7 @@ class RebaselineTest(AbstractRebaseliningCommand):
if platforms_to_move_existing_baselines_to:
self._copy_existing_baseline(platforms_to_move_existing_baselines_to, test_name, suffix)
- print "Retrieving %s." % source_baseline
+ _log.info("Retrieving %s." % source_baseline)
self._save_baseline(self._tool.web.get_binary(source_baseline, convert_404_to_None=True), target_baseline)
def _rebaseline_test_and_update_expectations(self, builder_name, test_name, platforms_to_move_existing_baselines_to):
@@ -158,12 +177,16 @@ class RebaselineTest(AbstractRebaseliningCommand):
def execute(self, options, args, tool):
self._baseline_suffix_list = options.suffixes.split(',')
+ self._print_scm_changes = options.print_scm_changes
+ self._scm_changes = {'add': [], 'delete': []}
if len(args) > 2:
platforms_to_move_existing_baselines_to = args[2:]
else:
platforms_to_move_existing_baselines_to = None
self._rebaseline_test_and_update_expectations(args[0], args[1], platforms_to_move_existing_baselines_to)
+ if self._print_scm_changes:
+ print json.dumps(self._scm_changes)
class OptimizeBaselines(AbstractRebaseliningCommand):
@@ -257,10 +280,10 @@ class RebaselineExpectations(AbstractDeclarativeCommand):
builder_name = builders.builder_name_for_port_name(port_name)
if not builder_name:
return
- print "Retrieving results for %s from %s." % (port_name, builder_name)
+ _log.info("Retrieving results for %s from %s." % (port_name, builder_name))
for test_name in self._tests_to_rebaseline(self._tool.port_factory.get(port_name)):
self._touched_test_names.add(test_name)
- print " %s" % test_name
+ _log.info(" %s" % test_name)
# FIXME: need to extract the correct list of suffixes here.
self._run_webkit_patch(['rebaseline-test', builder_name, test_name])
@@ -273,7 +296,7 @@ class RebaselineExpectations(AbstractDeclarativeCommand):
if not options.optimize:
return
for test_name in self._touched_test_names:
- print "Optimizing baselines for %s." % test_name
+ _log.info("Optimizing baselines for %s." % test_name)
self._run_webkit_patch(['optimize-baselines', test_name])
@@ -285,7 +308,7 @@ class Rebaseline(AbstractDeclarativeCommand):
def _builder_to_pull_from(self):
builder_statuses = self._tool.buildbot.builder_statuses()
red_statuses = [status for status in builder_statuses if not status["is_green"]]
- print "%s failing" % (pluralize("builder", len(red_statuses)))
+ _log.info("%s failing" % (pluralize("builder", len(red_statuses))))
builder_choices = [status["name"] for status in red_statuses]
chosen_name = self._tool.user.prompt_with_list("Which builder to pull results from:", builder_choices)
# FIXME: prompt_with_list should really take a set of objects and a set of names and then return the object.
@@ -315,7 +338,7 @@ class Rebaseline(AbstractDeclarativeCommand):
results_url = self._results_url_for_test(build, test)
# Port operates with absolute paths.
expected_file = port.expected_filename(test, '.txt')
- print test
+ _log.info(test)
self._replace_expectation_with_remote_result(expected_file, results_url)
# FIXME: We should handle new results too.