def compare_output(self, filename, output, test_args, configuration): """Implementation of CompareOutput that checks the output image and checksum against the expected files from the LayoutTest directory. """ failures = [] # If we didn't produce a hash file, this test must be text-only. if test_args.hash is None: return failures expected_png_file = self._port.expected_filename(filename, '.png') if test_args.show_sources: _log.debug('Using %s' % expected_png_file) # Also report a missing expected PNG file. if not os.path.isfile(expected_png_file): failures.append(test_failures.FailureMissingImage(self)) # Run the fuzzymatcher r = self._port.fuzzy_diff(test_args.png_path, expected_png_file) if r != 0: failures.append(test_failures.FailureFuzzyFailure(self)) return failures
def _compare_image(self, driver_output, expected_driver_outputs): failures = [] # If we didn't produce a hash file, this test must be text-only. if driver_output.image_hash is None: return failures if not expected_driver_outputs.image: failures.append(test_failures.FailureMissingImage()) elif not expected_driver_outputs.image_hash: failures.append(test_failures.FailureMissingImageHash()) elif driver_output.image_hash != expected_driver_outputs.image_hash: failures.append(test_failures.FailureImageHashMismatch()) return failures
def test_parse_layout_test_results(self): failures = [ test_failures.FailureMissingResult(), test_failures.FailureMissingImageHash(), test_failures.FailureMissingImage() ] testname = 'fast/repaint/no-caret-repaint-in-non-content-editable-element.html' expected_results = [test_results.TestResult(testname, failures)] results = LayoutTestResults._parse_results_html( self._example_results_html) self.assertEqual(expected_results, results)
def _failures_from_row(cls, row, table_title): if table_title == cls.fail_key: return cls._failures_from_fail_row(row) if table_title == cls.crash_key: return [test_failures.FailureCrash()] if table_title == cls.webprocess_crash_key: return [test_failures.FailureCrash()] if table_title == cls.timeout_key: return [test_failures.FailureTimeout()] if table_title == cls.missing_key: return [ test_failures.FailureMissingResult(), test_failures.FailureMissingImageHash(), test_failures.FailureMissingImage() ] return None
with codecs.open(expected_hash_file, "r", "ascii") as file: expected_hash = file.read() except IOError, e: if errno.ENOENT != e.errno: raise expected_hash = '' if not os.path.isfile(expected_png_file): # Report a missing expected PNG file. self.write_output_files(port, filename, '.checksum', test_args.hash, expected_hash, encoding="ascii", print_text_diffs=False) self._copy_output_png(filename, test_args.png_path, '-actual.png') failures.append(test_failures.FailureMissingImage(self)) return failures elif test_args.hash == expected_hash: # Hash matched (no diff needed, okay to return). return failures self.write_output_files(port, filename, '.checksum', test_args.hash, expected_hash, encoding="ascii", print_text_diffs=False) self._copy_output_png(filename, test_args.png_path, '-actual.png') self._copy_output_png(filename, expected_png_file, '-expected.png') # Even though we only use the result in one codepath below but we # still need to call CreateImageDiff for other codepaths. images_are_different = self._create_image_diff(port, filename, configuration)
def compare_output(self, port, filename, output, test_args, configuration): """Implementation of CompareOutput that checks the output image and checksum against the expected files from the LayoutTest directory. """ failures = [] # If we didn't produce a hash file, this test must be text-only. if test_args.hash is None: return failures # If we're generating a new baseline, we pass. if test_args.new_baseline or test_args.reset_results: self._save_baseline_files(filename, test_args.png_path, test_args.hash, test_args.new_baseline) return failures # Compare hashes. expected_hash_file = self._port.expected_filename( filename, '.checksum') expected_png_file = self._port.expected_filename(filename, '.png') # FIXME: We repeat this pattern often, we should share code. expected_hash = '' if os.path.exists(expected_hash_file): with codecs.open(expected_hash_file, "r", "ascii") as file: expected_hash = file.read() if not os.path.isfile(expected_png_file): # Report a missing expected PNG file. self.write_output_files(port, filename, '.checksum', test_args.hash, expected_hash, encoding="ascii", print_text_diffs=False) self._copy_output_png(filename, test_args.png_path, '-actual.png') failures.append(test_failures.FailureMissingImage()) return failures elif test_args.hash == expected_hash: # Hash matched (no diff needed, okay to return). return failures self.write_output_files(port, filename, '.checksum', test_args.hash, expected_hash, encoding="ascii", print_text_diffs=False) self._copy_output_png(filename, test_args.png_path, '-actual.png') self._copy_output_png(filename, expected_png_file, '-expected.png') # Even though we only use the result in one codepath below but we # still need to call CreateImageDiff for other codepaths. images_are_different = self._create_image_diff(port, filename, configuration) if expected_hash == '': failures.append(test_failures.FailureMissingImageHash()) elif test_args.hash != expected_hash: if images_are_different: failures.append(test_failures.FailureImageHashMismatch()) else: failures.append(test_failures.FailureImageHashIncorrect()) return failures