From cdc7defb018587e3dd6ce6da9e962c281f34b725 Mon Sep 17 00:00:00 2001 From: Vaclav Brozek Date: Tue, 20 Mar 2018 09:54:35 +0000 Subject: [PATCH] Run PRESUBMIT_test.py in subdirectories Right now, changes to //PRESUBMIT.py trigger running //PRESUBMIT_test.py during presubmit checks. However, this does not happen for PRESUBMITs in subdirectories, of which there is a number with associated PRESUBMIT_test. This CL allows running the associated PRESUBMIT_test. Bug: 821981 Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation;master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs Change-Id: I057f4d736992795dde7dd0d329ed3773d22553dc Reviewed-on: https://chromium-review.googlesource.com/966906 Commit-Queue: Vaclav Brozek Reviewed-by: Daniel Cheng Reviewed-by: Jochen Eisinger Cr-Commit-Position: refs/heads/master@{#544318} --- PRESUBMIT.py | 12 +++++++----- chrome/browser/resources/PRESUBMIT_test.py | 1 + ios/PRESUBMIT_test.py | 1 + media/PRESUBMIT_test.py | 1 + third_party/WebKit/PRESUBMIT_test.py | 1 + 5 files changed, 11 insertions(+), 5 deletions(-) mode change 100644 => 100755 chrome/browser/resources/PRESUBMIT_test.py mode change 100644 => 100755 ios/PRESUBMIT_test.py mode change 100644 => 100755 media/PRESUBMIT_test.py mode change 100644 => 100755 third_party/WebKit/PRESUBMIT_test.py diff --git a/PRESUBMIT.py b/PRESUBMIT.py index b877faa8cb4f8f..117881c06d63da 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -2633,11 +2633,13 @@ def _CommonChecks(input_api, output_api): results.extend(input_api.RunTests( input_api.canned_checks.CheckVPythonSpec(input_api, output_api))) - if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): - results.extend(input_api.canned_checks.RunUnitTestsInDirectory( - input_api, output_api, - input_api.PresubmitLocalPath(), - whitelist=[r'^PRESUBMIT_test\.py$'])) + for f in input_api.AffectedFiles(): + path, name = input_api.os_path.split(f.LocalPath()) + if name == 'PRESUBMIT.py': + full_path = input_api.os_path.join(input_api.PresubmitLocalPath(), path) + results.extend(input_api.canned_checks.RunUnitTestsInDirectory( + input_api, output_api, full_path, + whitelist=[r'^PRESUBMIT_test\.py$'])) return results diff --git a/chrome/browser/resources/PRESUBMIT_test.py b/chrome/browser/resources/PRESUBMIT_test.py old mode 100644 new mode 100755 index 923f2be1f4cad1..c7412927c8904d --- a/chrome/browser/resources/PRESUBMIT_test.py +++ b/chrome/browser/resources/PRESUBMIT_test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/ios/PRESUBMIT_test.py b/ios/PRESUBMIT_test.py old mode 100644 new mode 100755 index 48c5a36b57e008..bc5acaf19e765b --- a/ios/PRESUBMIT_test.py +++ b/ios/PRESUBMIT_test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # Copyright 2017 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/media/PRESUBMIT_test.py b/media/PRESUBMIT_test.py old mode 100644 new mode 100755 index f537a6d509056e..6ca6687ab43d42 --- a/media/PRESUBMIT_test.py +++ b/media/PRESUBMIT_test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/third_party/WebKit/PRESUBMIT_test.py b/third_party/WebKit/PRESUBMIT_test.py old mode 100644 new mode 100755 index c1ff0b0917b987..5bbfafeaed646a --- a/third_party/WebKit/PRESUBMIT_test.py +++ b/third_party/WebKit/PRESUBMIT_test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # Copyright 2017 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.