| 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 12 matching lines...) Expand all Loading... |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 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 TestResultWrite
r | 34 from webkitpy.layout_tests.controllers.test_result_writer import TestResultWrite
r |
| 34 from webkitpy.tool.commands.rebaseline import AbstractRebaseliningCommand | 35 from webkitpy.tool.commands.rebaseline import AbstractRebaseliningCommand |
| 35 | 36 |
| 36 | 37 |
| 37 _log = logging.getLogger(__name__) | 38 _log = logging.getLogger(__name__) |
| 38 | 39 |
| 39 | 40 |
| 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): | 41 class AnalyzeBaselines(AbstractRebaseliningCommand): |
| 46 name = "analyze-baselines" | 42 name = "analyze-baselines" |
| 47 help_text = "Analyzes the baselines for the given tests and prints results t
hat are identical." | 43 help_text = "Analyzes the baselines for the given tests and prints results t
hat are identical." |
| 48 show_in_main_help = True | 44 show_in_main_help = True |
| 49 argument_names = "TEST_NAMES" | 45 argument_names = "TEST_NAMES" |
| 50 | 46 |
| 51 def __init__(self): | 47 def __init__(self): |
| 52 super(AnalyzeBaselines, self).__init__(options=[ | 48 super(AnalyzeBaselines, self).__init__(options=[ |
| 53 self.suffixes_option, | 49 self.suffixes_option, |
| 54 optparse.make_option('--missing', action='store_true', default=False
, help='Show missing baselines as well.'), | 50 optparse.make_option('--missing', action='store_true', default=False
, help='Show missing baselines as well.'), |
| 55 ] + self.platform_options) | 51 ] + self.platform_options) |
| 56 self._optimizer_class = BaselineOptimizer # overridable for testing | 52 self._optimizer_class = BaselineOptimizer # overridable for testing |
| 57 self._baseline_optimizer = None | 53 self._baseline_optimizer = None |
| 58 self._port = None | 54 self._port = None |
| 59 | 55 |
| 60 def _write(self, msg): | 56 def _write(self, msg): |
| 61 print msg # pylint: disable=print-statement | 57 print msg # pylint: disable=print-statement |
| 62 | 58 |
| 63 def _analyze_baseline(self, options, test_name): | 59 def _analyze_baseline(self, options, test_name): |
| 64 for suffix in self._baseline_suffix_list: | 60 for suffix in self._baseline_suffix_list: |
| 65 baseline_name = _baseline_name(self._tool.filesystem, test_name, suf
fix) | 61 name = baseline_name(self._tool.filesystem, test_name, suffix) |
| 66 results_by_directory = self._baseline_optimizer.read_results_by_dire
ctory(baseline_name) | 62 results_by_directory = self._baseline_optimizer.read_results_by_dire
ctory(name) |
| 67 if results_by_directory: | 63 if results_by_directory: |
| 68 self._write("%s:" % baseline_name) | 64 self._write("%s:" % name) |
| 69 self._baseline_optimizer.write_by_directory(results_by_directory
, self._write, " ") | 65 self._baseline_optimizer.write_by_directory(results_by_directory
, self._write, " ") |
| 70 elif options.missing: | 66 elif options.missing: |
| 71 self._write("%s: (no baselines found)" % baseline_name) | 67 self._write("%s: (no baselines found)" % name) |
| 72 | 68 |
| 73 def execute(self, options, args, tool): | 69 def execute(self, options, args, tool): |
| 74 self._baseline_suffix_list = options.suffixes.split(',') | 70 self._baseline_suffix_list = options.suffixes.split(',') |
| 75 port_names = tool.port_factory.all_port_names(options.platform) | 71 port_names = tool.port_factory.all_port_names(options.platform) |
| 76 if not port_names: | 72 if not port_names: |
| 77 _log.error("No port names match '%s'" % options.platform) | 73 _log.error("No port names match '%s'" % options.platform) |
| 78 return | 74 return |
| 79 self._port = tool.port_factory.get(port_names[0]) | 75 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) | 76 self._baseline_optimizer = self._optimizer_class(tool, self._port, port_
names, skip_scm_commands=False) |
| 81 for test_name in self._port.tests(args): | 77 for test_name in self._port.tests(args): |
| 82 self._analyze_baseline(options, test_name) | 78 self._analyze_baseline(options, test_name) |
| OLD | NEW |