forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPRESUBMIT_test.py
executable file
·35 lines (29 loc) · 1.2 KB
/
PRESUBMIT_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/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.
import os
import sys
import unittest
import PRESUBMIT
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from PRESUBMIT_test_mocks import MockFile, MockInputApi
class InvalidOSMacroNamesTest(unittest.TestCase):
def testChromeDoesNotUseOSAPPLE(self):
lines = ['#if defined(OS_APPLE)',
'#error OS_APPLE not allowed',
'#endif']
errors = PRESUBMIT._CheckNoOSAPPLEMacrosInChromeFile(
MockInputApi(), MockFile('chrome/path/foo_platform.cc', lines))
self.assertEqual(1, len(errors))
self.assertEqual(' chrome/path/foo_platform.cc:1', errors[0])
def testChromeDoesNotUseOSIOS(self):
lines = ['#if defined(OS_IOS)',
'#error OS_IOS not allowed',
'#endif']
errors = PRESUBMIT._CheckNoOSIOSMacrosInChromeFile(
MockInputApi(), MockFile('chrome/path/foo_platform.cc', lines))
self.assertEqual(1, len(errors))
self.assertEqual(' chrome/path/foo_platform.cc:1', errors[0])
if __name__ == '__main__':
unittest.main()