From b2db677c9905a34ca6454aa526f7a0cc5cfaeca1 Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Wed, 1 Jul 2009 04:58:05 +0000 Subject: 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). --- test/gtest_test_utils.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'test/gtest_test_utils.py') diff --git a/test/gtest_test_utils.py b/test/gtest_test_utils.py index 5b28fe49..385662ad 100755 --- a/test/gtest_test_utils.py +++ b/test/gtest_test_utils.py @@ -190,7 +190,7 @@ def GetExitStatus(exit_code): class Subprocess: - def __init__(self, command, working_dir=None): + def __init__(self, command, working_dir=None, capture_stderr=True): """Changes into a specified directory, if provided, and executes a command. Restores the old directory afterwards. Execution results are returned via the following attributes: @@ -203,8 +203,10 @@ class Subprocess: combined in a string. Args: - command: A command to run, in the form of sys.argv. - working_dir: A directory to change into. + command: The command to run, in the form of sys.argv. + working_dir: The directory to change into. + capture_stderr: Determines whether to capture stderr in the output member + or to discard it. """ # The subprocess module is the preferrable way of running programs @@ -215,8 +217,13 @@ class Subprocess: # functionality (Popen4) under Windows. This allows us to support Mac # OS X 10.4 Tiger, which has python 2.3 installed. if _SUBPROCESS_MODULE_AVAILABLE: + if capture_stderr: + stderr = subprocess.STDOUT + else: + stderr = subprocess.PIPE + p = subprocess.Popen(command, - stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + stdout=subprocess.PIPE, stderr=stderr, cwd=working_dir, universal_newlines=True) # communicate returns a tuple with the file obect for the child's # output. @@ -227,7 +234,10 @@ class Subprocess: try: if working_dir is not None: os.chdir(working_dir) - p = popen2.Popen4(command) + if capture_stderr: + p = popen2.Popen4(command) + else: + p = popen2.Popen3(command) p.tochild.close() self.output = p.fromchild.read() ret_code = p.wait() -- cgit v1.2.3