Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Unified Diff: testing/gmock/test/gmock_test_utils.py

Issue 521012: Update gmock and gtest. (Closed)
Patch Set: update readme Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « testing/gmock/test/gmock_output_test_golden.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/gmock/test/gmock_test_utils.py
diff --git a/testing/gmock/test/gmock_test_utils.py b/testing/gmock/test/gmock_test_utils.py
old mode 100644
new mode 100755
index 2fda138d03c5b86ea7e24514f59edb5f9563a35d..fa896a47a969b1ab3c073d1081f40f52d4343c78
--- a/testing/gmock/test/gmock_test_utils.py
+++ b/testing/gmock/test/gmock_test_utils.py
@@ -35,7 +35,20 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
import os
import sys
-import unittest
+
+
+# Determines path to gtest_test_utils and imports it.
+SCRIPT_DIR = os.path.dirname(__file__) or '.'
+
+# isdir resolves symbolic links.
+gtest_tests_util_dir = os.path.join(SCRIPT_DIR, '../gtest/test')
+if os.path.isdir(gtest_tests_util_dir):
+ GTEST_TESTS_UTIL_DIR = gtest_tests_util_dir
+else:
+ GTEST_TESTS_UTIL_DIR = os.path.join(SCRIPT_DIR, '../../gtest/test')
+
+sys.path.append(GTEST_TESTS_UTIL_DIR)
+import gtest_test_utils # pylint: disable-msg=C6204
# Initially maps a flag to its default value. After
@@ -96,6 +109,22 @@ def GetBuildDir():
return os.path.abspath(GetFlag('gmock_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.
+ """
+
+ return gtest_test_utils.GetTestExecutablePath(executable_name, GetBuildDir())
+
+
def GetExitStatus(exit_code):
"""Returns the argument to exit(), or -1 if exit() wasn't called.
@@ -116,11 +145,23 @@ def GetExitStatus(exit_code):
return -1
+# Suppresses the "Invalid const name" lint complaint
+# pylint: disable-msg=C6409
+
+# Exposes Subprocess from gtest_test_utils.
+Subprocess = gtest_test_utils.Subprocess
+
+# Exposes TestCase from gtest_test_utils.
+TestCase = gtest_test_utils.TestCase
+
+# pylint: enable-msg=C6409
+
+
def Main():
"""Runs the unit test."""
# We must call _ParseAndStripGMockFlags() before calling
- # unittest.main(). Otherwise the latter will be confused by the
- # --gmock_* flags.
+ # gtest_test_utils.Main(). Otherwise unittest.main it calls will be
+ # confused by the --gmock_* flags.
_ParseAndStripGMockFlags(sys.argv)
- unittest.main()
+ gtest_test_utils.Main()
« no previous file with comments | « testing/gmock/test/gmock_output_test_golden.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698