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
ad99ca14
Commit
ad99ca14
authored
Feb 02, 2009
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exposes gtest flags to user code access. By Alexander Demin.
parent
4b83461e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
19 deletions
+64
-19
gtest.h
include/gtest/gtest.h
+42
-5
gtest-internal-inl.h
src/gtest-internal-inl.h
+3
-14
gtest_unittest.cc
test/gtest_unittest.cc
+19
-0
No files found.
include/gtest/gtest.h
View file @
ad99ca14
...
...
@@ -93,17 +93,54 @@
namespace
testing
{
// The upper limit for valid stack trace depths.
const
int
kMaxStackTraceDepth
=
100
;
// Declares the flags.
// This flag specifies the maximum number of stack frames to be
// printed in a failure message.
GTEST_DECLARE_int32_
(
stack_trace_depth
);
// This flag temporary enables the disabled tests.
GTEST_DECLARE_bool_
(
also_run_disabled_tests
);
// This flag brings the debugger on an assertion failure.
GTEST_DECLARE_bool_
(
break_on_failure
);
// This flag controls whether Google Test catches all test-thrown exceptions
// and logs them as failures.
GTEST_DECLARE_bool_
(
catch_exceptions
);
// This flag enables using colors in terminal output. Available values are
// "yes" to enable colors, "no" (disable colors), or "auto" (the default)
// to let Google Test decide.
GTEST_DECLARE_string_
(
color
);
// This flag sets up the filter to select by name using a glob pattern
// the tests to run. If the filter is not given all tests are executed.
GTEST_DECLARE_string_
(
filter
);
// This flag causes the Google Test to list tests. None of the tests listed
// are actually run if the flag is provided.
GTEST_DECLARE_bool_
(
list_tests
);
// This flag controls whether Google Test emits a detailed XML report to a file
// in addition to its normal textual output.
GTEST_DECLARE_string_
(
output
);
// This flags control whether Google Test prints the elapsed time for each
// test.
GTEST_DECLARE_bool_
(
print_time
);
// This flag sets how many times the tests are repeated. The default value
// is 1. If the value is -1 the tests are repeating forever.
GTEST_DECLARE_int32_
(
repeat
);
// This flag controls whether Google Test includes Google Test internal
// stack frames in failure stack traces.
GTEST_DECLARE_bool_
(
show_internal_stack_frames
);
// This flag specifies the maximum number of stack frames to be
// printed in a failure message.
GTEST_DECLARE_int32_
(
stack_trace_depth
);
// The upper limit for valid stack trace depths.
const
int
kMaxStackTraceDepth
=
100
;
namespace
internal
{
class
GTestFlagSaver
;
...
...
src/gtest-internal-inl.h
View file @
ad99ca14
...
...
@@ -60,21 +60,10 @@ namespace testing {
// Declares the flags.
//
// We don't want the users to modify these flags in the code, but want
// Google Test's own unit tests to be able to access them. Therefore we
// declare them here as opposed to in gtest.h.
GTEST_DECLARE_bool_
(
also_run_disabled_tests
);
GTEST_DECLARE_bool_
(
break_on_failure
);
GTEST_DECLARE_bool_
(
catch_exceptions
);
GTEST_DECLARE_string_
(
color
);
// We don't want the users to modify this flag in the code, but want
// Google Test's own unit tests to be able to access it. Therefore we
// declare it here as opposed to in gtest.h.
GTEST_DECLARE_bool_
(
death_test_use_fork
);
GTEST_DECLARE_string_
(
filter
);
GTEST_DECLARE_bool_
(
list_tests
);
GTEST_DECLARE_string_
(
output
);
GTEST_DECLARE_bool_
(
print_time
);
GTEST_DECLARE_int32_
(
repeat
);
GTEST_DECLARE_bool_
(
show_internal_stack_frames
);
GTEST_DECLARE_int32_
(
stack_trace_depth
);
namespace
internal
{
...
...
test/gtest_unittest.cc
View file @
ad99ca14
...
...
@@ -33,6 +33,25 @@
// Google Test work.
#include <gtest/gtest.h>
// Verifies that the command line flag variables can be accessed
// in code once <gtest/gtest.h> has been #included.
// Do not move it after other #includes.
TEST
(
CommandLineFlagsTest
,
CanBeAccessedInCodeOnceGTestHIsIncluded
)
{
bool
dummy
=
testing
::
GTEST_FLAG
(
also_run_disabled_tests
)
||
testing
::
GTEST_FLAG
(
break_on_failure
)
||
testing
::
GTEST_FLAG
(
catch_exceptions
)
||
testing
::
GTEST_FLAG
(
color
)
!=
"unknown"
||
testing
::
GTEST_FLAG
(
filter
)
!=
"unknown"
||
testing
::
GTEST_FLAG
(
list_tests
)
||
testing
::
GTEST_FLAG
(
output
)
!=
"unknown"
||
testing
::
GTEST_FLAG
(
print_time
)
||
testing
::
GTEST_FLAG
(
repeat
)
>
0
||
testing
::
GTEST_FLAG
(
show_internal_stack_frames
)
||
testing
::
GTEST_FLAG
(
stack_trace_depth
)
>
0
;
EXPECT_TRUE
(
dummy
||
!
dummy
);
// Suppresses warning that dummy is unused.
}
#include <gtest/gtest-spi.h>
// Indicates that this translation unit is part of Google Test's
...
...
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