aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2013-09-06 22:52:14 +0000
committerzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2013-09-06 22:52:14 +0000
commit45fef502fac471efa4bf25b3d4104943463912eb (patch)
tree9993cd7a492e5012bb4523db13038bd6dbf29a05 /test
parent778358e3f1815737f9d13eacb1346e1b2fb41cdc (diff)
downloadgoogletest-45fef502fac471efa4bf25b3d4104943463912eb.tar.gz
googletest-45fef502fac471efa4bf25b3d4104943463912eb.tar.bz2
googletest-45fef502fac471efa4bf25b3d4104943463912eb.zip
makes googlemock generator handle some class templates; pulls in gtest r662
Diffstat (limited to 'test')
-rwxr-xr-xtest/gmock_leak_test.py34
-rwxr-xr-xtest/gmock_test_utils.py7
2 files changed, 30 insertions, 11 deletions
diff --git a/test/gmock_leak_test.py b/test/gmock_leak_test.py
index 38ff9d01..997680ce 100755
--- a/test/gmock_leak_test.py
+++ b/test/gmock_leak_test.py
@@ -42,48 +42,66 @@ TEST_WITH_EXPECT_CALL = [PROGRAM_PATH, '--gtest_filter=*ExpectCall*']
TEST_WITH_ON_CALL = [PROGRAM_PATH, '--gtest_filter=*OnCall*']
TEST_MULTIPLE_LEAKS = [PROGRAM_PATH, '--gtest_filter=*MultipleLeaked*']
+environ = gmock_test_utils.environ
+SetEnvVar = gmock_test_utils.SetEnvVar
+
+# Tests in this file run a Google-Test-based test program and expect it
+# to terminate prematurely. Therefore they are incompatible with
+# the premature-exit-file protocol by design. Unset the
+# premature-exit filepath to prevent Google Test from creating
+# the file.
+SetEnvVar(gmock_test_utils.PREMATURE_EXIT_FILE_ENV_VAR, None)
+
class GMockLeakTest(gmock_test_utils.TestCase):
def testCatchesLeakedMockByDefault(self):
self.assertNotEqual(
0,
- gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL).exit_code)
+ gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL,
+ env=environ).exit_code)
self.assertNotEqual(
0,
- gmock_test_utils.Subprocess(TEST_WITH_ON_CALL).exit_code)
+ gmock_test_utils.Subprocess(TEST_WITH_ON_CALL,
+ env=environ).exit_code)
def testDoesNotCatchLeakedMockWhenDisabled(self):
self.assertEquals(
0,
gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL +
- ['--gmock_catch_leaked_mocks=0']).exit_code)
+ ['--gmock_catch_leaked_mocks=0'],
+ env=environ).exit_code)
self.assertEquals(
0,
gmock_test_utils.Subprocess(TEST_WITH_ON_CALL +
- ['--gmock_catch_leaked_mocks=0']).exit_code)
+ ['--gmock_catch_leaked_mocks=0'],
+ env=environ).exit_code)
def testCatchesLeakedMockWhenEnabled(self):
self.assertNotEqual(
0,
gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL +
- ['--gmock_catch_leaked_mocks']).exit_code)
+ ['--gmock_catch_leaked_mocks'],
+ env=environ).exit_code)
self.assertNotEqual(
0,
gmock_test_utils.Subprocess(TEST_WITH_ON_CALL +
- ['--gmock_catch_leaked_mocks']).exit_code)
+ ['--gmock_catch_leaked_mocks'],
+ env=environ).exit_code)
def testCatchesLeakedMockWhenEnabledWithExplictFlagValue(self):
self.assertNotEqual(
0,
gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL +
- ['--gmock_catch_leaked_mocks=1']).exit_code)
+ ['--gmock_catch_leaked_mocks=1'],
+ env=environ).exit_code)
def testCatchesMultipleLeakedMocks(self):
self.assertNotEqual(
0,
gmock_test_utils.Subprocess(TEST_MULTIPLE_LEAKS +
- ['--gmock_catch_leaked_mocks']).exit_code)
+ ['--gmock_catch_leaked_mocks'],
+ env=environ).exit_code)
if __name__ == '__main__':
diff --git a/test/gmock_test_utils.py b/test/gmock_test_utils.py
index ac3d67ae..20e3d3d4 100755
--- a/test/gmock_test_utils.py
+++ b/test/gmock_test_utils.py
@@ -96,11 +96,12 @@ def GetExitStatus(exit_code):
# Suppresses the "Invalid const name" lint complaint
# pylint: disable-msg=C6409
-# Exposes Subprocess from gtest_test_utils.
+# Exposes utilities from gtest_test_utils.
Subprocess = gtest_test_utils.Subprocess
-
-# Exposes TestCase from gtest_test_utils.
TestCase = gtest_test_utils.TestCase
+environ = gtest_test_utils.environ
+SetEnvVar = gtest_test_utils.SetEnvVar
+PREMATURE_EXIT_FILE_ENV_VAR = gtest_test_utils.PREMATURE_EXIT_FILE_ENV_VAR
# pylint: enable-msg=C6409