Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.7 KiB

  1. #!/usr/bin/env python
  2. #
  3. # Copyright 2007, Google Inc.
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions are
  8. # met:
  9. #
  10. # * Redistributions of source code must retain the above copyright
  11. # notice, this list of conditions and the following disclaimer.
  12. # * Redistributions in binary form must reproduce the above
  13. # copyright notice, this list of conditions and the following disclaimer
  14. # in the documentation and/or other materials provided with the
  15. # distribution.
  16. # * Neither the name of Google Inc. nor the names of its
  17. # contributors may be used to endorse or promote products derived from
  18. # this software without specific prior written permission.
  19. #
  20. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. """Negative compilation test for Google Test."""
  32. __author__ = '[email protected] (Zhanyong Wan)'
  33. import os
  34. import sys
  35. import unittest
  36. IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
  37. if not IS_LINUX:
  38. sys.exit(0) # Negative compilation tests are not supported on Windows & Mac.
  39. class GTestNCTest(unittest.TestCase):
  40. """Negative compilation test for Google Test."""
  41. def testCompilerError(self):
  42. """Verifies that erroneous code leads to expected compiler
  43. messages."""
  44. # Defines a list of test specs, where each element is a tuple
  45. # (test name, list of regexes for matching the compiler errors).
  46. test_specs = [
  47. ('CANNOT_IGNORE_RUN_ALL_TESTS_RESULT',
  48. [r'ignoring return value']),
  49. ('USER_CANNOT_INCLUDE_GTEST_INTERNAL_INL_H',
  50. [r'must not be included except by Google Test itself']),
  51. ('CATCHES_DECLARING_SETUP_IN_TEST_FIXTURE_WITH_TYPO',
  52. [r'Setup_should_be_spelled_SetUp']),
  53. ('CATCHES_CALLING_SETUP_IN_TEST_WITH_TYPO',
  54. [r'Setup_should_be_spelled_SetUp']),
  55. ('CATCHES_DECLARING_SETUP_IN_ENVIRONMENT_WITH_TYPO',
  56. [r'Setup_should_be_spelled_SetUp']),
  57. ('CATCHES_CALLING_SETUP_IN_ENVIRONMENT_WITH_TYPO',
  58. [r'Setup_should_be_spelled_SetUp']),
  59. ('CATCHES_WRONG_CASE_IN_TYPED_TEST_P',
  60. [r'BarTest.*was not declared']),
  61. ('CATCHES_WRONG_CASE_IN_REGISTER_TYPED_TEST_CASE_P',
  62. [r'BarTest.*was not declared']),
  63. ('CATCHES_WRONG_CASE_IN_INSTANTIATE_TYPED_TEST_CASE_P',
  64. [r'BarTest.*not declared']),
  65. ('CATCHES_INSTANTIATE_TYPED_TESET_CASE_P_WITH_SAME_NAME_PREFIX',
  66. [r'redefinition of.*My.*FooTest']),
  67. ('STATIC_ASSERT_TYPE_EQ_IS_NOT_A_TYPE',
  68. [r'StaticAssertTypeEq.* does not name a type']),
  69. ('STATIC_ASSERT_TYPE_EQ_WORKS_IN_NAMESPACE',
  70. [r'StaticAssertTypeEq.*int.*const int']),
  71. ('STATIC_ASSERT_TYPE_EQ_WORKS_IN_CLASS',
  72. [r'StaticAssertTypeEq.*int.*bool']),
  73. ('STATIC_ASSERT_TYPE_EQ_WORKS_IN_FUNCTION',
  74. [r'StaticAssertTypeEq.*const int.*int']),
  75. ('SANITY',
  76. None)
  77. ]
  78. # TODO([email protected]): verify that the test specs are satisfied.
  79. if __name__ == '__main__':
  80. unittest.main()