1 """Negative compilation tests for Google Mock macro MOCK_METHOD.""" 2 3 import os 4 import sys 5 6 IS_LINUX = os.name == "posix" and os.uname()[0] == "Linux" 7 if not IS_LINUX: 8 sys.stderr.write( 9 "WARNING: Negative compilation tests are not supported on this platform") 10 sys.exit(0) 11 12 # Suppresses the 'Import not at the top of the file' lint complaint. 13 # pylint: disable-msg=C6204 14 from google3.testing.pybase import fake_target_util 15 from google3.testing.pybase import googletest 16 17 # pylint: enable-msg=C6204 18 19 20 class GMockMethodNCTest(googletest.TestCase): 21 """Negative compilation tests for MOCK_METHOD.""" 22 23 # The class body is intentionally empty. The actual test*() methods 24 # will be defined at run time by a call to 25 # DefineNegativeCompilationTests() later. 26 pass 27 28 29 # Defines a list of test specs, where each element is a tuple 30 # (test name, list of regexes for matching the compiler errors). 31 TEST_SPECS = [ 32 ("MOCK_METHOD_INVALID_CONST_SPEC", 33 [r"onst cannot be recognized as a valid specification modifier"]), 34 ] 35 36 # Define a test method in GMockNCTest for each element in TEST_SPECS. 37 fake_target_util.DefineNegativeCompilationTests( 38 GMockMethodNCTest, 39 "google3/third_party/googletest/googlemock/test/gmock-function-mocker_nc", 40 "gmock-function-mocker_nc.o", TEST_SPECS) 41 42 if __name__ == "__main__": 43 googletest.main() 44