Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/analyze_baselines.py

Issue 2019243002: Extract analyze-baselines command out of rebaseline.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/analyze_baselines_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2016 Google Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met:
6 #
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
12 # distribution.
13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR/ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 import logging
30 import optparse
31
32 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer
33 from webkitpy.layout_tests.controllers.test_result_writer import TestResultWrite r
34 from webkitpy.tool.commands.rebaseline import AbstractRebaseliningCommand
35
36
37 _log = logging.getLogger(__name__)
38
39
40 # FIXME: Should TestResultWriter know how to compute this string?
41 def _baseline_name(fs, test_name, suffix):
42 return fs.splitext(test_name)[0] + TestResultWriter.FILENAME_SUFFIX_EXPECTED + "." + suffix
43
44
45 class AnalyzeBaselines(AbstractRebaseliningCommand):
46 name = "analyze-baselines"
47 help_text = "Analyzes the baselines for the given tests and prints results t hat are identical."
48 show_in_main_help = True
49 argument_names = "TEST_NAMES"
50
51 def __init__(self):
52 super(AnalyzeBaselines, self).__init__(options=[
53 self.suffixes_option,
54 optparse.make_option('--missing', action='store_true', default=False , help='Show missing baselines as well.'),
55 ] + self.platform_options)
56 self._optimizer_class = BaselineOptimizer # overridable for testing
57 self._baseline_optimizer = None
58 self._port = None
59
60 def _write(self, msg):
61 print msg # pylint: disable=print-statement
62
63 def _analyze_baseline(self, options, test_name):
64 for suffix in self._baseline_suffix_list:
65 baseline_name = _baseline_name(self._tool.filesystem, test_name, suf fix)
66 results_by_directory = self._baseline_optimizer.read_results_by_dire ctory(baseline_name)
67 if results_by_directory:
68 self._write("%s:" % baseline_name)
69 self._baseline_optimizer.write_by_directory(results_by_directory , self._write, " ")
70 elif options.missing:
71 self._write("%s: (no baselines found)" % baseline_name)
72
73 def execute(self, options, args, tool):
74 self._baseline_suffix_list = options.suffixes.split(',')
75 port_names = tool.port_factory.all_port_names(options.platform)
76 if not port_names:
77 _log.error("No port names match '%s'" % options.platform)
78 return
79 self._port = tool.port_factory.get(port_names[0])
80 self._baseline_optimizer = self._optimizer_class(tool, self._port, port_ names, skip_scm_commands=False)
81 for test_name in self._port.tests(args):
82 self._analyze_baseline(options, test_name)
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/analyze_baselines_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698