0
Files
src/chrome/PRESUBMIT_test.py
Lei Zhang a4561e708f Disallow OS_APPLE in chrome/.
OS_APPLE means OS_MAC or OS_IOS. Since OS_IOS is disallowed in chrome/,
it makes more sense to use OS_MAC in chrome/ instead of OS_APPLE.

Replace existing OS_APPLE usage with OS_MAC, and add a presubmit to
check for OS_APPLE usage.

Change-Id: I539f062f5f82a93dcbd861501421977e4f027517
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2365434
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800196}
2020-08-20 17:09:15 +00:00

36 lines
1.2 KiB
Python
Executable File

#!/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()