diff options
author | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-11-24 20:23:18 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-11-24 20:23:18 +0000 |
commit | 19eb9e9e3d4d5a4f0eee786d7664ca0e45137390 (patch) | |
tree | f28c91fcdbbac205124a68b4e5f9641d05288d07 /test/gmock_output_test.py | |
parent | e56daa7de1d85c35d1cdc252b500ab276b5c1c9c (diff) | |
download | googletest-19eb9e9e3d4d5a4f0eee786d7664ca0e45137390.tar.gz googletest-19eb9e9e3d4d5a4f0eee786d7664ca0e45137390.tar.bz2 googletest-19eb9e9e3d4d5a4f0eee786d7664ca0e45137390.zip |
Pulls in gtest r344; improves implicit_cast (by Zhanyong Wan); makes the Python tests work on Windows (by Vlad Losev); adds run_tests.py (by Vlad Losev).
Diffstat (limited to 'test/gmock_output_test.py')
-rwxr-xr-x | test/gmock_output_test.py | 67 |
1 files changed, 9 insertions, 58 deletions
diff --git a/test/gmock_output_test.py b/test/gmock_output_test.py index f43f7074..c5f05b34 100755 --- a/test/gmock_output_test.py +++ b/test/gmock_output_test.py @@ -40,29 +40,21 @@ SYNOPSIS __author__ = 'wan@google.com (Zhanyong Wan)' -import gmock_test_utils import os import re -import string import sys import unittest +import gmock_test_utils + # The flag for generating the golden file GENGOLDEN_FLAG = '--gengolden' -IS_WINDOWS = os.name == 'nt' - -if IS_WINDOWS: - PROGRAM = r'..\build.dbg\gmock_output_test_.exe' -else: - PROGRAM = 'gmock_output_test_' - -PROGRAM_PATH = os.path.join(gmock_test_utils.GetBuildDir(), PROGRAM) -COMMAND = PROGRAM_PATH + ' --gtest_stack_trace_depth=0 --gtest_print_time=0' +PROGRAM_PATH = gmock_test_utils.GetTestExecutablePath('gmock_output_test_') +COMMAND = [PROGRAM_PATH, '--gtest_stack_trace_depth=0', '--gtest_print_time=0'] GOLDEN_NAME = 'gmock_output_test_golden.txt' -GOLDEN_PATH = os.path.join(gmock_test_utils.GetSourceDir(), - GOLDEN_NAME) +GOLDEN_PATH = os.path.join(gmock_test_utils.GetSourceDir(), GOLDEN_NAME) def ToUnixLineEnding(s): @@ -144,51 +136,10 @@ def GetNormalizedOutputAndLeakyTests(output): return (RemoveTestNamesOfLeakedMocks(output), GetLeakyTests(output)) -def IterShellCommandOutput(cmd, stdin_string=None): - """Runs a command in a sub-process, and iterates the lines in its STDOUT. - - Args: - - cmd: The shell command. - stdin_string: The string to be fed to the STDIN of the sub-process; - If None, the sub-process will inherit the STDIN - from the parent process. - """ - - # Spawns cmd in a sub-process, and gets its standard I/O file objects. - stdin_file, stdout_file = os.popen2(cmd, 'b') - - # If the caller didn't specify a string for STDIN, gets it from the - # parent process. - if stdin_string is None: - stdin_string = sys.stdin.read() - - # Feeds the STDIN string to the sub-process. - stdin_file.write(stdin_string) - stdin_file.close() - - while True: - line = stdout_file.readline() - if not line: # EOF - stdout_file.close() - break - - yield line - - -def GetShellCommandOutput(cmd, stdin_string=None): - """Runs a command in a sub-process, and returns its STDOUT in a string. - - Args: - - cmd: The shell command. - stdin_string: The string to be fed to the STDIN of the sub-process; - If None, the sub-process will inherit the STDIN - from the parent process. - """ +def GetShellCommandOutput(cmd): + """Runs a command in a sub-process, and returns its STDOUT in a string.""" - lines = list(IterShellCommandOutput(cmd, stdin_string)) - return string.join(lines, '') + return gmock_test_utils.Subprocess(cmd, capture_stderr=False).output def GetNormalizedCommandOutputAndLeakyTests(cmd): @@ -200,7 +151,7 @@ def GetNormalizedCommandOutputAndLeakyTests(cmd): # Disables exception pop-ups on Windows. os.environ['GTEST_CATCH_EXCEPTIONS'] = '1' - return GetNormalizedOutputAndLeakyTests(GetShellCommandOutput(cmd, '')) + return GetNormalizedOutputAndLeakyTests(GetShellCommandOutput(cmd)) class GMockOutputTest(unittest.TestCase): |