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

Side by Side Diff: testing/gmock/test/gmock_test_utils.py

Issue 6241018: Pull in gmock through DEPS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/testing
Patch Set: don't use svn mirror for now Created 9 years, 11 months 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 unified diff | Download patch | Annotate | Revision Log
« DEPS ('K') | « testing/gmock/test/gmock_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2006, Google Inc.
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are
8 # met:
9 #
10 # * Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following disclaimer
14 # in the documentation and/or other materials provided with the
15 # distribution.
16 # * Neither the name of Google Inc. nor the names of its
17 # contributors may be used to endorse or promote products derived from
18 # this software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 """Unit test utilities for Google C++ Mocking Framework."""
33
34 __author__ = 'wan@google.com (Zhanyong Wan)'
35
36 import os
37 import sys
38
39
40 # Determines path to gtest_test_utils and imports it.
41 SCRIPT_DIR = os.path.dirname(__file__) or '.'
42
43 # isdir resolves symbolic links.
44 gtest_tests_util_dir = os.path.join(SCRIPT_DIR, '../gtest/test')
45 if os.path.isdir(gtest_tests_util_dir):
46 GTEST_TESTS_UTIL_DIR = gtest_tests_util_dir
47 else:
48 GTEST_TESTS_UTIL_DIR = os.path.join(SCRIPT_DIR, '../../gtest/test')
49
50 sys.path.append(GTEST_TESTS_UTIL_DIR)
51 import gtest_test_utils # pylint: disable-msg=C6204
52
53
54 def GetSourceDir():
55 """Returns the absolute path of the directory where the .py files are."""
56
57 return gtest_test_utils.GetSourceDir()
58
59
60 def GetTestExecutablePath(executable_name):
61 """Returns the absolute path of the test binary given its name.
62
63 The function will print a message and abort the program if the resulting file
64 doesn't exist.
65
66 Args:
67 executable_name: name of the test binary that the test script runs.
68
69 Returns:
70 The absolute path of the test binary.
71 """
72
73 return gtest_test_utils.GetTestExecutablePath(executable_name)
74
75
76 def GetExitStatus(exit_code):
77 """Returns the argument to exit(), or -1 if exit() wasn't called.
78
79 Args:
80 exit_code: the result value of os.system(command).
81 """
82
83 if os.name == 'nt':
84 # On Windows, os.WEXITSTATUS() doesn't work and os.system() returns
85 # the argument to exit() directly.
86 return exit_code
87 else:
88 # On Unix, os.WEXITSTATUS() must be used to extract the exit status
89 # from the result of os.system().
90 if os.WIFEXITED(exit_code):
91 return os.WEXITSTATUS(exit_code)
92 else:
93 return -1
94
95
96 # Suppresses the "Invalid const name" lint complaint
97 # pylint: disable-msg=C6409
98
99 # Exposes Subprocess from gtest_test_utils.
100 Subprocess = gtest_test_utils.Subprocess
101
102 # Exposes TestCase from gtest_test_utils.
103 TestCase = gtest_test_utils.TestCase
104
105 # pylint: enable-msg=C6409
106
107
108 def Main():
109 """Runs the unit test."""
110
111 gtest_test_utils.Main()
OLDNEW
« DEPS ('K') | « testing/gmock/test/gmock_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698