0

Fix crash in PRESUBMIT.py when moving dirs.

If you deleted or moved a directory containing a PRESUBMIT.py file,
then the presubmit checks would crash trying to run tests in a
directory that no longer existed.

R=agable@chromium.org
BUG=834077

Change-Id: I8deb59c2d00b80f6b5215597076bba34ff1f0872
Reviewed-on: https://chromium-review.googlesource.com/1015976
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551542}
This commit is contained in:
Dirk Pranke
2018-04-18 00:53:07 +00:00
committed by Commit Bot
parent 992fabdc07
commit 3855731efe

@ -2824,9 +2824,13 @@ def _CommonChecks(input_api, output_api):
path, name = input_api.os_path.split(f.LocalPath())
if name == 'PRESUBMIT.py':
full_path = input_api.os_path.join(input_api.PresubmitLocalPath(), path)
results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
input_api, output_api, full_path,
whitelist=[r'^PRESUBMIT_test\.py$']))
if f.Action() != 'D':
# The PRESUBMIT.py file (and the directory containing it) might
# have been affected by being moved or removed, so only try to
# run the tests if they still exist.
results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
input_api, output_api, full_path,
whitelist=[r'^PRESUBMIT_test\.py$']))
return results