Commit e1702667 authored by gayane's avatar gayane Committed by Commit bot

Looking into all changed files to find actions.xml.

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}
parent 80295948
...@@ -24,6 +24,7 @@ class MockInputApi(object): ...@@ -24,6 +24,7 @@ class MockInputApi(object):
self.subprocess = subprocess self.subprocess = subprocess
self.files = [] self.files = []
self.is_committing = False self.is_committing = False
self.change = MockChange([])
def AffectedFiles(self, file_filter=None): def AffectedFiles(self, file_filter=None):
return self.files return self.files
......
...@@ -12,8 +12,8 @@ ACTION_XML_PATH = '../../../tools/metrics/actions/actions.xml' ...@@ -12,8 +12,8 @@ ACTION_XML_PATH = '../../../tools/metrics/actions/actions.xml'
def CheckUserActionUpdate(input_api, output_api, action_xml_path): def CheckUserActionUpdate(input_api, output_api, action_xml_path):
"""Checks if any new user action has been added.""" """Checks if any new user action has been added."""
if any('actions.xml' == input_api.os_path.basename(f.LocalPath()) for f in if any('actions.xml' == input_api.os_path.basename(f) for f in
input_api.AffectedFiles()): input_api.change.LocalPaths()):
# If actions.xml is already included in the changelist, the PRESUBMIT # If actions.xml is already included in the changelist, the PRESUBMIT
# for actions.xml will do a more complete presubmit check. # for actions.xml will do a more complete presubmit check.
return [] return []
......
...@@ -11,16 +11,17 @@ import PRESUBMIT ...@@ -11,16 +11,17 @@ import PRESUBMIT
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname( sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(
os.path.abspath(__file__)))))) 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): class HTMLActionAdditionTest(unittest.TestCase):
def testActionXMLChanged(self): def testActionXMLChanged(self):
mock_input_api = MockInputApi() mock_input_api = MockInputApi()
mock_input_api.files = [ lines = ['<input id="testinput" pref="testpref"',
MockFile('path/valid.html', ''), 'metric="validaction" type="checkbox" dialog-pref>']
MockFile('actions.xml', '') ] mock_input_api.files = [MockFile('path/valid.html', lines)]
mock_input_api.change = MockChange(['path/valid.html','actions.xml'])
action_xml_path = self._createActionXMLFile() action_xml_path = self._createActionXMLFile()
self.assertEqual([], PRESUBMIT.CheckUserActionUpdate(mock_input_api, self.assertEqual([], PRESUBMIT.CheckUserActionUpdate(mock_input_api,
MockOutputApi(), MockOutputApi(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment