Skip to content

Commit

Permalink
Looking into all changed files to find actions.xml.
Browse files Browse the repository at this point in the history
In case actions.xml is included in the changelist the chrome/browser/resources/PRESUBMIT.py shouldn't run because the presubmit for actions.xml will do more complete job.

Fixing the bug to look into all changed files in the CL where previously it was only looking at subdirectories of current presubmit script to find actions.xml

BUG=439978

Review URL: https://codereview.chromium.org/760163004

Cr-Commit-Position: refs/heads/master@{#308244}
  • Loading branch information
gayane authored and Commit bot committed Dec 13, 2014
1 parent 8029594 commit e170266
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions PRESUBMIT_test_mocks.py
Expand Up @@ -24,6 +24,7 @@ def __init__(self):
self.subprocess = subprocess
self.files = []
self.is_committing = False
self.change = MockChange([])

def AffectedFiles(self, file_filter=None):
return self.files
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/resources/PRESUBMIT.py
Expand Up @@ -12,8 +12,8 @@

def CheckUserActionUpdate(input_api, output_api, action_xml_path):
"""Checks if any new user action has been added."""
if any('actions.xml' == input_api.os_path.basename(f.LocalPath()) for f in
input_api.AffectedFiles()):
if any('actions.xml' == input_api.os_path.basename(f) for f in
input_api.change.LocalPaths()):
# If actions.xml is already included in the changelist, the PRESUBMIT
# for actions.xml will do a more complete presubmit check.
return []
Expand Down
11 changes: 6 additions & 5 deletions chrome/browser/resources/PRESUBMIT_test.py
Expand Up @@ -11,16 +11,17 @@

sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(
os.path.abspath(__file__))))))
from PRESUBMIT_test_mocks import MockFile, MockInputApi, MockOutputApi
from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi
from PRESUBMIT_test_mocks import MockFile, MockChange

class HTMLActionAdditionTest(unittest.TestCase):

def testActionXMLChanged(self):
mock_input_api = MockInputApi()
mock_input_api.files = [
MockFile('path/valid.html', ''),
MockFile('actions.xml', '') ]

lines = ['<input id="testinput" pref="testpref"',
'metric="validaction" type="checkbox" dialog-pref>']
mock_input_api.files = [MockFile('path/valid.html', lines)]
mock_input_api.change = MockChange(['path/valid.html','actions.xml'])
action_xml_path = self._createActionXMLFile()
self.assertEqual([], PRESUBMIT.CheckUserActionUpdate(mock_input_api,
MockOutputApi(),
Expand Down

0 comments on commit e170266

Please sign in to comment.