diff options
author | shiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925> | 2008-09-18 21:18:11 +0000 |
---|---|---|
committer | shiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925> | 2008-09-18 21:18:11 +0000 |
commit | e79c3ccb73d68543e8ad98d69179dee74abff7ab (patch) | |
tree | 3754cd4cd0ddc726c95c456944e7235826a34e3e /test/gtest_test_utils.py | |
parent | f6b0dc0b408f38bb04079b14198d6bdf703e5e56 (diff) | |
download | googletest-e79c3ccb73d68543e8ad98d69179dee74abff7ab.tar.gz googletest-e79c3ccb73d68543e8ad98d69179dee74abff7ab.tar.bz2 googletest-e79c3ccb73d68543e8ad98d69179dee74abff7ab.zip |
Makes the Python tests more portable by calling standard functions to interpret the result of os.system(). This could fix the broken Python tests on some users' machines.
Diffstat (limited to 'test/gtest_test_utils.py')
-rwxr-xr-x | test/gtest_test_utils.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/gtest_test_utils.py b/test/gtest_test_utils.py index 6c158871..f454774d 100755 --- a/test/gtest_test_utils.py +++ b/test/gtest_test_utils.py @@ -96,6 +96,26 @@ def GetBuildDir(): return os.path.abspath(GetFlag('gtest_build_dir')) +def GetExitStatus(exit_code): + """Returns the argument to exit(), or -1 if exit() wasn't called. + + Args: + exit_code: the result value of os.system(command). + """ + + if os.name == 'nt': + # On Windows, os.WEXITSTATUS() doesn't work and os.system() returns + # the argument to exit() directly. + return exit_code + else: + # On Unix, os.WEXITSTATUS() must be used to extract the exit status + # from the result of os.system(). + if os.WIFEXITED(exit_code): + return os.WEXITSTATUS(exit_code) + else: + return -1 + + def Main(): """Runs the unit test.""" |