32 """Verifies that Google Test correctly parses environment variables."""
34 __author__ =
'wan@google.com (Zhanyong Wan)'
37 import gtest_test_utils
40 IS_WINDOWS = os.name ==
'nt'
41 IS_LINUX = os.name ==
'posix' and os.uname()[0] ==
'Linux'
45 environ = os.environ.copy()
49 if expected != actual:
50 print(
'Expected: %s' % (expected,))
51 print(
' Actual: %s' % (actual,))
56 """Sets the env variable to 'value'; unsets it when 'value' is None."""
59 environ[env_var] = value
60 elif env_var
in environ:
65 """Runs gtest_env_var_test_ and returns its output."""
74 """Verifies that the given flag is affected by the corresponding env var."""
76 env_var =
'GTEST_' + flag.upper()
85 """Tests that environment variable should affect the corresponding flag."""
87 TestFlag(
'break_on_failure',
'1',
'0')
89 TestFlag(
'filter',
'FooTest.Bar',
'*')
91 TestFlag(
'output',
'xml:tmp/foo.xml',
'')
94 TestFlag(
'throw_on_failure',
'1',
'0')
95 TestFlag(
'death_test_style',
'threadsafe',
'fast')
96 TestFlag(
'catch_exceptions',
'0',
'1')
99 TestFlag(
'death_test_use_fork',
'1',
'0')
100 TestFlag(
'stack_trace_depth',
'0',
'100')
103 """Tests that $XML_OUTPUT_FILE affects the output flag."""
106 SetEnvVar(
'XML_OUTPUT_FILE',
'tmp/bar.xml')
110 """Tests that $XML_OUTPUT_FILE is overridden by $GTEST_OUTPUT"""
112 SetEnvVar(
'GTEST_OUTPUT',
'xml:tmp/foo.xml')
113 SetEnvVar(
'XML_OUTPUT_FILE',
'tmp/bar.xml')
116 if __name__ ==
'__main__':