diff --git a/tools_webrtc/PRESUBMIT.py b/tools_webrtc/PRESUBMIT.py index 2f7b835ba9..c2dfd0e6fd 100644 --- a/tools_webrtc/PRESUBMIT.py +++ b/tools_webrtc/PRESUBMIT.py @@ -6,6 +6,9 @@ # in the file PATENTS. All contributing project authors may # be found in the AUTHORS file in the root of the source tree. +import os + + def _LicenseHeader(input_api): """Returns the license header regexp.""" # Accept any year number from 2003 to the current year @@ -27,11 +30,34 @@ def _LicenseHeader(input_api): } return license_header +def _CheckValgrindFiles(input_api, output_api): + """Check that valgrind-webrtc.gni contains all existing files.""" + valgrind_dir = os.path.join('tools_webrtc', 'valgrind') + with open(os.path.join('valgrind', 'valgrind-webrtc.gni')) as f: + valgrind_webrtc = f.read() + + results = [] + for f in input_api.AffectedFiles(): + f = f.LocalPath() + if (f.startswith(valgrind_dir) + and f not in valgrind_webrtc + and not f.endswith('valgrind-webrtc.gni')): + results.append(' * %s\n' % f) + + if results: + results = [output_api.PresubmitError( + 'The following files are not listed in ' + 'tools_webrtc/valgrind/valgrind-webrt.gni. Please add them, so they can ' + 'be isolated and uploaded to swarming:\n' + + ''.join(file_path for file_path in results))] + return results + def _CommonChecks(input_api, output_api): """Checks common to both upload and commit.""" results = [] results.extend(input_api.canned_checks.CheckLicense( input_api, output_api, _LicenseHeader(input_api))) + results.extend(_CheckValgrindFiles(input_api, output_api)) return results def CheckChangeOnUpload(input_api, output_api):