32"""Verifies that Google Test correctly parses environment variables."""
35import gtest_test_utils
38IS_WINDOWS = os.name ==
'nt'
39IS_LINUX = os.name ==
'posix' and os.uname()[0] ==
'Linux'
43environ = os.environ.copy()
47 if expected != actual:
48 print(
'Expected: %s' % (expected,))
49 print(
' Actual: %s' % (actual,))
54 """Sets the env variable to 'value'; unsets it when 'value' is None."""
57 environ[env_var] = value
58 elif env_var
in environ:
63 """Runs googletest-env-var-test_ and returns its output."""
72 """Verifies that the given flag is affected by the corresponding env var."""
74 env_var =
'GTEST_' + flag.upper()
84 """Tests that environment variable should affect the corresponding flag."""
86 TestFlag(
'break_on_failure',
'1',
'0')
88 SetEnvVar(
'TESTBRIDGE_TEST_RUNNER_FAIL_FAST',
None)
90 TestFlag(
'filter',
'FooTest.Bar',
'*')
92 TestFlag(
'output',
'xml:tmp/foo.xml',
'')
96 TestFlag(
'throw_on_failure',
'1',
'0')
97 TestFlag(
'death_test_style',
'threadsafe',
'fast')
98 TestFlag(
'catch_exceptions',
'0',
'1')
101 TestFlag(
'death_test_use_fork',
'1',
'0')
102 TestFlag(
'stack_trace_depth',
'0',
'100')
106 """Tests that $XML_OUTPUT_FILE affects the output flag."""
109 SetEnvVar(
'XML_OUTPUT_FILE',
'tmp/bar.xml')
113 """Tests that $XML_OUTPUT_FILE is overridden by $GTEST_OUTPUT."""
115 SetEnvVar(
'GTEST_OUTPUT',
'xml:tmp/foo.xml')
116 SetEnvVar(
'XML_OUTPUT_FILE',
'tmp/bar.xml')
119if __name__ ==
'__main__':
def AssertEq(expected, actual)
def SetEnvVar(env_var, value)
def TestFlag(flag, test_val, default_val)
def GetTestExecutablePath(executable_name, build_dir=None)
def testXmlOutputFile(self)
def testXmlOutputFileOverride(self)
def testEnvVarAffectsFlag(self)