Commit 75898b6c authored by Richard Townsend's avatar Richard Townsend Committed by Commit Bot

web_tests: fix a crash when baselines are missing

This fixes a problem when using run_web_tests.py with --copy-baselines
when the original test expectation does not exist for some reason.

Change-Id: I43fafb982936173639d213a0fa560ef976e13fe8
Reviewed-on: https://chromium-review.googlesource.com/c/1311929
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605940}
parent 380eb2e0
...@@ -231,7 +231,11 @@ class SingleTestRunner(object): ...@@ -231,7 +231,11 @@ class SingleTestRunner(object):
port.update_baseline(output_path, data) port.update_baseline(output_path, data)
else: else:
_log.info('Copying baseline to "%s"', port.relative_test_filename(output_path)) _log.info('Copying baseline to "%s"', port.relative_test_filename(output_path))
fs.copyfile(current_expected_path, output_path) if fs.exists(current_expected_path):
fs.copyfile(current_expected_path, output_path)
else:
_log.error('Could not copy baseline to "%s" from "%s" because the source file does not exist',
port.relative_test_filename(output_path), current_expected_path)
def _handle_error(self, driver_output, reference_filename=None): def _handle_error(self, driver_output, reference_filename=None):
"""Returns test failures if some unusual errors happen in driver's run. """Returns test failures if some unusual errors happen in driver's run.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment