aboutsummaryrefslogtreecommitdiffstats
path: root/test/gtest_list_tests_unittest.py
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-07-01 04:58:05 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-07-01 04:58:05 +0000
commitb2db677c9905a34ca6454aa526f7a0cc5cfaeca1 (patch)
tree673f967d6404ea730ccb3d93f30cd3bff5fc8a0e /test/gtest_list_tests_unittest.py
parent1b61f16aef4ea5bb2a7b28e759996dab10e0ca72 (diff)
downloadgoogletest-b2db677c9905a34ca6454aa526f7a0cc5cfaeca1.tar.gz
googletest-b2db677c9905a34ca6454aa526f7a0cc5cfaeca1.tar.bz2
googletest-b2db677c9905a34ca6454aa526f7a0cc5cfaeca1.zip
Reduces the flakiness of gtest-port_test on Mac; improves the Python tests; hides methods that we don't want to publish; makes win-dbg8 the default scons configuration (all by Vlad Losev).
Diffstat (limited to 'test/gtest_list_tests_unittest.py')
-rwxr-xr-xtest/gtest_list_tests_unittest.py39
1 files changed, 17 insertions, 22 deletions
diff --git a/test/gtest_list_tests_unittest.py b/test/gtest_list_tests_unittest.py
index 7dca0b87..ce8c3ef0 100755
--- a/test/gtest_list_tests_unittest.py
+++ b/test/gtest_list_tests_unittest.py
@@ -39,7 +39,6 @@ Google Test) the command line flags.
__author__ = 'phanna@google.com (Patrick Hanna)'
-import os
import gtest_test_utils
@@ -89,15 +88,11 @@ FooTest.
# Utilities.
-def Run(command):
- """Runs a command and returns the list of tests printed."""
+def Run(args):
+ """Runs gtest_list_tests_unittest_ and returns the list of tests printed."""
- stdout_file = os.popen(command, 'r')
-
- output = stdout_file.read()
-
- stdout_file.close()
- return output
+ return gtest_test_utils.Subprocess([EXE_PATH] + args,
+ capture_stderr=False).output
# The unit test.
@@ -122,23 +117,23 @@ class GTestListTestsUnitTest(gtest_test_utils.TestCase):
if flag_value is None:
flag = ''
- flag_expression = "not set"
+ flag_expression = 'not set'
elif flag_value == '0':
- flag = ' --%s=0' % LIST_TESTS_FLAG
- flag_expression = "0"
+ flag = '--%s=0' % LIST_TESTS_FLAG
+ flag_expression = '0'
else:
- flag = ' --%s' % LIST_TESTS_FLAG
- flag_expression = "1"
+ flag = '--%s' % LIST_TESTS_FLAG
+ flag_expression = '1'
- command = EXE_PATH + flag
+ args = [flag]
if other_flag is not None:
- command += " " + other_flag
+ args += [other_flag]
- output = Run(command)
+ output = Run(args)
msg = ('when %s is %s, the output of "%s" is "%s".' %
- (LIST_TESTS_FLAG, flag_expression, command, output))
+ (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output))
if expected_output is not None:
self.assert_(output == expected_output, msg)
@@ -165,17 +160,17 @@ class GTestListTestsUnitTest(gtest_test_utils.TestCase):
def testOverrideNonFilterFlags(self):
"""Tests that --gtest_list_tests overrides the non-filter flags."""
- self.RunAndVerify(flag_value="1",
+ self.RunAndVerify(flag_value='1',
expected_output=EXPECTED_OUTPUT_NO_FILTER,
- other_flag="--gtest_break_on_failure")
+ other_flag='--gtest_break_on_failure')
def testWithFilterFlags(self):
"""Tests that --gtest_list_tests takes into account the
--gtest_filter flag."""
- self.RunAndVerify(flag_value="1",
+ self.RunAndVerify(flag_value='1',
expected_output=EXPECTED_OUTPUT_FILTER_FOO,
- other_flag="--gtest_filter=Foo*")
+ other_flag='--gtest_filter=Foo*')
if __name__ == '__main__':