1"""Negative compilation tests for Google Mock macro MOCK_METHOD.""" 2 3import os 4import sys 5 6IS_LINUX = os.name == "posix" and os.uname()[0] == "Linux" 7if 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 14from google3.testing.pybase import fake_target_util 15from google3.testing.pybase import googletest 16 17# pylint: enable-msg=C6204 18 19 20class 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). 31TEST_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. 37fake_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 42if __name__ == "__main__": 43 googletest.main() 44