[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 <jkummerow@chromium.org> Commit-Queue: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#43270}
This commit is contained in:
parent
0a8de761ff
commit
219c14d14b
@ -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))
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user