From 219c14d14bffd4d8261c603a2b0a63a22cb9f56b Mon Sep 17 00:00:00 2001 From: Michael Achenbach Date: Thu, 16 Feb 2017 14:11:14 +0100 Subject: [PATCH] [test] Do status-file presubmit check for any test file changes. Before this change, presubmit on upload/commit would miss checking status files when e.g. test files were deleted. But the status file check in CI will enforce that all referenced test files exist. NOTRY=true Change-Id: I6069563a0a4e98406977dbce2ae44b299f7cd4b0 Reviewed-on: https://chromium-review.googlesource.com/443467 Reviewed-by: Jakob Kummerow Commit-Queue: Michael Achenbach Cr-Commit-Position: refs/heads/master@{#43270} --- PRESUBMIT.py | 2 +- tools/presubmit.py | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 8321f5cedf..4cacf81133 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -79,7 +79,7 @@ def _V8PresubmitChecks(input_api, output_api): "Copyright header, trailing whitespaces and two empty lines " \ "between declarations check failed")) if not StatusFilesProcessor().RunOnFiles( - input_api.AffectedFiles(include_deletes=False)): + input_api.AffectedFiles(include_deletes=True)): results.append(output_api.PresubmitError("Status file check failed")) results.extend(input_api.canned_checks.CheckAuthorizedAuthor( input_api, output_api)) diff --git a/tools/presubmit.py b/tools/presubmit.py index 9e9394560b..e8ab511479 100755 --- a/tools/presubmit.py +++ b/tools/presubmit.py @@ -485,14 +485,32 @@ class StatusFilesProcessor(SourceFileProcessor): """Checks status files for incorrect syntax and duplicate keys.""" def IsRelevant(self, name): - return name.endswith('.status') + # Several changes to files under the test directories could impact status + # files. + return True def GetPathsToSearch(self): return ['test'] def ProcessFiles(self, files): + test_path = join(dirname(TOOLS_PATH), 'test') + status_files = set([]) + for file_path in files: + if file_path.startswith(test_path): + # Strip off absolute path prefix pointing to test suites. + pieces = file_path[len(test_path):].lstrip(os.sep).split(os.sep) + if pieces: + # Infer affected status file name. Only care for existing status + # files. Some directories under "test" don't have any. + if not os.path.isdir(join(test_path, pieces[0])): + continue + status_file = join(test_path, pieces[0], pieces[0] + ".status") + if not os.path.exists(status_file): + continue + status_files.add(status_file) + success = True - for status_file_path in files: + for status_file_path in sorted(status_files): success &= statusfile.PresubmitCheck(status_file_path) success &= _CheckStatusFileForDuplicateKeys(status_file_path) return success