PRESUBMIT_test.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env python3
  2. # Copyright 2017 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. import os
  6. import sys
  7. import unittest
  8. import PRESUBMIT
  9. sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  10. from PRESUBMIT_test_mocks import MockFile, MockInputApi
  11. class DisallowedBuildFlagsTest(unittest.TestCase):
  12. def testChromeDoesNotUseISAPPLE(self):
  13. lines = ['#if BUILDFLAG(IS_APPLE)',
  14. '#error IS_APPLE not allowed',
  15. '#endif']
  16. errors = PRESUBMIT._CheckNoIsAppleBuildFlagsInChromeFile(
  17. MockInputApi(), MockFile('chrome/path/foo_platform.cc', lines))
  18. self.assertEqual(1, len(errors))
  19. self.assertEqual(' chrome/path/foo_platform.cc:1', errors[0])
  20. def testChromeDoesNotUseISIOS(self):
  21. lines = ['#if BUILDFLAG(IS_IOS)',
  22. '#error IS_IOS not allowed',
  23. '#endif']
  24. errors = PRESUBMIT._CheckNoIsIOSBuildFlagsInChromeFile(
  25. MockInputApi(), MockFile('chrome/path/foo_platform.cc', lines))
  26. self.assertEqual(1, len(errors))
  27. self.assertEqual(' chrome/path/foo_platform.cc:1', errors[0])
  28. if __name__ == '__main__':
  29. unittest.main()