projects
/
platform
/
upstream
/
gtest.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bump to gtest 1.10.0
[platform/upstream/gtest.git]
/
googletest
/
test
/
gtest_test_utils.py
diff --git
a/test/gtest_test_utils.py
b/googletest/test/gtest_test_utils.py
similarity index 92%
rename from
test/gtest_test_utils.py
rename to
googletest/test/gtest_test_utils.py
index
4acd36c
..
ef9363c
100755
(executable)
--- a/
test/gtest_test_utils.py
+++ b/
googletest/test/gtest_test_utils.py
@@
-1,5
+1,3
@@
-#!/usr/bin/env python
-#
# Copyright 2006, Google Inc.
# All rights reserved.
#
# Copyright 2006, Google Inc.
# All rights reserved.
#
@@
-29,20
+27,22
@@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-"""Unit test utilities for Google C++ Testing Framework."""
+"""Unit test utilities for Google C++ Testing and Mocking Framework."""
+# Suppresses the 'Import not at the top of the file' lint complaint.
+# pylint: disable-msg=C6204
+
+import os
+import sys
-__author__ = 'wan@google.com (Zhanyong Wan)'
+IS_WINDOWS = os.name == 'nt'
+IS_CYGWIN = os.name == 'posix' and 'CYGWIN' in os.uname()[0]
+IS_OS2 = os.name == 'os2'
import atexit
import atexit
-import os
import shutil
import shutil
-import sys
import tempfile
import tempfile
-import unittest
-_test_module = unittest
+import unittest as _test_module
-# Suppresses the 'Import not at the top of the file' lint complaint.
-# pylint: disable-msg=C6204
try:
import subprocess
_SUBPROCESS_MODULE_AVAILABLE = True
try:
import subprocess
_SUBPROCESS_MODULE_AVAILABLE = True
@@
-53,9
+53,6
@@
except:
GTEST_OUTPUT_VAR_NAME = 'GTEST_OUTPUT'
GTEST_OUTPUT_VAR_NAME = 'GTEST_OUTPUT'
-IS_WINDOWS = os.name == 'nt'
-IS_CYGWIN = os.name == 'posix' and 'CYGWIN' in os.uname()[0]
-
# The environment variable for specifying the path to the premature-exit file.
PREMATURE_EXIT_FILE_ENV_VAR = 'TEST_PREMATURE_EXIT_FILE'
# The environment variable for specifying the path to the premature-exit file.
PREMATURE_EXIT_FILE_ENV_VAR = 'TEST_PREMATURE_EXIT_FILE'
@@
-74,7
+71,7
@@
def SetEnvVar(env_var, value):
# Here we expose a class from a particular module, depending on the
# environment. The comment suppresses the 'Invalid variable name' lint
# complaint.
# Here we expose a class from a particular module, depending on the
# environment. The comment suppresses the 'Invalid variable name' lint
# complaint.
-TestCase = _test_module.TestCase # pylint: disable
-msg
=C6409
+TestCase = _test_module.TestCase # pylint: disable=C6409
# 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.
@@
-88,7
+85,7
@@
def _ParseAndStripGTestFlags(argv):
# Suppresses the lint complaint about a global variable since we need it
# here to maintain module-wide state.
# Suppresses the lint complaint about a global variable since we need it
# here to maintain module-wide state.
- global _gtest_flags_are_parsed # pylint: disable
-msg
=W0603
+ global _gtest_flags_are_parsed # pylint: disable=W0603
if _gtest_flags_are_parsed:
return
if _gtest_flags_are_parsed:
return
@@
-145,8
+142,6
@@
atexit.register(_RemoveTempDir)
def GetTempDir():
def GetTempDir():
- """Returns a directory for temporary files."""
-
global _temp_dir
if not _temp_dir:
_temp_dir = tempfile.mkdtemp()
global _temp_dir
if not _temp_dir:
_temp_dir = tempfile.mkdtemp()
@@
-170,7
+165,7
@@
def GetTestExecutablePath(executable_name, build_dir=None):
path = os.path.abspath(os.path.join(build_dir or GetBuildDir(),
executable_name))
path = os.path.abspath(os.path.join(build_dir or GetBuildDir(),
executable_name))
- if (IS_WINDOWS or IS_CYGWIN) and not path.endswith('.exe'):
+ if (IS_WINDOWS or IS_CYGWIN
or IS_OS2
) and not path.endswith('.exe'):
path += '.exe'
if not os.path.exists(path):
path += '.exe'
if not os.path.exists(path):
@@
-178,7
+173,7
@@
def GetTestExecutablePath(executable_name, build_dir=None):
'Unable to find the test binary "%s". Please make sure to provide\n'
'a path to the binary via the --build_dir flag or the BUILD_DIR\n'
'environment variable.' % path)
'Unable to find the test binary "%s". Please make sure to provide\n'
'a path to the binary via the --build_dir flag or the BUILD_DIR\n'
'environment variable.' % path)
- sys.stdout.write(message)
+ print >> sys.stderr, message
sys.exit(1)
return path
sys.exit(1)
return path
@@
-220,10
+215,11
@@
class Subprocess:
Returns:
An object that represents outcome of the executed process. It has the
following attributes:
Returns:
An object that represents outcome of the executed process. It has the
following attributes:
- terminated_by_signal True if
f the child process has been terminated
- by a signal.
+ terminated_by_signal True if
and only if the child process has been
+
terminated
by a signal.
signal Sygnal that terminated the child process.
signal Sygnal that terminated the child process.
- exited True iff the child process exited normally.
+ exited True if and only if the child process exited
+ normally.
exit_code The code with which the child process exited.
output Child process's stdout and stderr output
combined in a string.
exit_code The code with which the child process exited.
output Child process's stdout and stderr output
combined in a string.
@@
-245,7
+241,7
@@
class Subprocess:
p = subprocess.Popen(command,
stdout=subprocess.PIPE, stderr=stderr,
cwd=working_dir, universal_newlines=True, env=env)
p = subprocess.Popen(command,
stdout=subprocess.PIPE, stderr=stderr,
cwd=working_dir, universal_newlines=True, env=env)
- # communicate returns a tuple with the file obect for the child's
+ # communicate returns a tuple with the file ob
j
ect for the child's
# output.
self.output = p.communicate()[0]
self._return_code = p.returncode
# output.
self.output = p.communicate()[0]
self._return_code = p.returncode
@@
-312,8
+308,6
@@
def Main():
_ParseAndStripGTestFlags(sys.argv)
# The tested binaries should not be writing XML output files unless the
# script explicitly instructs them to.
_ParseAndStripGTestFlags(sys.argv)
# The tested binaries should not be writing XML output files unless the
# script explicitly instructs them to.
- # TODO(vladl@google.com): Move this into Subprocess when we implement
- # passing environment into it as a parameter.
if GTEST_OUTPUT_VAR_NAME in os.environ:
del os.environ[GTEST_OUTPUT_VAR_NAME]
if GTEST_OUTPUT_VAR_NAME in os.environ:
del os.environ[GTEST_OUTPUT_VAR_NAME]