summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorrdevlin.cronin <rdevlin.cronin@chromium.org>2016-03-10 15:25:58 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-10 23:27:37 +0000
commit953fd79d9cebebe12504985d3ef1c9291047425a (patch)
treebde900d2233522807a004a3f486ec47a79f7d7bc /extensions
parent0958a444aefc5b2847e46dff8bc6f82fb27ec6f1 (diff)
downloadchromium_src-953fd79d9cebebe12504985d3ef1c9291047425a.zip
chromium_src-953fd79d9cebebe12504985d3ef1c9291047425a.tar.gz
chromium_src-953fd79d9cebebe12504985d3ef1c9291047425a.tar.bz2
[Closure Externs] Add more APIs to the presubmit warning list
Add a bunch of private APIs to the list that will get presubmit checks. Also normalize the paths and check that each exists. BUG=469920 Review URL: https://codereview.chromium.org/1761663002 Cr-Commit-Position: refs/heads/master@{#380488}
Diffstat (limited to 'extensions')
-rw-r--r--extensions/common/api/externs_checker.py4
-rwxr-xr-xextensions/common/api/externs_checker_test.py9
2 files changed, 12 insertions, 1 deletions
diff --git a/extensions/common/api/externs_checker.py b/extensions/common/api/externs_checker.py
index 58c0076..fd60fdd 100644
--- a/extensions/common/api/externs_checker.py
+++ b/extensions/common/api/externs_checker.py
@@ -12,6 +12,10 @@ class ExternsChecker(object):
self._output_api = output_api
self._api_pairs = api_pairs
+ for path in api_pairs.keys() + api_pairs.values():
+ if not input_api.os_path.exists(path):
+ raise OSError('Path Not Found: %s' % path)
+
def RunChecks(self):
bad_files = []
affected = [f.AbsoluteLocalPath() for f in self._input_api.AffectedFiles()]
diff --git a/extensions/common/api/externs_checker_test.py b/extensions/common/api/externs_checker_test.py
index 73b65fa..9bcc651 100755
--- a/extensions/common/api/externs_checker_test.py
+++ b/extensions/common/api/externs_checker_test.py
@@ -18,8 +18,9 @@ from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi, MockFile
class ExternsCheckerTest(unittest.TestCase):
API_PAIRS = {'a': '1', 'b': '2', 'c': '3'}
- def _runChecks(self, files):
+ def _runChecks(self, files, exists=lambda f: True):
input_api = MockInputApi()
+ input_api.os_path.exists = exists
input_api.files = [MockFile(f, '') for f in files]
output_api = MockOutputApi()
checker = ExternsChecker(input_api, output_api, self.API_PAIRS)
@@ -58,6 +59,12 @@ class ExternsCheckerTest(unittest.TestCase):
self.assertEquals(1, len(results[0].items))
self.assertEquals('c', results[0].items[0])
+ def testApiFileDoesNotExist(self):
+ exists = lambda f: f in ['a', 'b', 'c', '1', '2']
+ with self.assertRaises(OSError) as e:
+ self._runChecks(['a'], exists)
+ self.assertEqual('Path Not Found: 3', str(e.exception))
+
if __name__ == '__main__':
unittest.main()