From 27b2c9a3b069949673357f3afbc691bede6d39ba Mon Sep 17 00:00:00 2001 From: Edward Lemur Date: Thu, 1 Feb 2018 15:23:33 +0100 Subject: [PATCH] Add PRESUBMIT test to make sure all valgrind dependencies are listed. Add a PRESUBMIT test to make sure new valgrind runtime dependencies are listed in tools_webrtc/valgrind/valgrind-webrtc.gni, so that they are isolated and uploaded to swarming. TBR=phoglund@webrtc.org Bug: webrtc:7249 Change-Id: I090b790da0b6dd7c1e76c20f96e40df9000cbd62 Reviewed-on: https://webrtc-review.googlesource.com/42740 Commit-Queue: Edward Lemur Reviewed-by: Mirko Bonadei Cr-Commit-Position: refs/heads/master@{#21933} --- tools_webrtc/PRESUBMIT.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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):