[test] Only run presubmit for changed status files

This turns the status files check into a source processor similar to
lint and copyright check. On upload and on trybots it will only run
on the affected files.

BUG=v8:5603
NOTRY=true

Review-Url: https://codereview.chromium.org/2553633002
Cr-Commit-Position: refs/heads/master@{#41516}
This commit is contained in:
machenbach 2016-12-06 03:41:35 -08:00 committed by Commit bot
parent 3e8a67e540
commit dd0202a786
2 changed files with 20 additions and 12 deletions

View File

@ -67,7 +67,7 @@ def _V8PresubmitChecks(input_api, output_api):
input_api.PresubmitLocalPath(), 'tools')) input_api.PresubmitLocalPath(), 'tools'))
from presubmit import CppLintProcessor from presubmit import CppLintProcessor
from presubmit import SourceProcessor from presubmit import SourceProcessor
from presubmit import CheckStatusFiles from presubmit import StatusFilesProcessor
results = [] results = []
if not CppLintProcessor().RunOnFiles( if not CppLintProcessor().RunOnFiles(
@ -78,7 +78,8 @@ def _V8PresubmitChecks(input_api, output_api):
results.append(output_api.PresubmitError( results.append(output_api.PresubmitError(
"Copyright header, trailing whitespaces and two empty lines " \ "Copyright header, trailing whitespaces and two empty lines " \
"between declarations check failed")) "between declarations check failed"))
if not CheckStatusFiles(input_api.PresubmitLocalPath()): if not StatusFilesProcessor().RunOnFiles(
input_api.AffectedFiles(include_deletes=False)):
results.append(output_api.PresubmitError("Status file check failed")) results.append(output_api.PresubmitError("Status file check failed"))
results.extend(input_api.canned_checks.CheckAuthorizedAuthor( results.extend(input_api.canned_checks.CheckAuthorizedAuthor(
input_api, output_api)) input_api, output_api))

View File

@ -461,17 +461,23 @@ def _CheckStatusFileForDuplicateKeys(filepath):
json.loads(contents, object_pairs_hook=check_pairs) json.loads(contents, object_pairs_hook=check_pairs)
return status["success"] return status["success"]
def CheckStatusFiles(workspace):
success = True class StatusFilesProcessor(SourceFileProcessor):
suite_paths = utils.GetSuitePaths(join(workspace, "test")) """Checks status files for incorrect syntax and duplicate keys."""
for root in suite_paths:
suite_path = join(workspace, "test", root) def IsRelevant(self, name):
status_file_path = join(suite_path, root + ".status") return name.endswith('.status')
suite = testsuite.TestSuite.LoadTestSuite(suite_path)
if suite and exists(status_file_path): def GetPathsToSearch(self):
return ['test']
def ProcessFiles(self, files):
success = True
for status_file_path in files:
success &= statusfile.PresubmitCheck(status_file_path) success &= statusfile.PresubmitCheck(status_file_path)
success &= _CheckStatusFileForDuplicateKeys(status_file_path) success &= _CheckStatusFileForDuplicateKeys(status_file_path)
return success return success
def GetOptions(): def GetOptions():
result = optparse.OptionParser() result = optparse.OptionParser()
@ -491,7 +497,8 @@ def Main():
print "Running copyright header, trailing whitespaces and " \ print "Running copyright header, trailing whitespaces and " \
"two empty lines between declarations check..." "two empty lines between declarations check..."
success &= SourceProcessor().RunOnPath(workspace) success &= SourceProcessor().RunOnPath(workspace)
success &= CheckStatusFiles(workspace) print "Running status-files check..."
success &= StatusFilesProcessor().RunOnPath(workspace)
if success: if success:
return 0 return 0
else: else: