Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
e2e8ba40
Commit
e2e8ba40
authored
May 13, 2010
by
vladlosev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renames test script flags.
parent
02f71065
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
76 deletions
+29
-76
gmock-matchers.h
include/gmock/gmock-matchers.h
+13
-14
gmock-more-actions.h
include/gmock/gmock-more-actions.h
+10
-0
gmock-spec-builders.h
include/gmock/gmock-spec-builders.h
+3
-2
run_tests.py
run_tests.py
+0
-1
gmock_output_test.py
test/gmock_output_test.py
+1
-1
gmock_test_utils.py
test/gmock_test_utils.py
+2
-58
No files found.
include/gmock/gmock-matchers.h
View file @
e2e8ba40
...
@@ -702,11 +702,11 @@ class AnythingMatcher {
...
@@ -702,11 +702,11 @@ class AnythingMatcher {
} \
} \
virtual void DescribeTo(::std::ostream* os) const { \
virtual void DescribeTo(::std::ostream* os) const { \
*os << relation " "; \
*os << relation " "; \
UniversalPrint
er<Rhs>::Print
(rhs_, os); \
UniversalPrint(rhs_, os); \
} \
} \
virtual void DescribeNegationTo(::std::ostream* os) const { \
virtual void DescribeNegationTo(::std::ostream* os) const { \
*os << negated_relation " "; \
*os << negated_relation " "; \
UniversalPrint
er<Rhs>::Print
(rhs_, os); \
UniversalPrint(rhs_, os); \
} \
} \
private: \
private: \
Rhs rhs_; \
Rhs rhs_; \
...
@@ -910,7 +910,7 @@ class StrEqualityMatcher {
...
@@ -910,7 +910,7 @@ class StrEqualityMatcher {
if
(
!
case_sensitive_
)
{
if
(
!
case_sensitive_
)
{
*
os
<<
"(ignoring case) "
;
*
os
<<
"(ignoring case) "
;
}
}
UniversalPrint
er
<
StringType
>::
Print
(
string_
,
os
);
UniversalPrint
(
string_
,
os
);
}
}
const
StringType
string_
;
const
StringType
string_
;
...
@@ -947,12 +947,12 @@ class HasSubstrMatcher {
...
@@ -947,12 +947,12 @@ class HasSubstrMatcher {
// Describes what this matcher matches.
// Describes what this matcher matches.
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"has substring "
;
*
os
<<
"has substring "
;
UniversalPrint
er
<
StringType
>::
Print
(
substring_
,
os
);
UniversalPrint
(
substring_
,
os
);
}
}
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"has no substring "
;
*
os
<<
"has no substring "
;
UniversalPrint
er
<
StringType
>::
Print
(
substring_
,
os
);
UniversalPrint
(
substring_
,
os
);
}
}
private
:
private
:
...
@@ -988,12 +988,12 @@ class StartsWithMatcher {
...
@@ -988,12 +988,12 @@ class StartsWithMatcher {
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"starts with "
;
*
os
<<
"starts with "
;
UniversalPrint
er
<
StringType
>::
Print
(
prefix_
,
os
);
UniversalPrint
(
prefix_
,
os
);
}
}
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"doesn't start with "
;
*
os
<<
"doesn't start with "
;
UniversalPrint
er
<
StringType
>::
Print
(
prefix_
,
os
);
UniversalPrint
(
prefix_
,
os
);
}
}
private
:
private
:
...
@@ -1028,12 +1028,12 @@ class EndsWithMatcher {
...
@@ -1028,12 +1028,12 @@ class EndsWithMatcher {
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"ends with "
;
*
os
<<
"ends with "
;
UniversalPrint
er
<
StringType
>::
Print
(
suffix_
,
os
);
UniversalPrint
(
suffix_
,
os
);
}
}
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"doesn't end with "
;
*
os
<<
"doesn't end with "
;
UniversalPrint
er
<
StringType
>::
Print
(
suffix_
,
os
);
UniversalPrint
(
suffix_
,
os
);
}
}
private
:
private
:
...
@@ -1879,11 +1879,11 @@ class ContainerEqMatcher {
...
@@ -1879,11 +1879,11 @@ class ContainerEqMatcher {
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"equals "
;
*
os
<<
"equals "
;
UniversalPrint
er
<
StlContainer
>::
Print
(
rhs_
,
os
);
UniversalPrint
(
rhs_
,
os
);
}
}
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"does not equal "
;
*
os
<<
"does not equal "
;
UniversalPrint
er
<
StlContainer
>::
Print
(
rhs_
,
os
);
UniversalPrint
(
rhs_
,
os
);
}
}
template
<
typename
LhsContainer
>
template
<
typename
LhsContainer
>
...
@@ -1913,8 +1913,7 @@ class ContainerEqMatcher {
...
@@ -1913,8 +1913,7 @@ class ContainerEqMatcher {
*
os
<<
"which has these unexpected elements: "
;
*
os
<<
"which has these unexpected elements: "
;
printed_header
=
true
;
printed_header
=
true
;
}
}
UniversalPrinter
<
typename
LhsStlContainer
::
value_type
>::
UniversalPrint
(
*
it
,
os
);
Print
(
*
it
,
os
);
}
}
}
}
...
@@ -1932,7 +1931,7 @@ class ContainerEqMatcher {
...
@@ -1932,7 +1931,7 @@ class ContainerEqMatcher {
<<
" doesn't have these expected elements: "
;
<<
" doesn't have these expected elements: "
;
printed_header2
=
true
;
printed_header2
=
true
;
}
}
UniversalPrint
er
<
typename
StlContainer
::
value_type
>::
Print
(
*
it
,
os
);
UniversalPrint
(
*
it
,
os
);
}
}
}
}
}
}
...
...
include/gmock/gmock-more-actions.h
View file @
e2e8ba40
...
@@ -198,7 +198,17 @@ ACTION_TEMPLATE(DeleteArg,
...
@@ -198,7 +198,17 @@ ACTION_TEMPLATE(DeleteArg,
// Action Throw(exception) can be used in a mock function of any type
// Action Throw(exception) can be used in a mock function of any type
// to throw the given exception. Any copyable value can be thrown.
// to throw the given exception. Any copyable value can be thrown.
#if GTEST_HAS_EXCEPTIONS
#if GTEST_HAS_EXCEPTIONS
// Suppresses the 'unreachable code' warning that VC generates in opt modes.
#ifdef _MSC_VER
#pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4702) // Temporarily disables warning 4702.
#endif
ACTION_P
(
Throw
,
exception
)
{
throw
exception
;
}
ACTION_P
(
Throw
,
exception
)
{
throw
exception
;
}
#ifdef _MSC_VER
#pragma warning(pop) // Restores the warning state.
#endif
#endif // GTEST_HAS_EXCEPTIONS
#endif // GTEST_HAS_EXCEPTIONS
#ifdef _MSC_VER
#ifdef _MSC_VER
...
...
include/gmock/gmock-spec-builders.h
View file @
e2e8ba40
...
@@ -1268,6 +1268,7 @@ class ActionResultHolder {
...
@@ -1268,6 +1268,7 @@ class ActionResultHolder {
// Prints the held value as an action's result to os.
// Prints the held value as an action's result to os.
void
PrintAsActionResult
(
::
std
::
ostream
*
os
)
const
{
void
PrintAsActionResult
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"
\n
Returns: "
;
*
os
<<
"
\n
Returns: "
;
// T may be a reference type, so we don't use UniversalPrint().
UniversalPrinter
<
T
>::
Print
(
value_
,
os
);
UniversalPrinter
<
T
>::
Print
(
value_
,
os
);
}
}
...
@@ -1539,7 +1540,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1539,7 +1540,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
*
os
<<
"Uninteresting mock function call - "
;
*
os
<<
"Uninteresting mock function call - "
;
DescribeDefaultActionTo
(
args
,
os
);
DescribeDefaultActionTo
(
args
,
os
);
*
os
<<
" Function call: "
<<
Name
();
*
os
<<
" Function call: "
<<
Name
();
UniversalPrint
er
<
ArgumentTuple
>::
Print
(
args
,
os
);
UniversalPrint
(
args
,
os
);
}
}
// Critical section: We must find the matching expectation and the
// Critical section: We must find the matching expectation and the
...
@@ -1775,7 +1776,7 @@ typename Function<F>::Result FunctionMockerBase<F>::InvokeWith(
...
@@ -1775,7 +1776,7 @@ typename Function<F>::Result FunctionMockerBase<F>::InvokeWith(
}
}
ss
<<
" Function call: "
<<
Name
();
ss
<<
" Function call: "
<<
Name
();
UniversalPrint
er
<
ArgumentTuple
>::
Print
(
args
,
&
ss
);
UniversalPrint
(
args
,
&
ss
);
// In case the action deletes a piece of the expectation, we
// In case the action deletes a piece of the expectation, we
// generate the message beforehand.
// generate the message beforehand.
...
...
run_tests.py
View file @
e2e8ba40
...
@@ -68,7 +68,6 @@ def _Main():
...
@@ -68,7 +68,6 @@ def _Main():
options
,
args
=
run_tests_util
.
ParseArgs
(
'gtest'
)
options
,
args
=
run_tests_util
.
ParseArgs
(
'gtest'
)
test_runner
=
run_tests_util
.
TestRunner
(
test_runner
=
run_tests_util
.
TestRunner
(
script_dir
=
SCRIPT_DIR
,
script_dir
=
SCRIPT_DIR
,
build_dir_var_name
=
'GMOCK_BUILD_DIR'
,
injected_build_dir_finder
=
GetGmockBuildDir
)
injected_build_dir_finder
=
GetGmockBuildDir
)
tests
=
test_runner
.
GetTestsToRun
(
args
,
tests
=
test_runner
.
GetTestsToRun
(
args
,
options
.
configurations
,
options
.
configurations
,
...
...
test/gmock_output_test.py
View file @
e2e8ba40
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
"""Tests the text output of Google C++ Mocking Framework.
"""Tests the text output of Google C++ Mocking Framework.
SYNOPSIS
SYNOPSIS
gmock_output_test.py --
gmock_
build_dir=BUILD/DIR --gengolden
gmock_output_test.py --build_dir=BUILD/DIR --gengolden
# where BUILD/DIR contains the built gmock_output_test_ file.
# where BUILD/DIR contains the built gmock_output_test_ file.
gmock_output_test.py --gengolden
gmock_output_test.py --gengolden
gmock_output_test.py
gmock_output_test.py
...
...
test/gmock_test_utils.py
View file @
e2e8ba40
...
@@ -51,62 +51,10 @@ sys.path.append(GTEST_TESTS_UTIL_DIR)
...
@@ -51,62 +51,10 @@ sys.path.append(GTEST_TESTS_UTIL_DIR)
import
gtest_test_utils
# pylint: disable-msg=C6204
import
gtest_test_utils
# pylint: disable-msg=C6204
# Initially maps a flag to its default value. After
# _ParseAndStripGMockFlags() is called, maps a flag to its actual
# value.
_flag_map
=
{
'gmock_source_dir'
:
os
.
path
.
dirname
(
sys
.
argv
[
0
]),
'gmock_build_dir'
:
os
.
path
.
dirname
(
sys
.
argv
[
0
])}
_gmock_flags_are_parsed
=
False
def
_ParseAndStripGMockFlags
(
argv
):
"""Parses and strips Google Test flags from argv. This is idempotent."""
global
_gmock_flags_are_parsed
if
_gmock_flags_are_parsed
:
return
_gmock_flags_are_parsed
=
True
for
flag
in
_flag_map
:
# The environment variable overrides the default value.
if
flag
.
upper
()
in
os
.
environ
:
_flag_map
[
flag
]
=
os
.
environ
[
flag
.
upper
()]
# The command line flag overrides the environment variable.
i
=
1
# Skips the program name.
while
i
<
len
(
argv
):
prefix
=
'--'
+
flag
+
'='
if
argv
[
i
]
.
startswith
(
prefix
):
_flag_map
[
flag
]
=
argv
[
i
][
len
(
prefix
):]
del
argv
[
i
]
break
else
:
# We don't increment i in case we just found a --gmock_* flag
# and removed it from argv.
i
+=
1
def
GetFlag
(
flag
):
"""Returns the value of the given flag."""
# In case GetFlag() is called before Main(), we always call
# _ParseAndStripGMockFlags() here to make sure the --gmock_* flags
# are parsed.
_ParseAndStripGMockFlags
(
sys
.
argv
)
return
_flag_map
[
flag
]
def
GetSourceDir
():
def
GetSourceDir
():
"""Returns the absolute path of the directory where the .py files are."""
"""Returns the absolute path of the directory where the .py files are."""
return
os
.
path
.
abspath
(
GetFlag
(
'gmock_source_dir'
))
return
gtest_test_utils
.
GetSourceDir
()
def
GetBuildDir
():
"""Returns the absolute path of the directory where the test binaries are."""
return
os
.
path
.
abspath
(
GetFlag
(
'gmock_build_dir'
))
def
GetTestExecutablePath
(
executable_name
):
def
GetTestExecutablePath
(
executable_name
):
...
@@ -122,7 +70,7 @@ def GetTestExecutablePath(executable_name):
...
@@ -122,7 +70,7 @@ def GetTestExecutablePath(executable_name):
The absolute path of the test binary.
The absolute path of the test binary.
"""
"""
return
gtest_test_utils
.
GetTestExecutablePath
(
executable_name
,
GetBuildDir
()
)
return
gtest_test_utils
.
GetTestExecutablePath
(
executable_name
)
def
GetExitStatus
(
exit_code
):
def
GetExitStatus
(
exit_code
):
...
@@ -160,8 +108,4 @@ TestCase = gtest_test_utils.TestCase
...
@@ -160,8 +108,4 @@ TestCase = gtest_test_utils.TestCase
def
Main
():
def
Main
():
"""Runs the unit test."""
"""Runs the unit test."""
# We must call _ParseAndStripGMockFlags() before calling
# gtest_test_utils.Main(). Otherwise unittest.main it calls will be
# confused by the --gmock_* flags.
_ParseAndStripGMockFlags
(
sys
.
argv
)
gtest_test_utils
.
Main
()
gtest_test_utils
.
Main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment