| OLD | NEW |
| 1 # Copyright (C) 2011, Google Inc. All rights reserved. | 1 # Copyright (C) 2011, 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 def write_by_directory(self, results_by_directory, writer, indent): | 278 def write_by_directory(self, results_by_directory, writer, indent): |
| 279 for path in sorted(results_by_directory): | 279 for path in sorted(results_by_directory): |
| 280 writer("%s%s: %s" % (indent, self._platform(path), results_by_direct
ory[path][0:6])) | 280 writer("%s%s: %s" % (indent, self._platform(path), results_by_direct
ory[path][0:6])) |
| 281 | 281 |
| 282 def _optimize_subtree(self, baseline_name): | 282 def _optimize_subtree(self, baseline_name): |
| 283 basename = self._filesystem.basename(baseline_name) | 283 basename = self._filesystem.basename(baseline_name) |
| 284 results_by_directory, new_results_by_directory = self._find_optimal_resu
lt_placement(baseline_name) | 284 results_by_directory, new_results_by_directory = self._find_optimal_resu
lt_placement(baseline_name) |
| 285 | 285 |
| 286 if new_results_by_directory == results_by_directory: | 286 if new_results_by_directory == results_by_directory: |
| 287 if new_results_by_directory: | 287 if new_results_by_directory: |
| 288 _log.debug(" %s: (already optimal)" % basename) | 288 _log.debug(" %s: (already optimal)", basename) |
| 289 self.write_by_directory(results_by_directory, _log.debug, " "
) | 289 self.write_by_directory(results_by_directory, _log.debug, " "
) |
| 290 else: | 290 else: |
| 291 _log.debug(" %s: (no baselines found)" % basename) | 291 _log.debug(" %s: (no baselines found)", basename) |
| 292 # This is just used for unittests. Intentionally set it to the old d
ata if we don't modify anything. | 292 # This is just used for unittests. Intentionally set it to the old d
ata if we don't modify anything. |
| 293 self.new_results_by_directory.append(results_by_directory) | 293 self.new_results_by_directory.append(results_by_directory) |
| 294 return True | 294 return True |
| 295 | 295 |
| 296 if self._results_by_port_name(results_by_directory, baseline_name) != se
lf._results_by_port_name( | 296 if self._results_by_port_name(results_by_directory, baseline_name) != se
lf._results_by_port_name( |
| 297 new_results_by_directory, baseline_name): | 297 new_results_by_directory, baseline_name): |
| 298 # This really should never happen. Just a sanity check to make sure
the script fails in the case of bugs | 298 # This really should never happen. Just a sanity check to make sure
the script fails in the case of bugs |
| 299 # instead of committing incorrect baselines. | 299 # instead of committing incorrect baselines. |
| 300 _log.error(" %s: optimization failed" % basename) | 300 _log.error(" %s: optimization failed", basename) |
| 301 self.write_by_directory(results_by_directory, _log.warning, " "
) | 301 self.write_by_directory(results_by_directory, _log.warning, " "
) |
| 302 return False | 302 return False |
| 303 | 303 |
| 304 _log.debug(" %s:" % basename) | 304 _log.debug(" %s:", basename) |
| 305 _log.debug(" Before: ") | 305 _log.debug(" Before: ") |
| 306 self.write_by_directory(results_by_directory, _log.debug, " ") | 306 self.write_by_directory(results_by_directory, _log.debug, " ") |
| 307 _log.debug(" After: ") | 307 _log.debug(" After: ") |
| 308 self.write_by_directory(new_results_by_directory, _log.debug, " ") | 308 self.write_by_directory(new_results_by_directory, _log.debug, " ") |
| 309 | 309 |
| 310 self._move_baselines(baseline_name, results_by_directory, new_results_by
_directory) | 310 self._move_baselines(baseline_name, results_by_directory, new_results_by
_directory) |
| 311 return True | 311 return True |
| 312 | 312 |
| 313 def _optimize_virtual_root(self, baseline_name, non_virtual_baseline_name): | 313 def _optimize_virtual_root(self, baseline_name, non_virtual_baseline_name): |
| 314 virtual_root_expected_baseline_path = self._filesystem.join(self._layout
_tests_dir, baseline_name) | 314 virtual_root_expected_baseline_path = self._filesystem.join(self._layout
_tests_dir, baseline_name) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 result = self._optimize_subtree(baseline_name) | 353 result = self._optimize_subtree(baseline_name) |
| 354 non_virtual_baseline_name = self._virtual_base(baseline_name) | 354 non_virtual_baseline_name = self._virtual_base(baseline_name) |
| 355 if not non_virtual_baseline_name: | 355 if not non_virtual_baseline_name: |
| 356 return result, self._files_to_delete, self._files_to_add | 356 return result, self._files_to_delete, self._files_to_add |
| 357 | 357 |
| 358 self._optimize_virtual_root(baseline_name, non_virtual_baseline_name) | 358 self._optimize_virtual_root(baseline_name, non_virtual_baseline_name) |
| 359 | 359 |
| 360 _log.debug("Optimizing non-virtual fallback path.") | 360 _log.debug("Optimizing non-virtual fallback path.") |
| 361 result |= self._optimize_subtree(non_virtual_baseline_name) | 361 result |= self._optimize_subtree(non_virtual_baseline_name) |
| 362 return result, self._files_to_delete, self._files_to_add | 362 return result, self._files_to_delete, self._files_to_add |
| OLD | NEW |