| OLD | NEW |
| 1 # Copyright (c) 2016 Google Inc. All rights reserved. | 1 # Copyright (c) 2016 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR/ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import logging | 29 import logging |
| 30 import optparse | 30 import optparse |
| 31 | 31 |
| 32 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer | 32 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer |
| 33 from webkitpy.layout_tests.controllers.test_result_writer import baseline_name | 33 from webkitpy.layout_tests.controllers.test_result_writer import baseline_name |
| 34 from webkitpy.layout_tests.controllers.test_result_writer import TestResultWrite
r | |
| 35 from webkitpy.tool.commands.rebaseline import AbstractRebaseliningCommand | 34 from webkitpy.tool.commands.rebaseline import AbstractRebaseliningCommand |
| 36 | 35 |
| 37 | |
| 38 _log = logging.getLogger(__name__) | 36 _log = logging.getLogger(__name__) |
| 39 | 37 |
| 40 | 38 |
| 41 class AnalyzeBaselines(AbstractRebaseliningCommand): | 39 class AnalyzeBaselines(AbstractRebaseliningCommand): |
| 42 name = "analyze-baselines" | 40 name = "analyze-baselines" |
| 43 help_text = "Analyzes the baselines for the given tests and prints results t
hat are identical." | 41 help_text = "Analyzes the baselines for the given tests and prints results t
hat are identical." |
| 44 show_in_main_help = True | 42 show_in_main_help = True |
| 45 argument_names = "TEST_NAMES" | 43 argument_names = "TEST_NAMES" |
| 46 | 44 |
| 47 def __init__(self): | 45 def __init__(self): |
| 48 super(AnalyzeBaselines, self).__init__(options=[ | 46 super(AnalyzeBaselines, self).__init__(options=[ |
| 49 self.suffixes_option, | 47 self.suffixes_option, |
| 50 optparse.make_option('--missing', action='store_true', default=False
, help='Show missing baselines as well.'), | 48 optparse.make_option('--missing', action='store_true', default=False
, help='Show missing baselines as well.'), |
| 51 ] + self.platform_options) | 49 ] + self.platform_options) |
| 52 self._optimizer_class = BaselineOptimizer # overridable for testing | 50 self._optimizer_class = BaselineOptimizer # overridable for testing |
| 53 self._baseline_optimizer = None | 51 self._baseline_optimizer = None |
| 54 self._port = None | 52 self._port = None |
| 53 self._tool = None |
| 55 | 54 |
| 56 def _write(self, msg): | 55 def _write(self, msg): |
| 57 print msg | 56 print msg |
| 58 | 57 |
| 59 def _analyze_baseline(self, options, test_name): | 58 def _analyze_baseline(self, options, test_name): |
| 60 for suffix in self._baseline_suffix_list: | 59 for suffix in self._baseline_suffix_list: |
| 61 name = baseline_name(self._tool.filesystem, test_name, suffix) | 60 name = baseline_name(self._tool.filesystem, test_name, suffix) |
| 62 results_by_directory = self._baseline_optimizer.read_results_by_dire
ctory(name) | 61 results_by_directory = self._baseline_optimizer.read_results_by_dire
ctory(name) |
| 63 if results_by_directory: | 62 if results_by_directory: |
| 64 self._write("%s:" % name) | 63 self._write("%s:" % name) |
| 65 self._baseline_optimizer.write_by_directory(results_by_directory
, self._write, " ") | 64 self._baseline_optimizer.write_by_directory(results_by_directory
, self._write, " ") |
| 66 elif options.missing: | 65 elif options.missing: |
| 67 self._write("%s: (no baselines found)" % name) | 66 self._write("%s: (no baselines found)" % name) |
| 68 | 67 |
| 69 def execute(self, options, args, tool): | 68 def execute(self, options, args, tool): |
| 69 self._tool = tool |
| 70 self._baseline_suffix_list = options.suffixes.split(',') | 70 self._baseline_suffix_list = options.suffixes.split(',') |
| 71 port_names = tool.port_factory.all_port_names(options.platform) | 71 port_names = tool.port_factory.all_port_names(options.platform) |
| 72 if not port_names: | 72 if not port_names: |
| 73 _log.error("No port names match '%s'", options.platform) | 73 _log.error("No port names match '%s'", options.platform) |
| 74 return | 74 return |
| 75 self._port = tool.port_factory.get(port_names[0]) | 75 self._port = tool.port_factory.get(port_names[0]) |
| 76 self._baseline_optimizer = self._optimizer_class(tool, self._port, port_
names, skip_scm_commands=False) | 76 self._baseline_optimizer = self._optimizer_class(tool, self._port, port_
names, skip_scm_commands=False) |
| 77 for test_name in self._port.tests(args): | 77 for test_name in self._port.tests(args): |
| 78 self._analyze_baseline(options, test_name) | 78 self._analyze_baseline(options, test_name) |
| OLD | NEW |