| 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 failures = [] | 304 failures = [] |
| 305 if (expected_audio and actual_audio and | 305 if (expected_audio and actual_audio and |
| 306 self._port.do_audio_results_differ(expected_audio, actual_audio)): | 306 self._port.do_audio_results_differ(expected_audio, actual_audio)): |
| 307 failures.append(test_failures.FailureAudioMismatch()) | 307 failures.append(test_failures.FailureAudioMismatch()) |
| 308 elif actual_audio and not expected_audio: | 308 elif actual_audio and not expected_audio: |
| 309 failures.append(test_failures.FailureMissingAudio()) | 309 failures.append(test_failures.FailureMissingAudio()) |
| 310 return failures | 310 return failures |
| 311 | 311 |
| 312 _observatory_cleaner = re.compile(r"^Observatory.*\n", re.MULTILINE) | 312 _observatory_cleaner = re.compile(r"^Observatory.*\n", re.MULTILINE) |
| 313 _console_observatory_cleaner = re.compile(r"^CONSOLE INFO: Observatory.*\n",
re.MULTILINE) | 313 _console_observatory_cleaner = re.compile(r"^CONSOLE INFO: Observatory.*\n",
re.MULTILINE) |
| 314 _line_number_cleaner = re.compile(r"\(dart:(\w+):\d+\)", re.MULTILINE) |
| 315 |
| 316 def _line_number_substitution(self, match): |
| 317 return "(dart:" + match.group(1) + ":xxxx)" |
| 314 | 318 |
| 315 def _get_normalized_output_text(self, output): | 319 def _get_normalized_output_text(self, output): |
| 316 """Returns the normalized text output, i.e. the output in which | 320 """Returns the normalized text output, i.e. the output in which |
| 317 the end-of-line characters are normalized to "\n".""" | 321 the end-of-line characters are normalized to "\n".""" |
| 318 # Running tests on Windows produces "\r\n". The "\n" part is helpfully | 322 # Running tests on Windows produces "\r\n". The "\n" part is helpfully |
| 319 # changed to "\r\n" by our system (Python/Cygwin), resulting in | 323 # changed to "\r\n" by our system (Python/Cygwin), resulting in |
| 320 # "\r\r\n", when, in fact, we wanted to compare the text output with | 324 # "\r\r\n", when, in fact, we wanted to compare the text output with |
| 321 # the normalized text expectation files. | 325 # the normalized text expectation files. |
| 322 normalized_lines = output.replace("\r\r\n", "\r\n").replace("\r\n", "\n"
) | 326 normalized_lines = output.replace("\r\r\n", "\r\n").replace("\r\n", "\n"
) |
| 323 normalized_lines = re.sub(self._observatory_cleaner, r"", normalized_lin
es) | 327 normalized_lines = re.sub(self._observatory_cleaner, r"", normalized_lin
es) |
| 324 normalized_lines = re.sub(self._console_observatory_cleaner, r"", normal
ized_lines) | 328 normalized_lines = re.sub(self._console_observatory_cleaner, r"", normal
ized_lines) |
| 329 normalized_lines = re.sub(self._line_number_cleaner, self._line_number_s
ubstitution, normalized_lines) |
| 325 return normalized_lines | 330 return normalized_lines |
| 326 | 331 |
| 327 # FIXME: This function also creates the image diff. Maybe that work should | 332 # FIXME: This function also creates the image diff. Maybe that work should |
| 328 # be handled elsewhere? | 333 # be handled elsewhere? |
| 329 def _compare_image(self, expected_driver_output, driver_output): | 334 def _compare_image(self, expected_driver_output, driver_output): |
| 330 failures = [] | 335 failures = [] |
| 331 # If we didn't produce a hash file, this test must be text-only. | 336 # If we didn't produce a hash file, this test must be text-only. |
| 332 if driver_output.image_hash is None: | 337 if driver_output.image_hash is None: |
| 333 return failures | 338 return failures |
| 334 if not expected_driver_output.image: | 339 if not expected_driver_output.image: |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 elif reference_driver_output.image_hash != actual_driver_output.image_ha
sh: | 427 elif reference_driver_output.image_hash != actual_driver_output.image_ha
sh: |
| 423 diff, err_str = self._port.diff_image(reference_driver_output.image,
actual_driver_output.image) | 428 diff, err_str = self._port.diff_image(reference_driver_output.image,
actual_driver_output.image) |
| 424 if diff: | 429 if diff: |
| 425 failures.append(test_failures.FailureReftestMismatch(reference_f
ilename)) | 430 failures.append(test_failures.FailureReftestMismatch(reference_f
ilename)) |
| 426 elif err_str: | 431 elif err_str: |
| 427 _log.error(err_str) | 432 _log.error(err_str) |
| 428 else: | 433 else: |
| 429 _log.warning(" %s -> ref test hashes didn't match but diff pass
ed" % self._test_name) | 434 _log.warning(" %s -> ref test hashes didn't match but diff pass
ed" % self._test_name) |
| 430 | 435 |
| 431 return TestResult(self._test_name, failures, total_test_time, has_stderr
, pid=actual_driver_output.pid) | 436 return TestResult(self._test_name, failures, total_test_time, has_stderr
, pid=actual_driver_output.pid) |
| OLD | NEW |