Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1919)

Unified Diff: chrome/common/extensions/api/PRESUBMIT_test.py

Issue 239283008: Add global presubmit that JSON and IDL files can be parsed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/api/PRESUBMIT_test.py
diff --git a/chrome/common/extensions/api/PRESUBMIT_test.py b/chrome/common/extensions/api/PRESUBMIT_test.py
deleted file mode 100755
index 88d28e6c006f8f8dd6b5600f469a8657384b85f9..0000000000000000000000000000000000000000
--- a/chrome/common/extensions/api/PRESUBMIT_test.py
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2013 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.
-
-import glob
-import json
-import os
-import subprocess
-import sys
-import unittest
-
-import PRESUBMIT
-
-
-class MockInputApi(object):
- def __init__(self):
- self.json = json
- self.os_path = os.path
- self.subprocess = subprocess
- self.python_executable = sys.executable
-
- def PresubmitLocalPath(self):
- return os.path.dirname(__file__)
-
- def ReadFile(self, filename, mode='rU'):
- with open(filename, mode=mode) as f:
- return f.read()
-
-
-class JSONParsingTest(unittest.TestCase):
- def testSuccess(self):
- input_api = MockInputApi()
- filename = 'test_presubmit/valid_json.json'
- self.assertEqual(None,
- PRESUBMIT._GetJSONParseError(input_api, filename))
-
- def testFailure(self):
- input_api = MockInputApi()
- expected_errors = [
- 'Expecting property name: line 8 column 3 (char 9)',
- 'Invalid control character at: line 8 column 19 (char 25)',
- 'Expecting property name: line 8 column 23 (char 29)',
- 'Expecting , delimiter: line 8 column 12 (char 18)',
- ]
- actual_errors = [
- str(PRESUBMIT._GetJSONParseError(input_api, filename))
- for filename in sorted(glob.glob('test_presubmit/invalid_*.json'))
- ]
- self.assertEqual(expected_errors, actual_errors)
-
-
-class IDLParsingTest(unittest.TestCase):
- def testSuccess(self):
- input_api = MockInputApi()
- filename = 'test_presubmit/valid_idl_basics.idl'
- self.assertEqual(None,
- PRESUBMIT._GetIDLParseError(input_api, filename))
-
- def testFailure(self):
- input_api = MockInputApi()
- expected_errors = [
- 'Unexpected "{" after keyword "dictionary".',
- 'Unexpected symbol DOMString after symbol a.',
- 'Unexpected symbol name2 after symbol name1.',
- 'Trailing comma in block.',
- 'Unexpected ";" after "(".',
- 'Unexpected ")" after symbol long.',
- 'Unexpected symbol Events after symbol interace.',
- 'Did not process Interface Interface(NotEvent)',
- 'Interface missing name.',
- ]
- actual_errors = [
- PRESUBMIT._GetIDLParseError(input_api, filename)
- for filename in sorted(glob.glob('test_presubmit/invalid_*.idl'))
- ]
- for (expected_error, actual_error) in zip(expected_errors, actual_errors):
- self.assertTrue(expected_error in actual_error)
-
-
-if __name__ == "__main__":
- unittest.main()
« no previous file with comments | « chrome/common/extensions/api/PRESUBMIT.py ('k') | chrome/common/extensions/api/test_presubmit/invalid_idl_1.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698