Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
42abea35
Commit
42abea35
authored
May 05, 2009
by
zhanyong.wan
Browse files
Uses DebugBreak() to properly break on Windows (by Vlad Losev).
parent
9b23e3cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
src/gtest.cc
src/gtest.cc
+7
-0
test/gtest_break_on_failure_unittest.py
test/gtest_break_on_failure_unittest.py
+16
-0
No files found.
src/gtest.cc
View file @
42abea35
...
...
@@ -3312,7 +3312,14 @@ void UnitTest::AddTestPartResult(TestPartResultType result_type,
// with another testing framework) and specify the former on the
// command line for debugging.
if
(
GTEST_FLAG
(
break_on_failure
))
{
#if GTEST_OS_WINDOWS
// Using DebugBreak on Windows allows gtest to still break into a debugger
// when a failure happens and both the --gtest_break_on_failure and
// the --gtest_catch_exceptions flags are specified.
DebugBreak
();
#else
*
static_cast
<
int
*>
(
NULL
)
=
1
;
#endif // GTEST_OS_WINDOWS
}
else
if
(
GTEST_FLAG
(
throw_on_failure
))
{
#if GTEST_HAS_EXCEPTIONS
throw
GoogleTestFailureException
(
result
);
...
...
test/gtest_break_on_failure_unittest.py
View file @
42abea35
...
...
@@ -57,6 +57,9 @@ BREAK_ON_FAILURE_FLAG = 'gtest_break_on_failure'
# The environment variable for enabling/disabling the throw-on-failure mode.
THROW_ON_FAILURE_ENV_VAR
=
'GTEST_THROW_ON_FAILURE'
# The environment variable for enabling/disabling the catch-exceptions mode.
CATCH_EXCEPTIONS_ENV_VAR
=
'GTEST_CATCH_EXCEPTIONS'
# Path to the gtest_break_on_failure_unittest_ program.
EXE_PATH
=
gtest_test_utils
.
GetTestExecutablePath
(
'gtest_break_on_failure_unittest_'
)
...
...
@@ -194,5 +197,18 @@ class GTestBreakOnFailureUnitTest(unittest.TestCase):
finally
:
SetEnvVar
(
THROW_ON_FAILURE_ENV_VAR
,
None
)
if
IS_WINDOWS
:
def
testCatchExceptionsDoesNotInterfere
(
self
):
"""Tests that gtest_catch_exceptions doesn't interfere."""
SetEnvVar
(
CATCH_EXCEPTIONS_ENV_VAR
,
'1'
)
try
:
self
.
RunAndVerify
(
env_var_value
=
'1'
,
flag_value
=
'1'
,
expect_seg_fault
=
1
)
finally
:
SetEnvVar
(
CATCH_EXCEPTIONS_ENV_VAR
,
None
)
if
__name__
==
'__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