def _is_dup_baseline(self, new_baseline, baseline_path, test, suffix, platform): """Check whether a baseline is duplicate and can fallback to same baseline for another platform. For example, if a test has same baseline on linux and windows, then we only store windows baseline and linux baseline will fallback to the windows version. Args: expected_filename: baseline expectation file name. test: test name. suffix: file suffix of the expected results, including dot; e.g. '.txt' or '.png'. platform: baseline platform 'mac', 'win' or 'linux'. Returns: True if the baseline is unnecessary. False otherwise. """ test_filepath = os.path.join(path_utils.layout_tests_dir(), test) all_baselines = path_utils.expected_baselines(test_filepath, suffix, platform, True) for (fallback_dir, fallback_file) in all_baselines: if fallback_dir and fallback_file: fallback_fullpath = os.path.normpath( os.path.join(fallback_dir, fallback_file)) if fallback_fullpath.lower() != baseline_path.lower(): if not self._diff_baselines(new_baseline, fallback_fullpath): logging.info(' Found same baseline at %s', fallback_fullpath) return True else: return False return False
def _generate_html_for_one_test(self, test): """Generate html for one rebaselining test. Args: test: layout test name Returns: html that compares baseline results for the test. """ test_basename = os.path.basename(os.path.splitext(test)[0]) logging.info(' basename: "%s"', test_basename) rows = [] for suffix in BASELINE_SUFFIXES: if suffix == '.checksum': continue logging.info(' Checking %s files', suffix) for platform in self._platforms: links = self._generate_baseline_links(test_basename, suffix, platform) if links: row = self.HTML_TD_NOLINK % self._get_baseline_result_type( suffix) row += self.HTML_TD_NOLINK % platform row += links logging.debug(' html row: %s', row) rows.append(self.HTML_TR % row) if rows: test_path = os.path.join(path_utils.layout_tests_dir(), test) html = self.HTML_TR_TEST % (path_utils.filename_to_uri(test_path), test) html += self.HTML_TEST_DETAIL % ' '.join(rows) logging.debug(' html for test: %s', html) return self.HTML_TABLE_TEST % html return ''