diff options
author | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-04-09 02:57:38 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-04-09 02:57:38 +0000 |
commit | 7fa242a44b47ce74d7246440b14571f7a5dd1b17 (patch) | |
tree | 968a9d50b23d7ef33cf37aaed77d23f0407fde7d /test/gtest_test_utils.py | |
parent | c12f63214e9b7761d27e68353e4aaf1761c9cf88 (diff) | |
download | googletest-7fa242a44b47ce74d7246440b14571f7a5dd1b17.tar.gz googletest-7fa242a44b47ce74d7246440b14571f7a5dd1b17.tar.bz2 googletest-7fa242a44b47ce74d7246440b14571f7a5dd1b17.zip |
Makes the Python tests more stable (by Vlad Losev); fixes a memory leak in GetThreadCount() on Mac (by Vlad Losev); improves fuse_gtest_files.py to support fusing Google Mock files (by Zhanyong Wan).
Diffstat (limited to 'test/gtest_test_utils.py')
-rwxr-xr-x | test/gtest_test_utils.py | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/test/gtest_test_utils.py b/test/gtest_test_utils.py index 8f55b075..7dc8c421 100755 --- a/test/gtest_test_utils.py +++ b/test/gtest_test_utils.py @@ -44,10 +44,10 @@ except: import popen2 _SUBPROCESS_MODULE_AVAILABLE = False +IS_WINDOWS = os.name == 'nt' -# Initially maps a flag to its default value. After -# _ParseAndStripGTestFlags() is called, maps a flag to its actual -# value. +# Initially maps a flag to its default value. After +# _ParseAndStripGTestFlags() is called, maps a flag to its actual value. _flag_map = {'gtest_source_dir': os.path.dirname(sys.argv[0]), 'gtest_build_dir': os.path.dirname(sys.argv[0])} _gtest_flags_are_parsed = False @@ -103,6 +103,38 @@ def GetBuildDir(): return os.path.abspath(GetFlag('gtest_build_dir')) +def GetTestExecutablePath(executable_name): + """Returns the absolute path of the test binary given its name. + + The function will print a message and abort the program if the resulting file + doesn't exist. + + Args: + executable_name: name of the test binary that the test script runs. + + Returns: + The absolute path of the test binary. + """ + + path = os.path.abspath(os.path.join(GetBuildDir(), executable_name)) + if IS_WINDOWS and not path.endswith('.exe'): + path += '.exe' + + if not os.path.exists(path): + message = ( + 'Unable to find the test binary. Please make sure to provide path\n' + 'to the binary via the --gtest_build_dir flag or the GTEST_BUILD_DIR\n' + 'environment variable. For convenient use, invoke this script via\n' + 'mk_test.py.\n' + # TODO(vladl@google.com): change mk_test.py to test.py after renaming + # the file. + 'Please run mk_test.py -h for help.') + print >> sys.stderr, message + sys.exit(1) + + return path + + def GetExitStatus(exit_code): """Returns the argument to exit(), or -1 if exit() wasn't called. |