Googletest export
Introduce GTEST_FLAG_GET and GTEST_FLAG_SET macros. PiperOrigin-RevId: 382808313
This commit is contained in:
parent
4cfd14984f
commit
977cffc442
@ -440,7 +440,8 @@ TEST(LogTest, NoSkippingStackFrameInOptMode) {
|
|||||||
const std::string log = GetCapturedStdout();
|
const std::string log = GetCapturedStdout();
|
||||||
|
|
||||||
std::string expected_trace =
|
std::string expected_trace =
|
||||||
(testing::Message() << GTEST_FLAG(stack_trace_depth) << "::").GetString();
|
(testing::Message() << GTEST_FLAG_GET(stack_trace_depth) << "::")
|
||||||
|
.GetString();
|
||||||
std::string expected_message =
|
std::string expected_message =
|
||||||
"\nGMOCK WARNING:\n"
|
"\nGMOCK WARNING:\n"
|
||||||
"Test log.\n"
|
"Test log.\n"
|
||||||
|
@ -6328,7 +6328,7 @@ TEST_P(BipartiteRandomTest, LargerNets) {
|
|||||||
int iters = GetParam().second;
|
int iters = GetParam().second;
|
||||||
MatchMatrix graph(static_cast<size_t>(nodes), static_cast<size_t>(nodes));
|
MatchMatrix graph(static_cast<size_t>(nodes), static_cast<size_t>(nodes));
|
||||||
|
|
||||||
auto seed = static_cast<uint32_t>(GTEST_FLAG(random_seed));
|
auto seed = static_cast<uint32_t>(GTEST_FLAG_GET(random_seed));
|
||||||
if (seed == 0) {
|
if (seed == 0) {
|
||||||
seed = static_cast<uint32_t>(time(nullptr));
|
seed = static_cast<uint32_t>(time(nullptr));
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,6 @@
|
|||||||
|
|
||||||
#include "gtest/internal/gtest-death-test-internal.h"
|
#include "gtest/internal/gtest-death-test-internal.h"
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
// This flag controls the style of death tests. Valid values are "threadsafe",
|
// This flag controls the style of death tests. Valid values are "threadsafe",
|
||||||
// meaning that the death test child process will re-execute the test binary
|
// meaning that the death test child process will re-execute the test binary
|
||||||
// from the start, running only a single death test, or "fast",
|
// from the start, running only a single death test, or "fast",
|
||||||
@ -49,6 +47,8 @@ namespace testing {
|
|||||||
// after forking.
|
// after forking.
|
||||||
GTEST_DECLARE_string_(death_test_style);
|
GTEST_DECLARE_string_(death_test_style);
|
||||||
|
|
||||||
|
namespace testing {
|
||||||
|
|
||||||
#if GTEST_HAS_DEATH_TEST
|
#if GTEST_HAS_DEATH_TEST
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
@ -73,17 +73,6 @@
|
|||||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
||||||
/* class A needs to have dll-interface to be used by clients of class B */)
|
/* class A needs to have dll-interface to be used by clients of class B */)
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
// Silence C4100 (unreferenced formal parameter) and 4805
|
|
||||||
// unsafe mix of type 'const int' and type 'const bool'
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(push)
|
|
||||||
# pragma warning(disable:4805)
|
|
||||||
# pragma warning(disable:4100)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// Declares the flags.
|
// Declares the flags.
|
||||||
|
|
||||||
// This flag temporary enables the disabled tests.
|
// This flag temporary enables the disabled tests.
|
||||||
@ -169,6 +158,16 @@ GTEST_DECLARE_string_(stream_result_to);
|
|||||||
GTEST_DECLARE_string_(flagfile);
|
GTEST_DECLARE_string_(flagfile);
|
||||||
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
|
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
|
||||||
|
|
||||||
|
namespace testing {
|
||||||
|
|
||||||
|
// Silence C4100 (unreferenced formal parameter) and 4805
|
||||||
|
// unsafe mix of type 'const int' and type 'const bool'
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4805)
|
||||||
|
#pragma warning(disable : 4100)
|
||||||
|
#endif
|
||||||
|
|
||||||
// The upper limit for valid stack trace depths.
|
// The upper limit for valid stack trace depths.
|
||||||
const int kMaxStackTraceDepth = 100;
|
const int kMaxStackTraceDepth = 100;
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ The following macros can be defined:
|
|||||||
* `GTEST_DEFINE_bool_(name, default_val, doc)`
|
* `GTEST_DEFINE_bool_(name, default_val, doc)`
|
||||||
* `GTEST_DEFINE_int32_(name, default_val, doc)`
|
* `GTEST_DEFINE_int32_(name, default_val, doc)`
|
||||||
* `GTEST_DEFINE_string_(name, default_val, doc)`
|
* `GTEST_DEFINE_string_(name, default_val, doc)`
|
||||||
|
* `GTEST_FLAG_GET(flag_name)`
|
||||||
|
* `GTEST_FLAG_SET(flag_name, value)`
|
||||||
|
|
||||||
### Logging:
|
### Logging:
|
||||||
|
|
||||||
|
@ -42,11 +42,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
GTEST_DECLARE_string_(internal_run_death_test);
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
GTEST_DECLARE_string_(internal_run_death_test);
|
|
||||||
|
|
||||||
// Names of the flags (needed for parsing Google Test flags).
|
// Names of the flags (needed for parsing Google Test flags).
|
||||||
const char kDeathTestStyleFlag[] = "death_test_style";
|
const char kDeathTestStyleFlag[] = "death_test_style";
|
||||||
const char kDeathTestUseFork[] = "death_test_use_fork";
|
const char kDeathTestUseFork[] = "death_test_use_fork";
|
||||||
|
@ -2216,22 +2216,40 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
|
|||||||
# define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver
|
# define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver
|
||||||
|
|
||||||
// Macros for declaring flags.
|
// Macros for declaring flags.
|
||||||
# define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
|
#define GTEST_DECLARE_bool_(name) \
|
||||||
# define GTEST_DECLARE_int32_(name) \
|
namespace testing { \
|
||||||
GTEST_API_ extern std::int32_t GTEST_FLAG(name)
|
GTEST_API_ extern bool GTEST_FLAG(name); \
|
||||||
# define GTEST_DECLARE_string_(name) \
|
}
|
||||||
GTEST_API_ extern ::std::string GTEST_FLAG(name)
|
#define GTEST_DECLARE_int32_(name) \
|
||||||
|
namespace testing { \
|
||||||
|
GTEST_API_ extern std::int32_t GTEST_FLAG(name); \
|
||||||
|
}
|
||||||
|
#define GTEST_DECLARE_string_(name) \
|
||||||
|
namespace testing { \
|
||||||
|
GTEST_API_ extern ::std::string GTEST_FLAG(name); \
|
||||||
|
}
|
||||||
|
|
||||||
// Macros for defining flags.
|
// Macros for defining flags.
|
||||||
# define GTEST_DEFINE_bool_(name, default_val, doc) \
|
#define GTEST_DEFINE_bool_(name, default_val, doc) \
|
||||||
GTEST_API_ bool GTEST_FLAG(name) = (default_val)
|
namespace testing { \
|
||||||
# define GTEST_DEFINE_int32_(name, default_val, doc) \
|
GTEST_API_ bool GTEST_FLAG(name) = (default_val); \
|
||||||
GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val)
|
}
|
||||||
# define GTEST_DEFINE_string_(name, default_val, doc) \
|
#define GTEST_DEFINE_int32_(name, default_val, doc) \
|
||||||
GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
|
namespace testing { \
|
||||||
|
GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val); \
|
||||||
|
}
|
||||||
|
#define GTEST_DEFINE_string_(name, default_val, doc) \
|
||||||
|
namespace testing { \
|
||||||
|
GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val); \
|
||||||
|
}
|
||||||
|
|
||||||
#endif // !defined(GTEST_DECLARE_bool_)
|
#endif // !defined(GTEST_DECLARE_bool_)
|
||||||
|
|
||||||
|
#if !defined(GTEST_FLAG_GET)
|
||||||
|
#define GTEST_FLAG_GET(name) ::testing::GTEST_FLAG(name)
|
||||||
|
#define GTEST_FLAG_SET(name, value) (void)(::testing::GTEST_FLAG(name) = value)
|
||||||
|
#endif // !defined(GTEST_FLAG_GET)
|
||||||
|
|
||||||
// Thread annotations
|
// Thread annotations
|
||||||
#if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
|
#if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
|
||||||
# define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
|
# define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
|
||||||
|
@ -96,9 +96,12 @@ namespace testing {
|
|||||||
// used internally at Google, is "threadsafe".
|
// used internally at Google, is "threadsafe".
|
||||||
static const char kDefaultDeathTestStyle[] = GTEST_DEFAULT_DEATH_TEST_STYLE;
|
static const char kDefaultDeathTestStyle[] = GTEST_DEFAULT_DEATH_TEST_STYLE;
|
||||||
|
|
||||||
|
} // namespace testing
|
||||||
|
|
||||||
GTEST_DEFINE_string_(
|
GTEST_DEFINE_string_(
|
||||||
death_test_style,
|
death_test_style,
|
||||||
internal::StringFromGTestEnv("death_test_style", kDefaultDeathTestStyle),
|
testing::internal::StringFromGTestEnv("death_test_style",
|
||||||
|
testing::kDefaultDeathTestStyle),
|
||||||
"Indicates how to run a death test in a forked child process: "
|
"Indicates how to run a death test in a forked child process: "
|
||||||
"\"threadsafe\" (child process re-executes the test binary "
|
"\"threadsafe\" (child process re-executes the test binary "
|
||||||
"from the beginning, running only the specific death test) or "
|
"from the beginning, running only the specific death test) or "
|
||||||
@ -107,7 +110,7 @@ GTEST_DEFINE_string_(
|
|||||||
|
|
||||||
GTEST_DEFINE_bool_(
|
GTEST_DEFINE_bool_(
|
||||||
death_test_use_fork,
|
death_test_use_fork,
|
||||||
internal::BoolFromGTestEnv("death_test_use_fork", false),
|
testing::internal::BoolFromGTestEnv("death_test_use_fork", false),
|
||||||
"Instructs to use fork()/_exit() instead of clone() in death tests. "
|
"Instructs to use fork()/_exit() instead of clone() in death tests. "
|
||||||
"Ignored and always uses fork() on POSIX systems where clone() is not "
|
"Ignored and always uses fork() on POSIX systems where clone() is not "
|
||||||
"implemented. Useful when running under valgrind or similar tools if "
|
"implemented. Useful when running under valgrind or similar tools if "
|
||||||
@ -117,7 +120,6 @@ GTEST_DEFINE_bool_(
|
|||||||
"work in 99% of the cases. Once valgrind is fixed, this flag will "
|
"work in 99% of the cases. Once valgrind is fixed, this flag will "
|
||||||
"most likely be removed.");
|
"most likely be removed.");
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
GTEST_DEFINE_string_(
|
GTEST_DEFINE_string_(
|
||||||
internal_run_death_test, "",
|
internal_run_death_test, "",
|
||||||
"Indicates the file, line number, temporal index of "
|
"Indicates the file, line number, temporal index of "
|
||||||
@ -126,7 +128,8 @@ GTEST_DEFINE_string_(
|
|||||||
"the '|' characters. This flag is specified if and only if the "
|
"the '|' characters. This flag is specified if and only if the "
|
||||||
"current process is a sub-process launched for running a thread-safe "
|
"current process is a sub-process launched for running a thread-safe "
|
||||||
"death test. FOR INTERNAL USE ONLY.");
|
"death test. FOR INTERNAL USE ONLY.");
|
||||||
} // namespace internal
|
|
||||||
|
namespace testing {
|
||||||
|
|
||||||
#if GTEST_HAS_DEATH_TEST
|
#if GTEST_HAS_DEATH_TEST
|
||||||
|
|
||||||
@ -148,12 +151,12 @@ bool InDeathTestChild() {
|
|||||||
|
|
||||||
// On Windows and Fuchsia, death tests are thread-safe regardless of the value
|
// On Windows and Fuchsia, death tests are thread-safe regardless of the value
|
||||||
// of the death_test_style flag.
|
// of the death_test_style flag.
|
||||||
return !GTEST_FLAG(internal_run_death_test).empty();
|
return !GTEST_FLAG_GET(internal_run_death_test).empty();
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
if (GTEST_FLAG(death_test_style) == "threadsafe")
|
if (GTEST_FLAG_GET(death_test_style) == "threadsafe")
|
||||||
return !GTEST_FLAG(internal_run_death_test).empty();
|
return !GTEST_FLAG_GET(internal_run_death_test).empty();
|
||||||
else
|
else
|
||||||
return g_in_fast_death_test_child;
|
return g_in_fast_death_test_child;
|
||||||
#endif
|
#endif
|
||||||
@ -756,18 +759,18 @@ DeathTest::TestRole WindowsDeathTest::AssumeRole() {
|
|||||||
nullptr)); // The even is unnamed.
|
nullptr)); // The even is unnamed.
|
||||||
GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != nullptr);
|
GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != nullptr);
|
||||||
const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ +
|
const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ +
|
||||||
kFilterFlag + "=" + info->test_suite_name() +
|
"filter=" + info->test_suite_name() + "." +
|
||||||
"." + info->name();
|
info->name();
|
||||||
const std::string internal_flag =
|
const std::string internal_flag =
|
||||||
std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag +
|
std::string("--") + GTEST_FLAG_PREFIX_ +
|
||||||
"=" + file_ + "|" + StreamableToString(line_) + "|" +
|
"internal_run_death_test=" + file_ + "|" + StreamableToString(line_) +
|
||||||
StreamableToString(death_test_index) + "|" +
|
"|" + StreamableToString(death_test_index) + "|" +
|
||||||
StreamableToString(static_cast<unsigned int>(::GetCurrentProcessId())) +
|
StreamableToString(static_cast<unsigned int>(::GetCurrentProcessId())) +
|
||||||
// size_t has the same width as pointers on both 32-bit and 64-bit
|
// size_t has the same width as pointers on both 32-bit and 64-bit
|
||||||
// Windows platforms.
|
// Windows platforms.
|
||||||
// See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx.
|
// See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx.
|
||||||
"|" + StreamableToString(reinterpret_cast<size_t>(write_handle)) +
|
"|" + StreamableToString(reinterpret_cast<size_t>(write_handle)) + "|" +
|
||||||
"|" + StreamableToString(reinterpret_cast<size_t>(event_handle_.Get()));
|
StreamableToString(reinterpret_cast<size_t>(event_handle_.Get()));
|
||||||
|
|
||||||
char executable_path[_MAX_PATH + 1]; // NOLINT
|
char executable_path[_MAX_PATH + 1]; // NOLINT
|
||||||
GTEST_DEATH_TEST_CHECK_(_MAX_PATH + 1 != ::GetModuleFileNameA(nullptr,
|
GTEST_DEATH_TEST_CHECK_(_MAX_PATH + 1 != ::GetModuleFileNameA(nullptr,
|
||||||
@ -987,8 +990,8 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
|
|||||||
|
|
||||||
// Build the child process command line.
|
// Build the child process command line.
|
||||||
const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ +
|
const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ +
|
||||||
kFilterFlag + "=" + info->test_suite_name() +
|
"filter=" + info->test_suite_name() + "." +
|
||||||
"." + info->name();
|
info->name();
|
||||||
const std::string internal_flag =
|
const std::string internal_flag =
|
||||||
std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "="
|
std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "="
|
||||||
+ file_ + "|"
|
+ file_ + "|"
|
||||||
@ -1351,7 +1354,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
|
|||||||
# endif // GTEST_OS_LINUX
|
# endif // GTEST_OS_LINUX
|
||||||
|
|
||||||
# if GTEST_HAS_CLONE
|
# if GTEST_HAS_CLONE
|
||||||
const bool use_fork = GTEST_FLAG(death_test_use_fork);
|
const bool use_fork = GTEST_FLAG_GET(death_test_use_fork);
|
||||||
|
|
||||||
if (!use_fork) {
|
if (!use_fork) {
|
||||||
static const bool stack_grows_down = StackGrowsDown();
|
static const bool stack_grows_down = StackGrowsDown();
|
||||||
@ -1420,13 +1423,13 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() {
|
|||||||
GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1);
|
GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1);
|
||||||
|
|
||||||
const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ +
|
const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ +
|
||||||
kFilterFlag + "=" + info->test_suite_name() +
|
"filter=" + info->test_suite_name() + "." +
|
||||||
"." + info->name();
|
info->name();
|
||||||
const std::string internal_flag =
|
const std::string internal_flag = std::string("--") + GTEST_FLAG_PREFIX_ +
|
||||||
std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "="
|
"internal_run_death_test=" + file_ + "|" +
|
||||||
+ file_ + "|" + StreamableToString(line_) + "|"
|
StreamableToString(line_) + "|" +
|
||||||
+ StreamableToString(death_test_index) + "|"
|
StreamableToString(death_test_index) + "|" +
|
||||||
+ StreamableToString(pipe_fd[1]);
|
StreamableToString(pipe_fd[1]);
|
||||||
Arguments args;
|
Arguments args;
|
||||||
args.AddArguments(GetArgvsForDeathTestChildProcess());
|
args.AddArguments(GetArgvsForDeathTestChildProcess());
|
||||||
args.AddArgument(filter_flag.c_str());
|
args.AddArgument(filter_flag.c_str());
|
||||||
@ -1482,32 +1485,32 @@ bool DefaultDeathTestFactory::Create(const char* statement,
|
|||||||
|
|
||||||
# if GTEST_OS_WINDOWS
|
# if GTEST_OS_WINDOWS
|
||||||
|
|
||||||
if (GTEST_FLAG(death_test_style) == "threadsafe" ||
|
if (GTEST_FLAG_GET(death_test_style) == "threadsafe" ||
|
||||||
GTEST_FLAG(death_test_style) == "fast") {
|
GTEST_FLAG_GET(death_test_style) == "fast") {
|
||||||
*test = new WindowsDeathTest(statement, std::move(matcher), file, line);
|
*test = new WindowsDeathTest(statement, std::move(matcher), file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
# elif GTEST_OS_FUCHSIA
|
# elif GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
if (GTEST_FLAG(death_test_style) == "threadsafe" ||
|
if (GTEST_FLAG_GET(death_test_style) == "threadsafe" ||
|
||||||
GTEST_FLAG(death_test_style) == "fast") {
|
GTEST_FLAG_GET(death_test_style) == "fast") {
|
||||||
*test = new FuchsiaDeathTest(statement, std::move(matcher), file, line);
|
*test = new FuchsiaDeathTest(statement, std::move(matcher), file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
if (GTEST_FLAG(death_test_style) == "threadsafe") {
|
if (GTEST_FLAG_GET(death_test_style) == "threadsafe") {
|
||||||
*test = new ExecDeathTest(statement, std::move(matcher), file, line);
|
*test = new ExecDeathTest(statement, std::move(matcher), file, line);
|
||||||
} else if (GTEST_FLAG(death_test_style) == "fast") {
|
} else if (GTEST_FLAG_GET(death_test_style) == "fast") {
|
||||||
*test = new NoExecDeathTest(statement, std::move(matcher));
|
*test = new NoExecDeathTest(statement, std::move(matcher));
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // GTEST_OS_WINDOWS
|
# endif // GTEST_OS_WINDOWS
|
||||||
|
|
||||||
else { // NOLINT - this is more readable than unbalanced brackets inside #if.
|
else { // NOLINT - this is more readable than unbalanced brackets inside #if.
|
||||||
DeathTest::set_last_death_test_message(
|
DeathTest::set_last_death_test_message("Unknown death test style \"" +
|
||||||
"Unknown death test style \"" + GTEST_FLAG(death_test_style)
|
GTEST_FLAG_GET(death_test_style) +
|
||||||
+ "\" encountered");
|
"\" encountered");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1584,14 +1587,14 @@ static int GetStatusFileDescriptor(unsigned int parent_process_id,
|
|||||||
// initialized from the GTEST_FLAG(internal_run_death_test) flag if
|
// initialized from the GTEST_FLAG(internal_run_death_test) flag if
|
||||||
// the flag is specified; otherwise returns NULL.
|
// the flag is specified; otherwise returns NULL.
|
||||||
InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
|
InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
|
||||||
if (GTEST_FLAG(internal_run_death_test) == "") return nullptr;
|
if (GTEST_FLAG_GET(internal_run_death_test) == "") return nullptr;
|
||||||
|
|
||||||
// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we
|
// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we
|
||||||
// can use it here.
|
// can use it here.
|
||||||
int line = -1;
|
int line = -1;
|
||||||
int index = -1;
|
int index = -1;
|
||||||
::std::vector< ::std::string> fields;
|
::std::vector< ::std::string> fields;
|
||||||
SplitString(GTEST_FLAG(internal_run_death_test).c_str(), '|', &fields);
|
SplitString(GTEST_FLAG_GET(internal_run_death_test), '|', &fields);
|
||||||
int write_fd = -1;
|
int write_fd = -1;
|
||||||
|
|
||||||
# if GTEST_OS_WINDOWS
|
# if GTEST_OS_WINDOWS
|
||||||
@ -1607,7 +1610,7 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
|
|||||||
|| !ParseNaturalNumber(fields[4], &write_handle_as_size_t)
|
|| !ParseNaturalNumber(fields[4], &write_handle_as_size_t)
|
||||||
|| !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) {
|
|| !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) {
|
||||||
DeathTestAbort("Bad --gtest_internal_run_death_test flag: " +
|
DeathTestAbort("Bad --gtest_internal_run_death_test flag: " +
|
||||||
GTEST_FLAG(internal_run_death_test));
|
GTEST_FLAG_GET(internal_run_death_test));
|
||||||
}
|
}
|
||||||
write_fd = GetStatusFileDescriptor(parent_process_id,
|
write_fd = GetStatusFileDescriptor(parent_process_id,
|
||||||
write_handle_as_size_t,
|
write_handle_as_size_t,
|
||||||
@ -1618,8 +1621,8 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
|
|||||||
if (fields.size() != 3
|
if (fields.size() != 3
|
||||||
|| !ParseNaturalNumber(fields[1], &line)
|
|| !ParseNaturalNumber(fields[1], &line)
|
||||||
|| !ParseNaturalNumber(fields[2], &index)) {
|
|| !ParseNaturalNumber(fields[2], &index)) {
|
||||||
DeathTestAbort("Bad --gtest_internal_run_death_test flag: "
|
DeathTestAbort("Bad --gtest_internal_run_death_test flag: " +
|
||||||
+ GTEST_FLAG(internal_run_death_test));
|
GTEST_FLAG_GET(internal_run_death_test));
|
||||||
}
|
}
|
||||||
|
|
||||||
# else
|
# else
|
||||||
@ -1628,8 +1631,8 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
|
|||||||
|| !ParseNaturalNumber(fields[1], &line)
|
|| !ParseNaturalNumber(fields[1], &line)
|
||||||
|| !ParseNaturalNumber(fields[2], &index)
|
|| !ParseNaturalNumber(fields[2], &index)
|
||||||
|| !ParseNaturalNumber(fields[3], &write_fd)) {
|
|| !ParseNaturalNumber(fields[3], &write_fd)) {
|
||||||
DeathTestAbort("Bad --gtest_internal_run_death_test flag: "
|
DeathTestAbort("Bad --gtest_internal_run_death_test flag: " +
|
||||||
+ GTEST_FLAG(internal_run_death_test));
|
GTEST_FLAG_GET(internal_run_death_test));
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // GTEST_OS_WINDOWS
|
# endif // GTEST_OS_WINDOWS
|
||||||
|
@ -64,8 +64,6 @@
|
|||||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
||||||
/* class A needs to have dll-interface to be used by clients of class B */)
|
/* class A needs to have dll-interface to be used by clients of class B */)
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
// Declares the flags.
|
// Declares the flags.
|
||||||
//
|
//
|
||||||
// We don't want the users to modify this flag in the code, but want
|
// We don't want the users to modify this flag in the code, but want
|
||||||
@ -73,34 +71,13 @@ namespace testing {
|
|||||||
// declare it here as opposed to in gtest.h.
|
// declare it here as opposed to in gtest.h.
|
||||||
GTEST_DECLARE_bool_(death_test_use_fork);
|
GTEST_DECLARE_bool_(death_test_use_fork);
|
||||||
|
|
||||||
|
namespace testing {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// The value of GetTestTypeId() as seen from within the Google Test
|
// The value of GetTestTypeId() as seen from within the Google Test
|
||||||
// library. This is solely for testing GetTestTypeId().
|
// library. This is solely for testing GetTestTypeId().
|
||||||
GTEST_API_ extern const TypeId kTestTypeIdInGoogleTest;
|
GTEST_API_ extern const TypeId kTestTypeIdInGoogleTest;
|
||||||
|
|
||||||
// Names of the flags (needed for parsing Google Test flags).
|
|
||||||
const char kAlsoRunDisabledTestsFlag[] = "also_run_disabled_tests";
|
|
||||||
const char kBreakOnFailureFlag[] = "break_on_failure";
|
|
||||||
const char kCatchExceptionsFlag[] = "catch_exceptions";
|
|
||||||
const char kColorFlag[] = "color";
|
|
||||||
const char kFailFast[] = "fail_fast";
|
|
||||||
const char kFilterFlag[] = "filter";
|
|
||||||
const char kListTestsFlag[] = "list_tests";
|
|
||||||
const char kOutputFlag[] = "output";
|
|
||||||
const char kBriefFlag[] = "brief";
|
|
||||||
const char kPrintTimeFlag[] = "print_time";
|
|
||||||
const char kPrintUTF8Flag[] = "print_utf8";
|
|
||||||
const char kRandomSeedFlag[] = "random_seed";
|
|
||||||
const char kRepeatFlag[] = "repeat";
|
|
||||||
const char kRecreateEnvironmentsWhenRepeatingFlag[] =
|
|
||||||
"recreate_environments_when_repeating";
|
|
||||||
const char kShuffleFlag[] = "shuffle";
|
|
||||||
const char kStackTraceDepthFlag[] = "stack_trace_depth";
|
|
||||||
const char kStreamResultToFlag[] = "stream_result_to";
|
|
||||||
const char kThrowOnFailureFlag[] = "throw_on_failure";
|
|
||||||
const char kFlagfileFlag[] = "flagfile";
|
|
||||||
|
|
||||||
// A valid random seed must be in [1, kMaxRandomSeed].
|
// A valid random seed must be in [1, kMaxRandomSeed].
|
||||||
const int kMaxRandomSeed = 99999;
|
const int kMaxRandomSeed = 99999;
|
||||||
|
|
||||||
@ -127,8 +104,7 @@ GTEST_API_ std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms);
|
|||||||
//
|
//
|
||||||
// On success, stores the value of the flag in *value, and returns
|
// On success, stores the value of the flag in *value, and returns
|
||||||
// true. On failure, returns false without changing *value.
|
// true. On failure, returns false without changing *value.
|
||||||
GTEST_API_ bool ParseInt32Flag(
|
GTEST_API_ bool ParseFlag(const char* str, const char* flag, int32_t* value);
|
||||||
const char* str, const char* flag, int32_t* value);
|
|
||||||
|
|
||||||
// Returns a random seed in range [1, kMaxRandomSeed] based on the
|
// Returns a random seed in range [1, kMaxRandomSeed] based on the
|
||||||
// given --gtest_random_seed flag value.
|
// given --gtest_random_seed flag value.
|
||||||
@ -162,54 +138,54 @@ class GTestFlagSaver {
|
|||||||
public:
|
public:
|
||||||
// The c'tor.
|
// The c'tor.
|
||||||
GTestFlagSaver() {
|
GTestFlagSaver() {
|
||||||
also_run_disabled_tests_ = GTEST_FLAG(also_run_disabled_tests);
|
also_run_disabled_tests_ = GTEST_FLAG_GET(also_run_disabled_tests);
|
||||||
break_on_failure_ = GTEST_FLAG(break_on_failure);
|
break_on_failure_ = GTEST_FLAG_GET(break_on_failure);
|
||||||
catch_exceptions_ = GTEST_FLAG(catch_exceptions);
|
catch_exceptions_ = GTEST_FLAG_GET(catch_exceptions);
|
||||||
color_ = GTEST_FLAG(color);
|
color_ = GTEST_FLAG_GET(color);
|
||||||
death_test_style_ = GTEST_FLAG(death_test_style);
|
death_test_style_ = GTEST_FLAG_GET(death_test_style);
|
||||||
death_test_use_fork_ = GTEST_FLAG(death_test_use_fork);
|
death_test_use_fork_ = GTEST_FLAG_GET(death_test_use_fork);
|
||||||
fail_fast_ = GTEST_FLAG(fail_fast);
|
fail_fast_ = GTEST_FLAG_GET(fail_fast);
|
||||||
filter_ = GTEST_FLAG(filter);
|
filter_ = GTEST_FLAG_GET(filter);
|
||||||
internal_run_death_test_ = GTEST_FLAG(internal_run_death_test);
|
internal_run_death_test_ = GTEST_FLAG_GET(internal_run_death_test);
|
||||||
list_tests_ = GTEST_FLAG(list_tests);
|
list_tests_ = GTEST_FLAG_GET(list_tests);
|
||||||
output_ = GTEST_FLAG(output);
|
output_ = GTEST_FLAG_GET(output);
|
||||||
brief_ = GTEST_FLAG(brief);
|
brief_ = GTEST_FLAG_GET(brief);
|
||||||
print_time_ = GTEST_FLAG(print_time);
|
print_time_ = GTEST_FLAG_GET(print_time);
|
||||||
print_utf8_ = GTEST_FLAG(print_utf8);
|
print_utf8_ = GTEST_FLAG_GET(print_utf8);
|
||||||
random_seed_ = GTEST_FLAG(random_seed);
|
random_seed_ = GTEST_FLAG_GET(random_seed);
|
||||||
repeat_ = GTEST_FLAG(repeat);
|
repeat_ = GTEST_FLAG_GET(repeat);
|
||||||
recreate_environments_when_repeating_ =
|
recreate_environments_when_repeating_ =
|
||||||
GTEST_FLAG(recreate_environments_when_repeating);
|
GTEST_FLAG_GET(recreate_environments_when_repeating);
|
||||||
shuffle_ = GTEST_FLAG(shuffle);
|
shuffle_ = GTEST_FLAG_GET(shuffle);
|
||||||
stack_trace_depth_ = GTEST_FLAG(stack_trace_depth);
|
stack_trace_depth_ = GTEST_FLAG_GET(stack_trace_depth);
|
||||||
stream_result_to_ = GTEST_FLAG(stream_result_to);
|
stream_result_to_ = GTEST_FLAG_GET(stream_result_to);
|
||||||
throw_on_failure_ = GTEST_FLAG(throw_on_failure);
|
throw_on_failure_ = GTEST_FLAG_GET(throw_on_failure);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The d'tor is not virtual. DO NOT INHERIT FROM THIS CLASS.
|
// The d'tor is not virtual. DO NOT INHERIT FROM THIS CLASS.
|
||||||
~GTestFlagSaver() {
|
~GTestFlagSaver() {
|
||||||
GTEST_FLAG(also_run_disabled_tests) = also_run_disabled_tests_;
|
GTEST_FLAG_SET(also_run_disabled_tests, also_run_disabled_tests_);
|
||||||
GTEST_FLAG(break_on_failure) = break_on_failure_;
|
GTEST_FLAG_SET(break_on_failure, break_on_failure_);
|
||||||
GTEST_FLAG(catch_exceptions) = catch_exceptions_;
|
GTEST_FLAG_SET(catch_exceptions, catch_exceptions_);
|
||||||
GTEST_FLAG(color) = color_;
|
GTEST_FLAG_SET(color, color_);
|
||||||
GTEST_FLAG(death_test_style) = death_test_style_;
|
GTEST_FLAG_SET(death_test_style, death_test_style_);
|
||||||
GTEST_FLAG(death_test_use_fork) = death_test_use_fork_;
|
GTEST_FLAG_SET(death_test_use_fork, death_test_use_fork_);
|
||||||
GTEST_FLAG(filter) = filter_;
|
GTEST_FLAG_SET(filter, filter_);
|
||||||
GTEST_FLAG(fail_fast) = fail_fast_;
|
GTEST_FLAG_SET(fail_fast, fail_fast_);
|
||||||
GTEST_FLAG(internal_run_death_test) = internal_run_death_test_;
|
GTEST_FLAG_SET(internal_run_death_test, internal_run_death_test_);
|
||||||
GTEST_FLAG(list_tests) = list_tests_;
|
GTEST_FLAG_SET(list_tests, list_tests_);
|
||||||
GTEST_FLAG(output) = output_;
|
GTEST_FLAG_SET(output, output_);
|
||||||
GTEST_FLAG(brief) = brief_;
|
GTEST_FLAG_SET(brief, brief_);
|
||||||
GTEST_FLAG(print_time) = print_time_;
|
GTEST_FLAG_SET(print_time, print_time_);
|
||||||
GTEST_FLAG(print_utf8) = print_utf8_;
|
GTEST_FLAG_SET(print_utf8, print_utf8_);
|
||||||
GTEST_FLAG(random_seed) = random_seed_;
|
GTEST_FLAG_SET(random_seed, random_seed_);
|
||||||
GTEST_FLAG(repeat) = repeat_;
|
GTEST_FLAG_SET(repeat, repeat_);
|
||||||
GTEST_FLAG(recreate_environments_when_repeating) =
|
GTEST_FLAG_SET(recreate_environments_when_repeating,
|
||||||
recreate_environments_when_repeating_;
|
recreate_environments_when_repeating_);
|
||||||
GTEST_FLAG(shuffle) = shuffle_;
|
GTEST_FLAG_SET(shuffle, shuffle_);
|
||||||
GTEST_FLAG(stack_trace_depth) = stack_trace_depth_;
|
GTEST_FLAG_SET(stack_trace_depth, stack_trace_depth_);
|
||||||
GTEST_FLAG(stream_result_to) = stream_result_to_;
|
GTEST_FLAG_SET(stream_result_to, stream_result_to_);
|
||||||
GTEST_FLAG(throw_on_failure) = throw_on_failure_;
|
GTEST_FLAG_SET(throw_on_failure, throw_on_failure_);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -502,7 +502,7 @@ void ConditionalPrintAsText(const char* str, size_t length, ostream* os) {
|
|||||||
|
|
||||||
void PrintStringTo(const ::std::string& s, ostream* os) {
|
void PrintStringTo(const ::std::string& s, ostream* os) {
|
||||||
if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) {
|
if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) {
|
||||||
if (GTEST_FLAG(print_utf8)) {
|
if (GTEST_FLAG_GET(print_utf8)) {
|
||||||
ConditionalPrintAsText(s.data(), s.size(), os);
|
ConditionalPrintAsText(s.data(), s.size(), os);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,28 +216,33 @@ static bool GetDefaultFailFast() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace testing
|
||||||
|
|
||||||
GTEST_DEFINE_bool_(
|
GTEST_DEFINE_bool_(
|
||||||
fail_fast, internal::BoolFromGTestEnv("fail_fast", GetDefaultFailFast()),
|
fail_fast,
|
||||||
|
testing::internal::BoolFromGTestEnv("fail_fast",
|
||||||
|
testing::GetDefaultFailFast()),
|
||||||
"True if and only if a test failure should stop further test execution.");
|
"True if and only if a test failure should stop further test execution.");
|
||||||
|
|
||||||
GTEST_DEFINE_bool_(
|
GTEST_DEFINE_bool_(
|
||||||
also_run_disabled_tests,
|
also_run_disabled_tests,
|
||||||
internal::BoolFromGTestEnv("also_run_disabled_tests", false),
|
testing::internal::BoolFromGTestEnv("also_run_disabled_tests", false),
|
||||||
"Run disabled tests too, in addition to the tests normally being run.");
|
"Run disabled tests too, in addition to the tests normally being run.");
|
||||||
|
|
||||||
GTEST_DEFINE_bool_(
|
GTEST_DEFINE_bool_(
|
||||||
break_on_failure, internal::BoolFromGTestEnv("break_on_failure", false),
|
break_on_failure,
|
||||||
|
testing::internal::BoolFromGTestEnv("break_on_failure", false),
|
||||||
"True if and only if a failed assertion should be a debugger "
|
"True if and only if a failed assertion should be a debugger "
|
||||||
"break-point.");
|
"break-point.");
|
||||||
|
|
||||||
GTEST_DEFINE_bool_(catch_exceptions,
|
GTEST_DEFINE_bool_(catch_exceptions,
|
||||||
internal::BoolFromGTestEnv("catch_exceptions", true),
|
testing::internal::BoolFromGTestEnv("catch_exceptions",
|
||||||
|
true),
|
||||||
"True if and only if " GTEST_NAME_
|
"True if and only if " GTEST_NAME_
|
||||||
" should catch exceptions and treat them as test failures.");
|
" should catch exceptions and treat them as test failures.");
|
||||||
|
|
||||||
GTEST_DEFINE_string_(
|
GTEST_DEFINE_string_(
|
||||||
color,
|
color, testing::internal::StringFromGTestEnv("color", "auto"),
|
||||||
internal::StringFromGTestEnv("color", "auto"),
|
|
||||||
"Whether to use colors in the output. Valid values: yes, no, "
|
"Whether to use colors in the output. Valid values: yes, no, "
|
||||||
"and auto. 'auto' means to use colors if the output is "
|
"and auto. 'auto' means to use colors if the output is "
|
||||||
"being sent to a terminal and the TERM environment variable "
|
"being sent to a terminal and the TERM environment variable "
|
||||||
@ -245,7 +250,8 @@ GTEST_DEFINE_string_(
|
|||||||
|
|
||||||
GTEST_DEFINE_string_(
|
GTEST_DEFINE_string_(
|
||||||
filter,
|
filter,
|
||||||
internal::StringFromGTestEnv("filter", GetDefaultFilter()),
|
testing::internal::StringFromGTestEnv("filter",
|
||||||
|
testing::GetDefaultFilter()),
|
||||||
"A colon-separated list of glob (not regex) patterns "
|
"A colon-separated list of glob (not regex) patterns "
|
||||||
"for filtering the tests to run, optionally followed by a "
|
"for filtering the tests to run, optionally followed by a "
|
||||||
"'-' and a : separated list of negative patterns (tests to "
|
"'-' and a : separated list of negative patterns (tests to "
|
||||||
@ -254,8 +260,10 @@ GTEST_DEFINE_string_(
|
|||||||
|
|
||||||
GTEST_DEFINE_bool_(
|
GTEST_DEFINE_bool_(
|
||||||
install_failure_signal_handler,
|
install_failure_signal_handler,
|
||||||
internal::BoolFromGTestEnv("install_failure_signal_handler", false),
|
testing::internal::BoolFromGTestEnv("install_failure_signal_handler",
|
||||||
"If true and supported on the current platform, " GTEST_NAME_ " should "
|
false),
|
||||||
|
"If true and supported on the current platform, " GTEST_NAME_
|
||||||
|
" should "
|
||||||
"install a signal handler that dumps debugging information when fatal "
|
"install a signal handler that dumps debugging information when fatal "
|
||||||
"signals are raised.");
|
"signals are raised.");
|
||||||
|
|
||||||
@ -269,8 +277,8 @@ GTEST_DEFINE_bool_(list_tests, false,
|
|||||||
// ''
|
// ''
|
||||||
GTEST_DEFINE_string_(
|
GTEST_DEFINE_string_(
|
||||||
output,
|
output,
|
||||||
internal::StringFromGTestEnv("output",
|
testing::internal::StringFromGTestEnv(
|
||||||
internal::OutputFlagAlsoCheckEnvVar().c_str()),
|
"output", testing::internal::OutputFlagAlsoCheckEnvVar().c_str()),
|
||||||
"A format (defaults to \"xml\" but can be specified to be \"json\"), "
|
"A format (defaults to \"xml\" but can be specified to be \"json\"), "
|
||||||
"optionally followed by a colon and an output file name or directory. "
|
"optionally followed by a colon and an output file name or directory. "
|
||||||
"A directory is indicated by a trailing pathname separator. "
|
"A directory is indicated by a trailing pathname separator. "
|
||||||
@ -281,32 +289,33 @@ GTEST_DEFINE_string_(
|
|||||||
"digits.");
|
"digits.");
|
||||||
|
|
||||||
GTEST_DEFINE_bool_(
|
GTEST_DEFINE_bool_(
|
||||||
brief, internal::BoolFromGTestEnv("brief", false),
|
brief, testing::internal::BoolFromGTestEnv("brief", false),
|
||||||
"True if only test failures should be displayed in text output.");
|
"True if only test failures should be displayed in text output.");
|
||||||
|
|
||||||
GTEST_DEFINE_bool_(print_time, internal::BoolFromGTestEnv("print_time", true),
|
GTEST_DEFINE_bool_(print_time,
|
||||||
|
testing::internal::BoolFromGTestEnv("print_time", true),
|
||||||
"True if and only if " GTEST_NAME_
|
"True if and only if " GTEST_NAME_
|
||||||
" should display elapsed time in text output.");
|
" should display elapsed time in text output.");
|
||||||
|
|
||||||
GTEST_DEFINE_bool_(print_utf8, internal::BoolFromGTestEnv("print_utf8", true),
|
GTEST_DEFINE_bool_(print_utf8,
|
||||||
|
testing::internal::BoolFromGTestEnv("print_utf8", true),
|
||||||
"True if and only if " GTEST_NAME_
|
"True if and only if " GTEST_NAME_
|
||||||
" prints UTF8 characters as text.");
|
" prints UTF8 characters as text.");
|
||||||
|
|
||||||
GTEST_DEFINE_int32_(
|
GTEST_DEFINE_int32_(
|
||||||
random_seed,
|
random_seed, testing::internal::Int32FromGTestEnv("random_seed", 0),
|
||||||
internal::Int32FromGTestEnv("random_seed", 0),
|
|
||||||
"Random number seed to use when shuffling test orders. Must be in range "
|
"Random number seed to use when shuffling test orders. Must be in range "
|
||||||
"[1, 99999], or 0 to use a seed based on the current time.");
|
"[1, 99999], or 0 to use a seed based on the current time.");
|
||||||
|
|
||||||
GTEST_DEFINE_int32_(
|
GTEST_DEFINE_int32_(
|
||||||
repeat,
|
repeat, testing::internal::Int32FromGTestEnv("repeat", 1),
|
||||||
internal::Int32FromGTestEnv("repeat", 1),
|
|
||||||
"How many times to repeat each test. Specify a negative number "
|
"How many times to repeat each test. Specify a negative number "
|
||||||
"for repeating forever. Useful for shaking out flaky tests.");
|
"for repeating forever. Useful for shaking out flaky tests.");
|
||||||
|
|
||||||
GTEST_DEFINE_bool_(
|
GTEST_DEFINE_bool_(
|
||||||
recreate_environments_when_repeating,
|
recreate_environments_when_repeating,
|
||||||
internal::BoolFromGTestEnv("recreate_environments_when_repeating", true),
|
testing::internal::BoolFromGTestEnv("recreate_environments_when_repeating",
|
||||||
|
true),
|
||||||
"Controls whether global test environments are recreated for each repeat "
|
"Controls whether global test environments are recreated for each repeat "
|
||||||
"of the tests. If set to false the global test environments are only set "
|
"of the tests. If set to false the global test environments are only set "
|
||||||
"up once, for the first iteration, and only torn down once, for the last. "
|
"up once, for the first iteration, and only torn down once, for the last. "
|
||||||
@ -320,37 +329,39 @@ GTEST_DEFINE_bool_(show_internal_stack_frames, false,
|
|||||||
" should include internal stack frames when "
|
" should include internal stack frames when "
|
||||||
"printing test failure stack traces.");
|
"printing test failure stack traces.");
|
||||||
|
|
||||||
GTEST_DEFINE_bool_(shuffle, internal::BoolFromGTestEnv("shuffle", false),
|
GTEST_DEFINE_bool_(shuffle,
|
||||||
|
testing::internal::BoolFromGTestEnv("shuffle", false),
|
||||||
"True if and only if " GTEST_NAME_
|
"True if and only if " GTEST_NAME_
|
||||||
" should randomize tests' order on every run.");
|
" should randomize tests' order on every run.");
|
||||||
|
|
||||||
GTEST_DEFINE_int32_(
|
GTEST_DEFINE_int32_(
|
||||||
stack_trace_depth,
|
stack_trace_depth,
|
||||||
internal::Int32FromGTestEnv("stack_trace_depth", kMaxStackTraceDepth),
|
testing::internal::Int32FromGTestEnv("stack_trace_depth",
|
||||||
|
testing::kMaxStackTraceDepth),
|
||||||
"The maximum number of stack frames to print when an "
|
"The maximum number of stack frames to print when an "
|
||||||
"assertion fails. The valid range is 0 through 100, inclusive.");
|
"assertion fails. The valid range is 0 through 100, inclusive.");
|
||||||
|
|
||||||
GTEST_DEFINE_string_(
|
GTEST_DEFINE_string_(
|
||||||
stream_result_to,
|
stream_result_to,
|
||||||
internal::StringFromGTestEnv("stream_result_to", ""),
|
testing::internal::StringFromGTestEnv("stream_result_to", ""),
|
||||||
"This flag specifies the host name and the port number on which to stream "
|
"This flag specifies the host name and the port number on which to stream "
|
||||||
"test results. Example: \"localhost:555\". The flag is effective only on "
|
"test results. Example: \"localhost:555\". The flag is effective only on "
|
||||||
"Linux.");
|
"Linux.");
|
||||||
|
|
||||||
GTEST_DEFINE_bool_(
|
GTEST_DEFINE_bool_(
|
||||||
throw_on_failure,
|
throw_on_failure,
|
||||||
internal::BoolFromGTestEnv("throw_on_failure", false),
|
testing::internal::BoolFromGTestEnv("throw_on_failure", false),
|
||||||
"When this flag is specified, a failed assertion will throw an exception "
|
"When this flag is specified, a failed assertion will throw an exception "
|
||||||
"if exceptions are enabled or exit the program with a non-zero code "
|
"if exceptions are enabled or exit the program with a non-zero code "
|
||||||
"otherwise. For use with an external test framework.");
|
"otherwise. For use with an external test framework.");
|
||||||
|
|
||||||
#if GTEST_USE_OWN_FLAGFILE_FLAG_
|
#if GTEST_USE_OWN_FLAGFILE_FLAG_
|
||||||
GTEST_DEFINE_string_(
|
GTEST_DEFINE_string_(
|
||||||
flagfile,
|
flagfile, testing::internal::StringFromGTestEnv("flagfile", ""),
|
||||||
internal::StringFromGTestEnv("flagfile", ""),
|
|
||||||
"This flag specifies the flagfile to read command-line flags from.");
|
"This flag specifies the flagfile to read command-line flags from.");
|
||||||
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
|
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
|
||||||
|
|
||||||
|
namespace testing {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// Generates a random number from [0, range), using a Linear
|
// Generates a random number from [0, range), using a Linear
|
||||||
@ -617,7 +628,8 @@ FilePath GetCurrentExecutableName() {
|
|||||||
|
|
||||||
// Returns the output format, or "" for normal printed output.
|
// Returns the output format, or "" for normal printed output.
|
||||||
std::string UnitTestOptions::GetOutputFormat() {
|
std::string UnitTestOptions::GetOutputFormat() {
|
||||||
const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
|
std::string s = GTEST_FLAG_GET(output);
|
||||||
|
const char* const gtest_output_flag = s.c_str();
|
||||||
const char* const colon = strchr(gtest_output_flag, ':');
|
const char* const colon = strchr(gtest_output_flag, ':');
|
||||||
return (colon == nullptr)
|
return (colon == nullptr)
|
||||||
? std::string(gtest_output_flag)
|
? std::string(gtest_output_flag)
|
||||||
@ -628,7 +640,8 @@ std::string UnitTestOptions::GetOutputFormat() {
|
|||||||
// Returns the name of the requested output file, or the default if none
|
// Returns the name of the requested output file, or the default if none
|
||||||
// was explicitly specified.
|
// was explicitly specified.
|
||||||
std::string UnitTestOptions::GetAbsolutePathToOutputFile() {
|
std::string UnitTestOptions::GetAbsolutePathToOutputFile() {
|
||||||
const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
|
std::string s = GTEST_FLAG_GET(output);
|
||||||
|
const char* const gtest_output_flag = s.c_str();
|
||||||
|
|
||||||
std::string format = GetOutputFormat();
|
std::string format = GetOutputFormat();
|
||||||
if (format.empty())
|
if (format.empty())
|
||||||
@ -743,12 +756,13 @@ bool UnitTestOptions::FilterMatchesTest(const std::string& test_suite_name,
|
|||||||
|
|
||||||
// Split --gtest_filter at '-', if there is one, to separate into
|
// Split --gtest_filter at '-', if there is one, to separate into
|
||||||
// positive filter and negative filter portions
|
// positive filter and negative filter portions
|
||||||
const char* const p = GTEST_FLAG(filter).c_str();
|
std::string str = GTEST_FLAG_GET(filter);
|
||||||
|
const char* const p = str.c_str();
|
||||||
const char* const dash = strchr(p, '-');
|
const char* const dash = strchr(p, '-');
|
||||||
std::string positive;
|
std::string positive;
|
||||||
std::string negative;
|
std::string negative;
|
||||||
if (dash == nullptr) {
|
if (dash == nullptr) {
|
||||||
positive = GTEST_FLAG(filter).c_str(); // Whole string is a positive filter
|
positive = str.c_str(); // Whole string is a positive filter
|
||||||
negative = "";
|
negative = "";
|
||||||
} else {
|
} else {
|
||||||
positive = std::string(p, dash); // Everything up to the dash
|
positive = std::string(p, dash); // Everything up to the dash
|
||||||
@ -782,7 +796,7 @@ int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {
|
|||||||
|
|
||||||
bool should_handle = true;
|
bool should_handle = true;
|
||||||
|
|
||||||
if (!GTEST_FLAG(catch_exceptions))
|
if (!GTEST_FLAG_GET(catch_exceptions))
|
||||||
should_handle = false;
|
should_handle = false;
|
||||||
else if (exception_code == EXCEPTION_BREAKPOINT)
|
else if (exception_code == EXCEPTION_BREAKPOINT)
|
||||||
should_handle = false;
|
should_handle = false;
|
||||||
@ -1035,8 +1049,7 @@ int UnitTestImpl::test_to_run_count() const {
|
|||||||
// trace but Bar() and CurrentOsStackTraceExceptTop() won't.
|
// trace but Bar() and CurrentOsStackTraceExceptTop() won't.
|
||||||
std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {
|
std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {
|
||||||
return os_stack_trace_getter()->CurrentStackTrace(
|
return os_stack_trace_getter()->CurrentStackTrace(
|
||||||
static_cast<int>(GTEST_FLAG(stack_trace_depth)),
|
static_cast<int>(GTEST_FLAG_GET(stack_trace_depth)), skip_count + 1
|
||||||
skip_count + 1
|
|
||||||
// Skips the user-specified number of frames plus this function
|
// Skips the user-specified number of frames plus this function
|
||||||
// itself.
|
// itself.
|
||||||
); // NOLINT
|
); // NOLINT
|
||||||
@ -2634,7 +2647,7 @@ Result HandleExceptionsInMethodIfSupported(
|
|||||||
// try {
|
// try {
|
||||||
// // Perform the test method.
|
// // Perform the test method.
|
||||||
// } catch (...) {
|
// } catch (...) {
|
||||||
// if (GTEST_FLAG(catch_exceptions))
|
// if (GTEST_FLAG_GET(catch_exceptions))
|
||||||
// // Report the exception as failure.
|
// // Report the exception as failure.
|
||||||
// else
|
// else
|
||||||
// throw; // Re-throws the original exception.
|
// throw; // Re-throws the original exception.
|
||||||
@ -3024,7 +3037,8 @@ void TestSuite::Run() {
|
|||||||
internal::Timer timer;
|
internal::Timer timer;
|
||||||
for (int i = 0; i < total_test_count(); i++) {
|
for (int i = 0; i < total_test_count(); i++) {
|
||||||
GetMutableTestInfo(i)->Run();
|
GetMutableTestInfo(i)->Run();
|
||||||
if (GTEST_FLAG(fail_fast) && GetMutableTestInfo(i)->result()->Failed()) {
|
if (GTEST_FLAG_GET(fail_fast) &&
|
||||||
|
GetMutableTestInfo(i)->result()->Failed()) {
|
||||||
for (int j = i + 1; j < total_test_count(); j++) {
|
for (int j = i + 1; j < total_test_count(); j++) {
|
||||||
GetMutableTestInfo(j)->Skip();
|
GetMutableTestInfo(j)->Skip();
|
||||||
}
|
}
|
||||||
@ -3243,7 +3257,8 @@ static const char* GetAnsiColorCode(GTestColor color) {
|
|||||||
|
|
||||||
// Returns true if and only if Google Test should use colors in the output.
|
// Returns true if and only if Google Test should use colors in the output.
|
||||||
bool ShouldUseColor(bool stdout_is_tty) {
|
bool ShouldUseColor(bool stdout_is_tty) {
|
||||||
const char* const gtest_color = GTEST_FLAG(color).c_str();
|
std::string c = GTEST_FLAG_GET(color);
|
||||||
|
const char* const gtest_color = c.c_str();
|
||||||
|
|
||||||
if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) {
|
if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) {
|
||||||
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
|
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
|
||||||
@ -3398,10 +3413,11 @@ class PrettyUnitTestResultPrinter : public TestEventListener {
|
|||||||
// Fired before each iteration of tests starts.
|
// Fired before each iteration of tests starts.
|
||||||
void PrettyUnitTestResultPrinter::OnTestIterationStart(
|
void PrettyUnitTestResultPrinter::OnTestIterationStart(
|
||||||
const UnitTest& unit_test, int iteration) {
|
const UnitTest& unit_test, int iteration) {
|
||||||
if (GTEST_FLAG(repeat) != 1)
|
if (GTEST_FLAG_GET(repeat) != 1)
|
||||||
printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1);
|
printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1);
|
||||||
|
|
||||||
const char* const filter = GTEST_FLAG(filter).c_str();
|
std::string f = GTEST_FLAG_GET(filter);
|
||||||
|
const char* const filter = f.c_str();
|
||||||
|
|
||||||
// Prints the filter if it's not *. This reminds the user that some
|
// Prints the filter if it's not *. This reminds the user that some
|
||||||
// tests may be skipped.
|
// tests may be skipped.
|
||||||
@ -3417,7 +3433,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationStart(
|
|||||||
internal::posix::GetEnv(kTestTotalShards));
|
internal::posix::GetEnv(kTestTotalShards));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GTEST_FLAG(shuffle)) {
|
if (GTEST_FLAG_GET(shuffle)) {
|
||||||
ColoredPrintf(GTestColor::kYellow,
|
ColoredPrintf(GTestColor::kYellow,
|
||||||
"Note: Randomizing tests' orders with a seed of %d .\n",
|
"Note: Randomizing tests' orders with a seed of %d .\n",
|
||||||
unit_test.random_seed());
|
unit_test.random_seed());
|
||||||
@ -3500,7 +3516,7 @@ void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {
|
|||||||
if (test_info.result()->Failed())
|
if (test_info.result()->Failed())
|
||||||
PrintFullTestCommentIfPresent(test_info);
|
PrintFullTestCommentIfPresent(test_info);
|
||||||
|
|
||||||
if (GTEST_FLAG(print_time)) {
|
if (GTEST_FLAG_GET(print_time)) {
|
||||||
printf(" (%s ms)\n", internal::StreamableToString(
|
printf(" (%s ms)\n", internal::StreamableToString(
|
||||||
test_info.result()->elapsed_time()).c_str());
|
test_info.result()->elapsed_time()).c_str());
|
||||||
} else {
|
} else {
|
||||||
@ -3511,7 +3527,7 @@ void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {
|
|||||||
|
|
||||||
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||||
void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) {
|
void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) {
|
||||||
if (!GTEST_FLAG(print_time)) return;
|
if (!GTEST_FLAG_GET(print_time)) return;
|
||||||
|
|
||||||
const std::string counts =
|
const std::string counts =
|
||||||
FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
|
FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
|
||||||
@ -3522,7 +3538,7 @@ void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void PrettyUnitTestResultPrinter::OnTestSuiteEnd(const TestSuite& test_suite) {
|
void PrettyUnitTestResultPrinter::OnTestSuiteEnd(const TestSuite& test_suite) {
|
||||||
if (!GTEST_FLAG(print_time)) return;
|
if (!GTEST_FLAG_GET(print_time)) return;
|
||||||
|
|
||||||
const std::string counts =
|
const std::string counts =
|
||||||
FormatCountableNoun(test_suite.test_to_run_count(), "test", "tests");
|
FormatCountableNoun(test_suite.test_to_run_count(), "test", "tests");
|
||||||
@ -3618,7 +3634,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
|
|||||||
printf("%s from %s ran.",
|
printf("%s from %s ran.",
|
||||||
FormatTestCount(unit_test.test_to_run_count()).c_str(),
|
FormatTestCount(unit_test.test_to_run_count()).c_str(),
|
||||||
FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());
|
FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());
|
||||||
if (GTEST_FLAG(print_time)) {
|
if (GTEST_FLAG_GET(print_time)) {
|
||||||
printf(" (%s ms total)",
|
printf(" (%s ms total)",
|
||||||
internal::StreamableToString(unit_test.elapsed_time()).c_str());
|
internal::StreamableToString(unit_test.elapsed_time()).c_str());
|
||||||
}
|
}
|
||||||
@ -3639,7 +3655,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int num_disabled = unit_test.reportable_disabled_test_count();
|
int num_disabled = unit_test.reportable_disabled_test_count();
|
||||||
if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
|
if (num_disabled && !GTEST_FLAG_GET(also_run_disabled_tests)) {
|
||||||
if (unit_test.Passed()) {
|
if (unit_test.Passed()) {
|
||||||
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
|
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
|
||||||
}
|
}
|
||||||
@ -3711,7 +3727,7 @@ void BriefUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {
|
|||||||
PrintTestName(test_info.test_suite_name(), test_info.name());
|
PrintTestName(test_info.test_suite_name(), test_info.name());
|
||||||
PrintFullTestCommentIfPresent(test_info);
|
PrintFullTestCommentIfPresent(test_info);
|
||||||
|
|
||||||
if (GTEST_FLAG(print_time)) {
|
if (GTEST_FLAG_GET(print_time)) {
|
||||||
printf(" (%s ms)\n",
|
printf(" (%s ms)\n",
|
||||||
internal::StreamableToString(test_info.result()->elapsed_time())
|
internal::StreamableToString(test_info.result()->elapsed_time())
|
||||||
.c_str());
|
.c_str());
|
||||||
@ -3728,7 +3744,7 @@ void BriefUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
|
|||||||
printf("%s from %s ran.",
|
printf("%s from %s ran.",
|
||||||
FormatTestCount(unit_test.test_to_run_count()).c_str(),
|
FormatTestCount(unit_test.test_to_run_count()).c_str(),
|
||||||
FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());
|
FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());
|
||||||
if (GTEST_FLAG(print_time)) {
|
if (GTEST_FLAG_GET(print_time)) {
|
||||||
printf(" (%s ms total)",
|
printf(" (%s ms total)",
|
||||||
internal::StreamableToString(unit_test.elapsed_time()).c_str());
|
internal::StreamableToString(unit_test.elapsed_time()).c_str());
|
||||||
}
|
}
|
||||||
@ -3743,7 +3759,7 @@ void BriefUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int num_disabled = unit_test.reportable_disabled_test_count();
|
int num_disabled = unit_test.reportable_disabled_test_count();
|
||||||
if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
|
if (num_disabled && !GTEST_FLAG_GET(also_run_disabled_tests)) {
|
||||||
if (unit_test.Passed()) {
|
if (unit_test.Passed()) {
|
||||||
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
|
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
|
||||||
}
|
}
|
||||||
@ -4227,7 +4243,7 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
|
|||||||
OutputXmlAttribute(stream, kTestsuite, "type_param",
|
OutputXmlAttribute(stream, kTestsuite, "type_param",
|
||||||
test_info.type_param());
|
test_info.type_param());
|
||||||
}
|
}
|
||||||
if (GTEST_FLAG(list_tests)) {
|
if (GTEST_FLAG_GET(list_tests)) {
|
||||||
OutputXmlAttribute(stream, kTestsuite, "file", test_info.file());
|
OutputXmlAttribute(stream, kTestsuite, "file", test_info.file());
|
||||||
OutputXmlAttribute(stream, kTestsuite, "line",
|
OutputXmlAttribute(stream, kTestsuite, "line",
|
||||||
StreamableToString(test_info.line()));
|
StreamableToString(test_info.line()));
|
||||||
@ -4306,7 +4322,7 @@ void XmlUnitTestResultPrinter::PrintXmlTestSuite(std::ostream* stream,
|
|||||||
OutputXmlAttribute(stream, kTestsuite, "name", test_suite.name());
|
OutputXmlAttribute(stream, kTestsuite, "name", test_suite.name());
|
||||||
OutputXmlAttribute(stream, kTestsuite, "tests",
|
OutputXmlAttribute(stream, kTestsuite, "tests",
|
||||||
StreamableToString(test_suite.reportable_test_count()));
|
StreamableToString(test_suite.reportable_test_count()));
|
||||||
if (!GTEST_FLAG(list_tests)) {
|
if (!GTEST_FLAG_GET(list_tests)) {
|
||||||
OutputXmlAttribute(stream, kTestsuite, "failures",
|
OutputXmlAttribute(stream, kTestsuite, "failures",
|
||||||
StreamableToString(test_suite.failed_test_count()));
|
StreamableToString(test_suite.failed_test_count()));
|
||||||
OutputXmlAttribute(
|
OutputXmlAttribute(
|
||||||
@ -4354,7 +4370,7 @@ void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream,
|
|||||||
stream, kTestsuites, "timestamp",
|
stream, kTestsuites, "timestamp",
|
||||||
FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp()));
|
FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp()));
|
||||||
|
|
||||||
if (GTEST_FLAG(shuffle)) {
|
if (GTEST_FLAG_GET(shuffle)) {
|
||||||
OutputXmlAttribute(stream, kTestsuites, "random_seed",
|
OutputXmlAttribute(stream, kTestsuites, "random_seed",
|
||||||
StreamableToString(unit_test.random_seed()));
|
StreamableToString(unit_test.random_seed()));
|
||||||
}
|
}
|
||||||
@ -4631,7 +4647,7 @@ void JsonUnitTestResultPrinter::OutputJsonTestSuiteForTestResult(
|
|||||||
*stream << Indent(4) << "{\n";
|
*stream << Indent(4) << "{\n";
|
||||||
OutputJsonKey(stream, "testsuite", "name", "NonTestSuiteFailure", Indent(6));
|
OutputJsonKey(stream, "testsuite", "name", "NonTestSuiteFailure", Indent(6));
|
||||||
OutputJsonKey(stream, "testsuite", "tests", 1, Indent(6));
|
OutputJsonKey(stream, "testsuite", "tests", 1, Indent(6));
|
||||||
if (!GTEST_FLAG(list_tests)) {
|
if (!GTEST_FLAG_GET(list_tests)) {
|
||||||
OutputJsonKey(stream, "testsuite", "failures", 1, Indent(6));
|
OutputJsonKey(stream, "testsuite", "failures", 1, Indent(6));
|
||||||
OutputJsonKey(stream, "testsuite", "disabled", 0, Indent(6));
|
OutputJsonKey(stream, "testsuite", "disabled", 0, Indent(6));
|
||||||
OutputJsonKey(stream, "testsuite", "skipped", 0, Indent(6));
|
OutputJsonKey(stream, "testsuite", "skipped", 0, Indent(6));
|
||||||
@ -4685,7 +4701,7 @@ void JsonUnitTestResultPrinter::OutputJsonTestInfo(::std::ostream* stream,
|
|||||||
OutputJsonKey(stream, kTestsuite, "type_param", test_info.type_param(),
|
OutputJsonKey(stream, kTestsuite, "type_param", test_info.type_param(),
|
||||||
kIndent);
|
kIndent);
|
||||||
}
|
}
|
||||||
if (GTEST_FLAG(list_tests)) {
|
if (GTEST_FLAG_GET(list_tests)) {
|
||||||
OutputJsonKey(stream, kTestsuite, "file", test_info.file(), kIndent);
|
OutputJsonKey(stream, kTestsuite, "file", test_info.file(), kIndent);
|
||||||
OutputJsonKey(stream, kTestsuite, "line", test_info.line(), kIndent, false);
|
OutputJsonKey(stream, kTestsuite, "line", test_info.line(), kIndent, false);
|
||||||
*stream << "\n" << Indent(8) << "}";
|
*stream << "\n" << Indent(8) << "}";
|
||||||
@ -4749,7 +4765,7 @@ void JsonUnitTestResultPrinter::PrintJsonTestSuite(
|
|||||||
OutputJsonKey(stream, kTestsuite, "name", test_suite.name(), kIndent);
|
OutputJsonKey(stream, kTestsuite, "name", test_suite.name(), kIndent);
|
||||||
OutputJsonKey(stream, kTestsuite, "tests", test_suite.reportable_test_count(),
|
OutputJsonKey(stream, kTestsuite, "tests", test_suite.reportable_test_count(),
|
||||||
kIndent);
|
kIndent);
|
||||||
if (!GTEST_FLAG(list_tests)) {
|
if (!GTEST_FLAG_GET(list_tests)) {
|
||||||
OutputJsonKey(stream, kTestsuite, "failures",
|
OutputJsonKey(stream, kTestsuite, "failures",
|
||||||
test_suite.failed_test_count(), kIndent);
|
test_suite.failed_test_count(), kIndent);
|
||||||
OutputJsonKey(stream, kTestsuite, "disabled",
|
OutputJsonKey(stream, kTestsuite, "disabled",
|
||||||
@ -4796,7 +4812,7 @@ void JsonUnitTestResultPrinter::PrintJsonUnitTest(std::ostream* stream,
|
|||||||
OutputJsonKey(stream, kTestsuites, "disabled",
|
OutputJsonKey(stream, kTestsuites, "disabled",
|
||||||
unit_test.reportable_disabled_test_count(), kIndent);
|
unit_test.reportable_disabled_test_count(), kIndent);
|
||||||
OutputJsonKey(stream, kTestsuites, "errors", 0, kIndent);
|
OutputJsonKey(stream, kTestsuites, "errors", 0, kIndent);
|
||||||
if (GTEST_FLAG(shuffle)) {
|
if (GTEST_FLAG_GET(shuffle)) {
|
||||||
OutputJsonKey(stream, kTestsuites, "random_seed", unit_test.random_seed(),
|
OutputJsonKey(stream, kTestsuites, "random_seed", unit_test.random_seed(),
|
||||||
kIndent);
|
kIndent);
|
||||||
}
|
}
|
||||||
@ -4973,7 +4989,7 @@ std::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count)
|
|||||||
|
|
||||||
for (int i = 0; i < raw_stack_size; ++i) {
|
for (int i = 0; i < raw_stack_size; ++i) {
|
||||||
if (raw_stack[i] == caller_frame &&
|
if (raw_stack[i] == caller_frame &&
|
||||||
!GTEST_FLAG(show_internal_stack_frames)) {
|
!GTEST_FLAG_GET(show_internal_stack_frames)) {
|
||||||
// Add a marker to the trace and stop adding frames.
|
// Add a marker to the trace and stop adding frames.
|
||||||
absl::StrAppend(&result, kElidedFramesMarker, "\n");
|
absl::StrAppend(&result, kElidedFramesMarker, "\n");
|
||||||
break;
|
break;
|
||||||
@ -5325,7 +5341,7 @@ void UnitTest::AddTestPartResult(
|
|||||||
// in the code (perhaps in order to use Google Test assertions
|
// in the code (perhaps in order to use Google Test assertions
|
||||||
// with another testing framework) and specify the former on the
|
// with another testing framework) and specify the former on the
|
||||||
// command line for debugging.
|
// command line for debugging.
|
||||||
if (GTEST_FLAG(break_on_failure)) {
|
if (GTEST_FLAG_GET(break_on_failure)) {
|
||||||
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
|
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
|
||||||
// Using DebugBreak on Windows allows gtest to still break into a debugger
|
// Using DebugBreak on Windows allows gtest to still break into a debugger
|
||||||
// when a failure happens and both the --gtest_break_on_failure and
|
// when a failure happens and both the --gtest_break_on_failure and
|
||||||
@ -5342,7 +5358,7 @@ void UnitTest::AddTestPartResult(
|
|||||||
// portability: some debuggers don't correctly trap abort().
|
// portability: some debuggers don't correctly trap abort().
|
||||||
*static_cast<volatile int*>(nullptr) = 1;
|
*static_cast<volatile int*>(nullptr) = 1;
|
||||||
#endif // GTEST_OS_WINDOWS
|
#endif // GTEST_OS_WINDOWS
|
||||||
} else if (GTEST_FLAG(throw_on_failure)) {
|
} else if (GTEST_FLAG_GET(throw_on_failure)) {
|
||||||
#if GTEST_HAS_EXCEPTIONS
|
#if GTEST_HAS_EXCEPTIONS
|
||||||
throw internal::GoogleTestFailureException(result);
|
throw internal::GoogleTestFailureException(result);
|
||||||
#else
|
#else
|
||||||
@ -5371,7 +5387,7 @@ void UnitTest::RecordProperty(const std::string& key,
|
|||||||
// from the main thread.
|
// from the main thread.
|
||||||
int UnitTest::Run() {
|
int UnitTest::Run() {
|
||||||
const bool in_death_test_child_process =
|
const bool in_death_test_child_process =
|
||||||
internal::GTEST_FLAG(internal_run_death_test).length() > 0;
|
GTEST_FLAG_GET(internal_run_death_test).length() > 0;
|
||||||
|
|
||||||
// Google Test implements this protocol for catching that a test
|
// Google Test implements this protocol for catching that a test
|
||||||
// program exits before returning control to Google Test:
|
// program exits before returning control to Google Test:
|
||||||
@ -5401,7 +5417,7 @@ int UnitTest::Run() {
|
|||||||
|
|
||||||
// Captures the value of GTEST_FLAG(catch_exceptions). This value will be
|
// Captures the value of GTEST_FLAG(catch_exceptions). This value will be
|
||||||
// used for the duration of the program.
|
// used for the duration of the program.
|
||||||
impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions));
|
impl()->set_catch_exceptions(GTEST_FLAG_GET(catch_exceptions));
|
||||||
|
|
||||||
#if GTEST_OS_WINDOWS
|
#if GTEST_OS_WINDOWS
|
||||||
// Either the user wants Google Test to catch exceptions thrown by the
|
// Either the user wants Google Test to catch exceptions thrown by the
|
||||||
@ -5428,7 +5444,7 @@ int UnitTest::Run() {
|
|||||||
// this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
|
// this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
|
||||||
// executed. Google Test will notify the user of any unexpected
|
// executed. Google Test will notify the user of any unexpected
|
||||||
// failure via stderr.
|
// failure via stderr.
|
||||||
if (!GTEST_FLAG(break_on_failure))
|
if (!GTEST_FLAG_GET(break_on_failure))
|
||||||
_set_abort_behavior(
|
_set_abort_behavior(
|
||||||
0x0, // Clear the following flags:
|
0x0, // Clear the following flags:
|
||||||
_WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump.
|
_WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump.
|
||||||
@ -5610,7 +5626,7 @@ void UnitTestImpl::ConfigureXmlOutput() {
|
|||||||
// Initializes event listeners for streaming test results in string form.
|
// Initializes event listeners for streaming test results in string form.
|
||||||
// Must not be called before InitGoogleTest.
|
// Must not be called before InitGoogleTest.
|
||||||
void UnitTestImpl::ConfigureStreamingOutput() {
|
void UnitTestImpl::ConfigureStreamingOutput() {
|
||||||
const std::string& target = GTEST_FLAG(stream_result_to);
|
const std::string& target = GTEST_FLAG_GET(stream_result_to);
|
||||||
if (!target.empty()) {
|
if (!target.empty()) {
|
||||||
const size_t pos = target.find(':');
|
const size_t pos = target.find(':');
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
@ -5653,7 +5669,7 @@ void UnitTestImpl::PostFlagParsingInit() {
|
|||||||
// to shut down the default XML output before invoking RUN_ALL_TESTS.
|
// to shut down the default XML output before invoking RUN_ALL_TESTS.
|
||||||
ConfigureXmlOutput();
|
ConfigureXmlOutput();
|
||||||
|
|
||||||
if (GTEST_FLAG(brief)) {
|
if (GTEST_FLAG_GET(brief)) {
|
||||||
listeners()->SetDefaultResultPrinter(new BriefUnitTestResultPrinter);
|
listeners()->SetDefaultResultPrinter(new BriefUnitTestResultPrinter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5663,7 +5679,7 @@ void UnitTestImpl::PostFlagParsingInit() {
|
|||||||
#endif // GTEST_CAN_STREAM_RESULTS_
|
#endif // GTEST_CAN_STREAM_RESULTS_
|
||||||
|
|
||||||
#if GTEST_HAS_ABSL
|
#if GTEST_HAS_ABSL
|
||||||
if (GTEST_FLAG(install_failure_signal_handler)) {
|
if (GTEST_FLAG_GET(install_failure_signal_handler)) {
|
||||||
absl::FailureSignalHandlerOptions options;
|
absl::FailureSignalHandlerOptions options;
|
||||||
absl::InstallFailureSignalHandler(options);
|
absl::InstallFailureSignalHandler(options);
|
||||||
}
|
}
|
||||||
@ -5796,14 +5812,15 @@ bool UnitTestImpl::RunAllTests() {
|
|||||||
: IGNORE_SHARDING_PROTOCOL) > 0;
|
: IGNORE_SHARDING_PROTOCOL) > 0;
|
||||||
|
|
||||||
// Lists the tests and exits if the --gtest_list_tests flag was specified.
|
// Lists the tests and exits if the --gtest_list_tests flag was specified.
|
||||||
if (GTEST_FLAG(list_tests)) {
|
if (GTEST_FLAG_GET(list_tests)) {
|
||||||
// This must be called *after* FilterTests() has been called.
|
// This must be called *after* FilterTests() has been called.
|
||||||
ListTestsMatchingFilter();
|
ListTestsMatchingFilter();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
random_seed_ = GTEST_FLAG(shuffle) ?
|
random_seed_ = GTEST_FLAG_GET(shuffle)
|
||||||
GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;
|
? GetRandomSeedFromFlag(GTEST_FLAG_GET(random_seed))
|
||||||
|
: 0;
|
||||||
|
|
||||||
// True if and only if at least one test has failed.
|
// True if and only if at least one test has failed.
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
@ -5815,7 +5832,7 @@ bool UnitTestImpl::RunAllTests() {
|
|||||||
|
|
||||||
// How many times to repeat the tests? We don't want to repeat them
|
// How many times to repeat the tests? We don't want to repeat them
|
||||||
// when we are inside the subprocess of a death test.
|
// when we are inside the subprocess of a death test.
|
||||||
const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat);
|
const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG_GET(repeat);
|
||||||
|
|
||||||
// Repeats forever if the repeat count is negative.
|
// Repeats forever if the repeat count is negative.
|
||||||
const bool gtest_repeat_forever = repeat < 0;
|
const bool gtest_repeat_forever = repeat < 0;
|
||||||
@ -5827,7 +5844,8 @@ bool UnitTestImpl::RunAllTests() {
|
|||||||
// resources that are external to this process. Without this check there would
|
// resources that are external to this process. Without this check there would
|
||||||
// be no way to clean up those external resources automatically.
|
// be no way to clean up those external resources automatically.
|
||||||
const bool recreate_environments_when_repeating =
|
const bool recreate_environments_when_repeating =
|
||||||
GTEST_FLAG(recreate_environments_when_repeating) || gtest_repeat_forever;
|
GTEST_FLAG_GET(recreate_environments_when_repeating) ||
|
||||||
|
gtest_repeat_forever;
|
||||||
|
|
||||||
for (int i = 0; gtest_repeat_forever || i != repeat; i++) {
|
for (int i = 0; gtest_repeat_forever || i != repeat; i++) {
|
||||||
// We want to preserve failures generated by ad-hoc test
|
// We want to preserve failures generated by ad-hoc test
|
||||||
@ -5837,7 +5855,7 @@ bool UnitTestImpl::RunAllTests() {
|
|||||||
Timer timer;
|
Timer timer;
|
||||||
|
|
||||||
// Shuffles test suites and tests if requested.
|
// Shuffles test suites and tests if requested.
|
||||||
if (has_tests_to_run && GTEST_FLAG(shuffle)) {
|
if (has_tests_to_run && GTEST_FLAG_GET(shuffle)) {
|
||||||
random()->Reseed(static_cast<uint32_t>(random_seed_));
|
random()->Reseed(static_cast<uint32_t>(random_seed_));
|
||||||
// This should be done before calling OnTestIterationStart(),
|
// This should be done before calling OnTestIterationStart(),
|
||||||
// such that a test event listener can see the actual test order
|
// such that a test event listener can see the actual test order
|
||||||
@ -5878,7 +5896,7 @@ bool UnitTestImpl::RunAllTests() {
|
|||||||
for (int test_index = 0; test_index < total_test_suite_count();
|
for (int test_index = 0; test_index < total_test_suite_count();
|
||||||
test_index++) {
|
test_index++) {
|
||||||
GetMutableSuiteCase(test_index)->Run();
|
GetMutableSuiteCase(test_index)->Run();
|
||||||
if (GTEST_FLAG(fail_fast) &&
|
if (GTEST_FLAG_GET(fail_fast) &&
|
||||||
GetMutableSuiteCase(test_index)->Failed()) {
|
GetMutableSuiteCase(test_index)->Failed()) {
|
||||||
for (int j = test_index + 1; j < total_test_suite_count(); j++) {
|
for (int j = test_index + 1; j < total_test_suite_count(); j++) {
|
||||||
GetMutableSuiteCase(j)->Skip();
|
GetMutableSuiteCase(j)->Skip();
|
||||||
@ -5925,7 +5943,7 @@ bool UnitTestImpl::RunAllTests() {
|
|||||||
// (it's always safe to unshuffle the tests).
|
// (it's always safe to unshuffle the tests).
|
||||||
UnshuffleTests();
|
UnshuffleTests();
|
||||||
|
|
||||||
if (GTEST_FLAG(shuffle)) {
|
if (GTEST_FLAG_GET(shuffle)) {
|
||||||
// Picks a new random seed for each iteration.
|
// Picks a new random seed for each iteration.
|
||||||
random_seed_ = GetNextRandomSeed(random_seed_);
|
random_seed_ = GetNextRandomSeed(random_seed_);
|
||||||
}
|
}
|
||||||
@ -6082,7 +6100,7 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
|
|||||||
test_info->matches_filter_ = matches_filter;
|
test_info->matches_filter_ = matches_filter;
|
||||||
|
|
||||||
const bool is_runnable =
|
const bool is_runnable =
|
||||||
(GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&
|
(GTEST_FLAG_GET(also_run_disabled_tests) || !is_disabled) &&
|
||||||
matches_filter;
|
matches_filter;
|
||||||
|
|
||||||
const bool is_in_another_shard =
|
const bool is_in_another_shard =
|
||||||
@ -6293,13 +6311,14 @@ bool SkipPrefix(const char* prefix, const char** pstr) {
|
|||||||
// part can be omitted.
|
// part can be omitted.
|
||||||
//
|
//
|
||||||
// Returns the value of the flag, or NULL if the parsing failed.
|
// Returns the value of the flag, or NULL if the parsing failed.
|
||||||
static const char* ParseFlagValue(const char* str, const char* flag,
|
static const char* ParseFlagValue(const char* str, const char* flag_name,
|
||||||
bool def_optional) {
|
bool def_optional) {
|
||||||
// str and flag must not be NULL.
|
// str and flag must not be NULL.
|
||||||
if (str == nullptr || flag == nullptr) return nullptr;
|
if (str == nullptr || flag_name == nullptr) return nullptr;
|
||||||
|
|
||||||
// The flag must start with "--" followed by GTEST_FLAG_PREFIX_.
|
// The flag must start with "--" followed by GTEST_FLAG_PREFIX_.
|
||||||
const std::string flag_str = std::string("--") + GTEST_FLAG_PREFIX_ + flag;
|
const std::string flag_str =
|
||||||
|
std::string("--") + GTEST_FLAG_PREFIX_ + flag_name;
|
||||||
const size_t flag_len = flag_str.length();
|
const size_t flag_len = flag_str.length();
|
||||||
if (strncmp(str, flag_str.c_str(), flag_len) != 0) return nullptr;
|
if (strncmp(str, flag_str.c_str(), flag_len) != 0) return nullptr;
|
||||||
|
|
||||||
@ -6330,9 +6349,9 @@ static const char* ParseFlagValue(const char* str, const char* flag,
|
|||||||
//
|
//
|
||||||
// On success, stores the value of the flag in *value, and returns
|
// On success, stores the value of the flag in *value, and returns
|
||||||
// true. On failure, returns false without changing *value.
|
// true. On failure, returns false without changing *value.
|
||||||
static bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
|
static bool ParseFlag(const char* str, const char* flag_name, bool* value) {
|
||||||
// Gets the value of the flag as a string.
|
// Gets the value of the flag as a string.
|
||||||
const char* const value_str = ParseFlagValue(str, flag, true);
|
const char* const value_str = ParseFlagValue(str, flag_name, true);
|
||||||
|
|
||||||
// Aborts if the parsing failed.
|
// Aborts if the parsing failed.
|
||||||
if (value_str == nullptr) return false;
|
if (value_str == nullptr) return false;
|
||||||
@ -6346,16 +6365,16 @@ static bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
|
|||||||
//
|
//
|
||||||
// On success, stores the value of the flag in *value, and returns
|
// On success, stores the value of the flag in *value, and returns
|
||||||
// true. On failure, returns false without changing *value.
|
// true. On failure, returns false without changing *value.
|
||||||
bool ParseInt32Flag(const char* str, const char* flag, int32_t* value) {
|
bool ParseFlag(const char* str, const char* flag_name, int32_t* value) {
|
||||||
// Gets the value of the flag as a string.
|
// Gets the value of the flag as a string.
|
||||||
const char* const value_str = ParseFlagValue(str, flag, false);
|
const char* const value_str = ParseFlagValue(str, flag_name, false);
|
||||||
|
|
||||||
// Aborts if the parsing failed.
|
// Aborts if the parsing failed.
|
||||||
if (value_str == nullptr) return false;
|
if (value_str == nullptr) return false;
|
||||||
|
|
||||||
// Sets *value to the value of the flag.
|
// Sets *value to the value of the flag.
|
||||||
return ParseInt32(Message() << "The value of flag --" << flag,
|
return ParseInt32(Message() << "The value of flag --" << flag_name, value_str,
|
||||||
value_str, value);
|
value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parses a string for a string flag, in the form of "--flag=value".
|
// Parses a string for a string flag, in the form of "--flag=value".
|
||||||
@ -6363,9 +6382,9 @@ bool ParseInt32Flag(const char* str, const char* flag, int32_t* value) {
|
|||||||
// On success, stores the value of the flag in *value, and returns
|
// On success, stores the value of the flag in *value, and returns
|
||||||
// true. On failure, returns false without changing *value.
|
// true. On failure, returns false without changing *value.
|
||||||
template <typename String>
|
template <typename String>
|
||||||
static bool ParseStringFlag(const char* str, const char* flag, String* value) {
|
static bool ParseFlag(const char* str, const char* flag_name, String* value) {
|
||||||
// Gets the value of the flag as a string.
|
// Gets the value of the flag as a string.
|
||||||
const char* const value_str = ParseFlagValue(str, flag, false);
|
const char* const value_str = ParseFlagValue(str, flag_name, false);
|
||||||
|
|
||||||
// Aborts if the parsing failed.
|
// Aborts if the parsing failed.
|
||||||
if (value_str == nullptr) return false;
|
if (value_str == nullptr) return false;
|
||||||
@ -6530,43 +6549,44 @@ static const char kColorEncodedHelpMessage[] =
|
|||||||
"@G<" GTEST_DEV_EMAIL_ ">@D.\n";
|
"@G<" GTEST_DEV_EMAIL_ ">@D.\n";
|
||||||
|
|
||||||
static bool ParseGoogleTestFlag(const char* const arg) {
|
static bool ParseGoogleTestFlag(const char* const arg) {
|
||||||
return ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag,
|
#define GTEST_INTERNAL_PARSE_FLAG(flag_name) \
|
||||||
>EST_FLAG(also_run_disabled_tests)) ||
|
do { \
|
||||||
ParseBoolFlag(arg, kBreakOnFailureFlag,
|
auto value = GTEST_FLAG_GET(flag_name); \
|
||||||
>EST_FLAG(break_on_failure)) ||
|
if (ParseFlag(arg, #flag_name, &value)) { \
|
||||||
ParseBoolFlag(arg, kCatchExceptionsFlag,
|
GTEST_FLAG_SET(flag_name, value); \
|
||||||
>EST_FLAG(catch_exceptions)) ||
|
return true; \
|
||||||
ParseStringFlag(arg, kColorFlag, >EST_FLAG(color)) ||
|
} \
|
||||||
ParseStringFlag(arg, kDeathTestStyleFlag,
|
} while (false)
|
||||||
>EST_FLAG(death_test_style)) ||
|
|
||||||
ParseBoolFlag(arg, kDeathTestUseFork,
|
GTEST_INTERNAL_PARSE_FLAG(also_run_disabled_tests);
|
||||||
>EST_FLAG(death_test_use_fork)) ||
|
GTEST_INTERNAL_PARSE_FLAG(break_on_failure);
|
||||||
ParseBoolFlag(arg, kFailFast, >EST_FLAG(fail_fast)) ||
|
GTEST_INTERNAL_PARSE_FLAG(catch_exceptions);
|
||||||
ParseStringFlag(arg, kFilterFlag, >EST_FLAG(filter)) ||
|
GTEST_INTERNAL_PARSE_FLAG(color);
|
||||||
ParseStringFlag(arg, kInternalRunDeathTestFlag,
|
GTEST_INTERNAL_PARSE_FLAG(death_test_style);
|
||||||
>EST_FLAG(internal_run_death_test)) ||
|
GTEST_INTERNAL_PARSE_FLAG(death_test_use_fork);
|
||||||
ParseBoolFlag(arg, kListTestsFlag, >EST_FLAG(list_tests)) ||
|
GTEST_INTERNAL_PARSE_FLAG(fail_fast);
|
||||||
ParseStringFlag(arg, kOutputFlag, >EST_FLAG(output)) ||
|
GTEST_INTERNAL_PARSE_FLAG(filter);
|
||||||
ParseBoolFlag(arg, kBriefFlag, >EST_FLAG(brief)) ||
|
GTEST_INTERNAL_PARSE_FLAG(internal_run_death_test);
|
||||||
ParseBoolFlag(arg, kPrintTimeFlag, >EST_FLAG(print_time)) ||
|
GTEST_INTERNAL_PARSE_FLAG(list_tests);
|
||||||
ParseBoolFlag(arg, kPrintUTF8Flag, >EST_FLAG(print_utf8)) ||
|
GTEST_INTERNAL_PARSE_FLAG(output);
|
||||||
ParseInt32Flag(arg, kRandomSeedFlag, >EST_FLAG(random_seed)) ||
|
GTEST_INTERNAL_PARSE_FLAG(brief);
|
||||||
ParseInt32Flag(arg, kRepeatFlag, >EST_FLAG(repeat)) ||
|
GTEST_INTERNAL_PARSE_FLAG(print_time);
|
||||||
ParseBoolFlag(arg, kRecreateEnvironmentsWhenRepeatingFlag,
|
GTEST_INTERNAL_PARSE_FLAG(print_utf8);
|
||||||
>EST_FLAG(recreate_environments_when_repeating)) ||
|
GTEST_INTERNAL_PARSE_FLAG(random_seed);
|
||||||
ParseBoolFlag(arg, kShuffleFlag, >EST_FLAG(shuffle)) ||
|
GTEST_INTERNAL_PARSE_FLAG(repeat);
|
||||||
ParseInt32Flag(arg, kStackTraceDepthFlag,
|
GTEST_INTERNAL_PARSE_FLAG(recreate_environments_when_repeating);
|
||||||
>EST_FLAG(stack_trace_depth)) ||
|
GTEST_INTERNAL_PARSE_FLAG(shuffle);
|
||||||
ParseStringFlag(arg, kStreamResultToFlag,
|
GTEST_INTERNAL_PARSE_FLAG(stack_trace_depth);
|
||||||
>EST_FLAG(stream_result_to)) ||
|
GTEST_INTERNAL_PARSE_FLAG(stream_result_to);
|
||||||
ParseBoolFlag(arg, kThrowOnFailureFlag, >EST_FLAG(throw_on_failure));
|
GTEST_INTERNAL_PARSE_FLAG(throw_on_failure);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GTEST_USE_OWN_FLAGFILE_FLAG_
|
#if GTEST_USE_OWN_FLAGFILE_FLAG_
|
||||||
static void LoadFlagsFromFile(const std::string& path) {
|
static void LoadFlagsFromFile(const std::string& path) {
|
||||||
FILE* flagfile = posix::FOpen(path.c_str(), "r");
|
FILE* flagfile = posix::FOpen(path.c_str(), "r");
|
||||||
if (!flagfile) {
|
if (!flagfile) {
|
||||||
GTEST_LOG_(FATAL) << "Unable to open file \"" << GTEST_FLAG(flagfile)
|
GTEST_LOG_(FATAL) << "Unable to open file \"" << GTEST_FLAG_GET(flagfile)
|
||||||
<< "\"";
|
<< "\"";
|
||||||
}
|
}
|
||||||
std::string contents(ReadEntireFile(flagfile));
|
std::string contents(ReadEntireFile(flagfile));
|
||||||
@ -6587,20 +6607,20 @@ static void LoadFlagsFromFile(const std::string& path) {
|
|||||||
// instantiated to either char or wchar_t.
|
// instantiated to either char or wchar_t.
|
||||||
template <typename CharType>
|
template <typename CharType>
|
||||||
void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
|
void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
|
||||||
|
std::string flagfile_value;
|
||||||
for (int i = 1; i < *argc; i++) {
|
for (int i = 1; i < *argc; i++) {
|
||||||
const std::string arg_string = StreamableToString(argv[i]);
|
const std::string arg_string = StreamableToString(argv[i]);
|
||||||
const char* const arg = arg_string.c_str();
|
const char* const arg = arg_string.c_str();
|
||||||
|
|
||||||
using internal::ParseBoolFlag;
|
using internal::ParseFlag;
|
||||||
using internal::ParseInt32Flag;
|
|
||||||
using internal::ParseStringFlag;
|
|
||||||
|
|
||||||
bool remove_flag = false;
|
bool remove_flag = false;
|
||||||
if (ParseGoogleTestFlag(arg)) {
|
if (ParseGoogleTestFlag(arg)) {
|
||||||
remove_flag = true;
|
remove_flag = true;
|
||||||
#if GTEST_USE_OWN_FLAGFILE_FLAG_
|
#if GTEST_USE_OWN_FLAGFILE_FLAG_
|
||||||
} else if (ParseStringFlag(arg, kFlagfileFlag, >EST_FLAG(flagfile))) {
|
} else if (ParseFlag(arg, "flagfile", &flagfile_value)) {
|
||||||
LoadFlagsFromFile(GTEST_FLAG(flagfile));
|
GTEST_FLAG_SET(flagfile, flagfile_value);
|
||||||
|
LoadFlagsFromFile(flagfile_value);
|
||||||
remove_flag = true;
|
remove_flag = true;
|
||||||
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
|
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
|
||||||
} else if (arg_string == "--help" || arg_string == "-h" ||
|
} else if (arg_string == "--help" || arg_string == "-h" ||
|
||||||
|
@ -370,14 +370,14 @@ TEST_F(TestForDeathTest, SwitchStatement) {
|
|||||||
// Tests that a static member function can be used in a "fast" style
|
// Tests that a static member function can be used in a "fast" style
|
||||||
// death test.
|
// death test.
|
||||||
TEST_F(TestForDeathTest, StaticMemberFunctionFastStyle) {
|
TEST_F(TestForDeathTest, StaticMemberFunctionFastStyle) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "fast";
|
GTEST_FLAG_SET(death_test_style, "fast");
|
||||||
ASSERT_DEATH(StaticMemberFunction(), "death.*StaticMember");
|
ASSERT_DEATH(StaticMemberFunction(), "death.*StaticMember");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that a method of the test fixture can be used in a "fast"
|
// Tests that a method of the test fixture can be used in a "fast"
|
||||||
// style death test.
|
// style death test.
|
||||||
TEST_F(TestForDeathTest, MemberFunctionFastStyle) {
|
TEST_F(TestForDeathTest, MemberFunctionFastStyle) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "fast";
|
GTEST_FLAG_SET(death_test_style, "fast");
|
||||||
should_die_ = true;
|
should_die_ = true;
|
||||||
EXPECT_DEATH(MemberFunction(), "inside.*MemberFunction");
|
EXPECT_DEATH(MemberFunction(), "inside.*MemberFunction");
|
||||||
}
|
}
|
||||||
@ -387,7 +387,7 @@ void ChangeToRootDir() { posix::ChDir(GTEST_PATH_SEP_); }
|
|||||||
// Tests that death tests work even if the current directory has been
|
// Tests that death tests work even if the current directory has been
|
||||||
// changed.
|
// changed.
|
||||||
TEST_F(TestForDeathTest, FastDeathTestInChangedDir) {
|
TEST_F(TestForDeathTest, FastDeathTestInChangedDir) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "fast";
|
GTEST_FLAG_SET(death_test_style, "fast");
|
||||||
|
|
||||||
ChangeToRootDir();
|
ChangeToRootDir();
|
||||||
EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), "");
|
EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), "");
|
||||||
@ -432,7 +432,7 @@ void DisableSigprofActionAndTimer(struct sigaction* old_signal_action) {
|
|||||||
|
|
||||||
// Tests that death tests work when SIGPROF handler and timer are set.
|
// Tests that death tests work when SIGPROF handler and timer are set.
|
||||||
TEST_F(TestForDeathTest, FastSigprofActionSet) {
|
TEST_F(TestForDeathTest, FastSigprofActionSet) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "fast";
|
GTEST_FLAG_SET(death_test_style, "fast");
|
||||||
SetSigprofActionAndTimer();
|
SetSigprofActionAndTimer();
|
||||||
EXPECT_DEATH(_exit(1), "");
|
EXPECT_DEATH(_exit(1), "");
|
||||||
struct sigaction old_signal_action;
|
struct sigaction old_signal_action;
|
||||||
@ -441,7 +441,7 @@ TEST_F(TestForDeathTest, FastSigprofActionSet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, ThreadSafeSigprofActionSet) {
|
TEST_F(TestForDeathTest, ThreadSafeSigprofActionSet) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "threadsafe";
|
GTEST_FLAG_SET(death_test_style, "threadsafe");
|
||||||
SetSigprofActionAndTimer();
|
SetSigprofActionAndTimer();
|
||||||
EXPECT_DEATH(_exit(1), "");
|
EXPECT_DEATH(_exit(1), "");
|
||||||
struct sigaction old_signal_action;
|
struct sigaction old_signal_action;
|
||||||
@ -453,25 +453,25 @@ TEST_F(TestForDeathTest, ThreadSafeSigprofActionSet) {
|
|||||||
// Repeats a representative sample of death tests in the "threadsafe" style:
|
// Repeats a representative sample of death tests in the "threadsafe" style:
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, StaticMemberFunctionThreadsafeStyle) {
|
TEST_F(TestForDeathTest, StaticMemberFunctionThreadsafeStyle) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "threadsafe";
|
GTEST_FLAG_SET(death_test_style, "threadsafe");
|
||||||
ASSERT_DEATH(StaticMemberFunction(), "death.*StaticMember");
|
ASSERT_DEATH(StaticMemberFunction(), "death.*StaticMember");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, MemberFunctionThreadsafeStyle) {
|
TEST_F(TestForDeathTest, MemberFunctionThreadsafeStyle) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "threadsafe";
|
GTEST_FLAG_SET(death_test_style, "threadsafe");
|
||||||
should_die_ = true;
|
should_die_ = true;
|
||||||
EXPECT_DEATH(MemberFunction(), "inside.*MemberFunction");
|
EXPECT_DEATH(MemberFunction(), "inside.*MemberFunction");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, ThreadsafeDeathTestInLoop) {
|
TEST_F(TestForDeathTest, ThreadsafeDeathTestInLoop) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "threadsafe";
|
GTEST_FLAG_SET(death_test_style, "threadsafe");
|
||||||
|
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
EXPECT_EXIT(_exit(i), testing::ExitedWithCode(i), "") << ": i = " << i;
|
EXPECT_EXIT(_exit(i), testing::ExitedWithCode(i), "") << ": i = " << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, ThreadsafeDeathTestInChangedDir) {
|
TEST_F(TestForDeathTest, ThreadsafeDeathTestInChangedDir) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "threadsafe";
|
GTEST_FLAG_SET(death_test_style, "threadsafe");
|
||||||
|
|
||||||
ChangeToRootDir();
|
ChangeToRootDir();
|
||||||
EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), "");
|
EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), "");
|
||||||
@ -481,9 +481,9 @@ TEST_F(TestForDeathTest, ThreadsafeDeathTestInChangedDir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, MixedStyles) {
|
TEST_F(TestForDeathTest, MixedStyles) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "threadsafe";
|
GTEST_FLAG_SET(death_test_style, "threadsafe");
|
||||||
EXPECT_DEATH(_exit(1), "");
|
EXPECT_DEATH(_exit(1), "");
|
||||||
testing::GTEST_FLAG(death_test_style) = "fast";
|
GTEST_FLAG_SET(death_test_style, "fast");
|
||||||
EXPECT_DEATH(_exit(1), "");
|
EXPECT_DEATH(_exit(1), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,8 +496,8 @@ void SetPthreadFlag() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) {
|
TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) {
|
||||||
if (!testing::GTEST_FLAG(death_test_use_fork)) {
|
if (!GTEST_FLAG_GET(death_test_use_fork)) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "threadsafe";
|
GTEST_FLAG_SET(death_test_style, "threadsafe");
|
||||||
pthread_flag = false;
|
pthread_flag = false;
|
||||||
ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, nullptr, nullptr));
|
ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, nullptr, nullptr));
|
||||||
ASSERT_DEATH(_exit(1), "");
|
ASSERT_DEATH(_exit(1), "");
|
||||||
@ -740,10 +740,12 @@ TEST(PopUpDeathTest, DoesNotShowPopUpOnAbort) {
|
|||||||
"any pop-up dialogs.\n");
|
"any pop-up dialogs.\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
EXPECT_DEATH({
|
EXPECT_DEATH(
|
||||||
testing::GTEST_FLAG(catch_exceptions) = false;
|
{
|
||||||
|
GTEST_FLAG_SET(catch_exceptions, false);
|
||||||
abort();
|
abort();
|
||||||
}, "");
|
},
|
||||||
|
"");
|
||||||
}
|
}
|
||||||
# endif // GTEST_OS_WINDOWS
|
# endif // GTEST_OS_WINDOWS
|
||||||
|
|
||||||
@ -874,19 +876,19 @@ TEST_F(TestForDeathTest, ExitMacros) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, ExitMacrosUsingFork) {
|
TEST_F(TestForDeathTest, ExitMacrosUsingFork) {
|
||||||
testing::GTEST_FLAG(death_test_use_fork) = true;
|
GTEST_FLAG_SET(death_test_use_fork, true);
|
||||||
TestExitMacros();
|
TestExitMacros();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, InvalidStyle) {
|
TEST_F(TestForDeathTest, InvalidStyle) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "rococo";
|
GTEST_FLAG_SET(death_test_style, "rococo");
|
||||||
EXPECT_NONFATAL_FAILURE({ // NOLINT
|
EXPECT_NONFATAL_FAILURE({ // NOLINT
|
||||||
EXPECT_DEATH(_exit(0), "") << "This failure is expected.";
|
EXPECT_DEATH(_exit(0), "") << "This failure is expected.";
|
||||||
}, "This failure is expected.");
|
}, "This failure is expected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, DeathTestFailedOutput) {
|
TEST_F(TestForDeathTest, DeathTestFailedOutput) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "fast";
|
GTEST_FLAG_SET(death_test_style, "fast");
|
||||||
EXPECT_NONFATAL_FAILURE(
|
EXPECT_NONFATAL_FAILURE(
|
||||||
EXPECT_DEATH(DieWithMessage("death\n"),
|
EXPECT_DEATH(DieWithMessage("death\n"),
|
||||||
"expected message"),
|
"expected message"),
|
||||||
@ -895,7 +897,7 @@ TEST_F(TestForDeathTest, DeathTestFailedOutput) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, DeathTestUnexpectedReturnOutput) {
|
TEST_F(TestForDeathTest, DeathTestUnexpectedReturnOutput) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "fast";
|
GTEST_FLAG_SET(death_test_style, "fast");
|
||||||
EXPECT_NONFATAL_FAILURE(
|
EXPECT_NONFATAL_FAILURE(
|
||||||
EXPECT_DEATH({
|
EXPECT_DEATH({
|
||||||
fprintf(stderr, "returning\n");
|
fprintf(stderr, "returning\n");
|
||||||
@ -908,7 +910,7 @@ TEST_F(TestForDeathTest, DeathTestUnexpectedReturnOutput) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, DeathTestBadExitCodeOutput) {
|
TEST_F(TestForDeathTest, DeathTestBadExitCodeOutput) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "fast";
|
GTEST_FLAG_SET(death_test_style, "fast");
|
||||||
EXPECT_NONFATAL_FAILURE(
|
EXPECT_NONFATAL_FAILURE(
|
||||||
EXPECT_EXIT(DieWithMessage("exiting with rc 1\n"),
|
EXPECT_EXIT(DieWithMessage("exiting with rc 1\n"),
|
||||||
testing::ExitedWithCode(3),
|
testing::ExitedWithCode(3),
|
||||||
@ -920,7 +922,7 @@ TEST_F(TestForDeathTest, DeathTestBadExitCodeOutput) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, DeathTestMultiLineMatchFail) {
|
TEST_F(TestForDeathTest, DeathTestMultiLineMatchFail) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "fast";
|
GTEST_FLAG_SET(death_test_style, "fast");
|
||||||
EXPECT_NONFATAL_FAILURE(
|
EXPECT_NONFATAL_FAILURE(
|
||||||
EXPECT_DEATH(DieWithMessage("line 1\nline 2\nline 3\n"),
|
EXPECT_DEATH(DieWithMessage("line 1\nline 2\nline 3\n"),
|
||||||
"line 1\nxyz\nline 3\n"),
|
"line 1\nxyz\nline 3\n"),
|
||||||
@ -931,7 +933,7 @@ TEST_F(TestForDeathTest, DeathTestMultiLineMatchFail) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestForDeathTest, DeathTestMultiLineMatchPass) {
|
TEST_F(TestForDeathTest, DeathTestMultiLineMatchPass) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "fast";
|
GTEST_FLAG_SET(death_test_style, "fast");
|
||||||
EXPECT_DEATH(DieWithMessage("line 1\nline 2\nline 3\n"),
|
EXPECT_DEATH(DieWithMessage("line 1\nline 2\nline 3\n"),
|
||||||
"line 1\nline 2\nline 3\n");
|
"line 1\nline 2\nline 3\n");
|
||||||
}
|
}
|
||||||
@ -1358,7 +1360,7 @@ TEST(ConditionalDeathMacrosDeathTest, ExpectsDeathWhenDeathTestsAvailable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInFastStyle) {
|
TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInFastStyle) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "fast";
|
GTEST_FLAG_SET(death_test_style, "fast");
|
||||||
EXPECT_FALSE(InDeathTestChild());
|
EXPECT_FALSE(InDeathTestChild());
|
||||||
EXPECT_DEATH({
|
EXPECT_DEATH({
|
||||||
fprintf(stderr, InDeathTestChild() ? "Inside" : "Outside");
|
fprintf(stderr, InDeathTestChild() ? "Inside" : "Outside");
|
||||||
@ -1368,7 +1370,7 @@ TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInFastStyle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInThreadSafeStyle) {
|
TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInThreadSafeStyle) {
|
||||||
testing::GTEST_FLAG(death_test_style) = "threadsafe";
|
GTEST_FLAG_SET(death_test_style, "threadsafe");
|
||||||
EXPECT_FALSE(InDeathTestChild());
|
EXPECT_FALSE(InDeathTestChild());
|
||||||
EXPECT_DEATH({
|
EXPECT_DEATH({
|
||||||
fprintf(stderr, InDeathTestChild() ? "Inside" : "Outside");
|
fprintf(stderr, InDeathTestChild() ? "Inside" : "Outside");
|
||||||
|
@ -53,7 +53,7 @@ TEST(CxxExceptionDeathTest, ExceptionIsFailure) {
|
|||||||
} catch (...) { // NOLINT
|
} catch (...) { // NOLINT
|
||||||
FAIL() << "An exception escaped a death test macro invocation "
|
FAIL() << "An exception escaped a death test macro invocation "
|
||||||
<< "with catch_exceptions "
|
<< "with catch_exceptions "
|
||||||
<< (testing::GTEST_FLAG(catch_exceptions) ? "enabled" : "disabled");
|
<< (GTEST_FLAG_GET(catch_exceptions) ? "enabled" : "disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ TEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) {
|
|||||||
TEST(SehExceptionDeasTest, CatchExceptionsDoesNotInterfere) {
|
TEST(SehExceptionDeasTest, CatchExceptionsDoesNotInterfere) {
|
||||||
EXPECT_DEATH(RaiseException(42, 0x0, 0, NULL), "")
|
EXPECT_DEATH(RaiseException(42, 0x0, 0, NULL), "")
|
||||||
<< "with catch_exceptions "
|
<< "with catch_exceptions "
|
||||||
<< (testing::GTEST_FLAG(catch_exceptions) ? "enabled" : "disabled");
|
<< (GTEST_FLAG_GET(catch_exceptions) ? "enabled" : "disabled");
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -87,6 +87,6 @@ TEST(SehExceptionDeasTest, CatchExceptionsDoesNotInterfere) {
|
|||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
testing::GTEST_FLAG(catch_exceptions) = GTEST_ENABLE_CATCH_EXCEPTIONS_ != 0;
|
GTEST_FLAG_SET(catch_exceptions, GTEST_ENABLE_CATCH_EXCEPTIONS_ != 0);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
@ -48,67 +48,67 @@ TEST(GTestEnvVarTest, Dummy) {
|
|||||||
|
|
||||||
void PrintFlag(const char* flag) {
|
void PrintFlag(const char* flag) {
|
||||||
if (strcmp(flag, "break_on_failure") == 0) {
|
if (strcmp(flag, "break_on_failure") == 0) {
|
||||||
cout << GTEST_FLAG(break_on_failure);
|
cout << GTEST_FLAG_GET(break_on_failure);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(flag, "catch_exceptions") == 0) {
|
if (strcmp(flag, "catch_exceptions") == 0) {
|
||||||
cout << GTEST_FLAG(catch_exceptions);
|
cout << GTEST_FLAG_GET(catch_exceptions);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(flag, "color") == 0) {
|
if (strcmp(flag, "color") == 0) {
|
||||||
cout << GTEST_FLAG(color);
|
cout << GTEST_FLAG_GET(color);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(flag, "death_test_style") == 0) {
|
if (strcmp(flag, "death_test_style") == 0) {
|
||||||
cout << GTEST_FLAG(death_test_style);
|
cout << GTEST_FLAG_GET(death_test_style);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(flag, "death_test_use_fork") == 0) {
|
if (strcmp(flag, "death_test_use_fork") == 0) {
|
||||||
cout << GTEST_FLAG(death_test_use_fork);
|
cout << GTEST_FLAG_GET(death_test_use_fork);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(flag, "fail_fast") == 0) {
|
if (strcmp(flag, "fail_fast") == 0) {
|
||||||
cout << GTEST_FLAG(fail_fast);
|
cout << GTEST_FLAG_GET(fail_fast);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(flag, "filter") == 0) {
|
if (strcmp(flag, "filter") == 0) {
|
||||||
cout << GTEST_FLAG(filter);
|
cout << GTEST_FLAG_GET(filter);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(flag, "output") == 0) {
|
if (strcmp(flag, "output") == 0) {
|
||||||
cout << GTEST_FLAG(output);
|
cout << GTEST_FLAG_GET(output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(flag, "brief") == 0) {
|
if (strcmp(flag, "brief") == 0) {
|
||||||
cout << GTEST_FLAG(brief);
|
cout << GTEST_FLAG_GET(brief);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(flag, "print_time") == 0) {
|
if (strcmp(flag, "print_time") == 0) {
|
||||||
cout << GTEST_FLAG(print_time);
|
cout << GTEST_FLAG_GET(print_time);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(flag, "repeat") == 0) {
|
if (strcmp(flag, "repeat") == 0) {
|
||||||
cout << GTEST_FLAG(repeat);
|
cout << GTEST_FLAG_GET(repeat);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(flag, "stack_trace_depth") == 0) {
|
if (strcmp(flag, "stack_trace_depth") == 0) {
|
||||||
cout << GTEST_FLAG(stack_trace_depth);
|
cout << GTEST_FLAG_GET(stack_trace_depth);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(flag, "throw_on_failure") == 0) {
|
if (strcmp(flag, "throw_on_failure") == 0) {
|
||||||
cout << GTEST_FLAG(throw_on_failure);
|
cout << GTEST_FLAG_GET(throw_on_failure);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ int main(int argc, char **argv) {
|
|||||||
GTEST_CHECK_(events.size() == 0)
|
GTEST_CHECK_(events.size() == 0)
|
||||||
<< "AddGlobalTestEnvironment should not generate any events itself.";
|
<< "AddGlobalTestEnvironment should not generate any events itself.";
|
||||||
|
|
||||||
::testing::GTEST_FLAG(repeat) = 2;
|
GTEST_FLAG_SET(repeat, 2);
|
||||||
int ret_val = RUN_ALL_TESTS();
|
int ret_val = RUN_ALL_TESTS();
|
||||||
|
|
||||||
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||||
|
@ -61,29 +61,29 @@ FilePath GetAbsolutePathOf(const FilePath& relative_path) {
|
|||||||
// Testing UnitTestOptions::GetOutputFormat/GetOutputFile.
|
// Testing UnitTestOptions::GetOutputFormat/GetOutputFile.
|
||||||
|
|
||||||
TEST(XmlOutputTest, GetOutputFormatDefault) {
|
TEST(XmlOutputTest, GetOutputFormatDefault) {
|
||||||
GTEST_FLAG(output) = "";
|
GTEST_FLAG_SET(output, "");
|
||||||
EXPECT_STREQ("", UnitTestOptions::GetOutputFormat().c_str());
|
EXPECT_STREQ("", UnitTestOptions::GetOutputFormat().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(XmlOutputTest, GetOutputFormat) {
|
TEST(XmlOutputTest, GetOutputFormat) {
|
||||||
GTEST_FLAG(output) = "xml:filename";
|
GTEST_FLAG_SET(output, "xml:filename");
|
||||||
EXPECT_STREQ("xml", UnitTestOptions::GetOutputFormat().c_str());
|
EXPECT_STREQ("xml", UnitTestOptions::GetOutputFormat().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(XmlOutputTest, GetOutputFileDefault) {
|
TEST(XmlOutputTest, GetOutputFileDefault) {
|
||||||
GTEST_FLAG(output) = "";
|
GTEST_FLAG_SET(output, "");
|
||||||
EXPECT_EQ(GetAbsolutePathOf(FilePath("test_detail.xml")).string(),
|
EXPECT_EQ(GetAbsolutePathOf(FilePath("test_detail.xml")).string(),
|
||||||
UnitTestOptions::GetAbsolutePathToOutputFile());
|
UnitTestOptions::GetAbsolutePathToOutputFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(XmlOutputTest, GetOutputFileSingleFile) {
|
TEST(XmlOutputTest, GetOutputFileSingleFile) {
|
||||||
GTEST_FLAG(output) = "xml:filename.abc";
|
GTEST_FLAG_SET(output, "xml:filename.abc");
|
||||||
EXPECT_EQ(GetAbsolutePathOf(FilePath("filename.abc")).string(),
|
EXPECT_EQ(GetAbsolutePathOf(FilePath("filename.abc")).string(),
|
||||||
UnitTestOptions::GetAbsolutePathToOutputFile());
|
UnitTestOptions::GetAbsolutePathToOutputFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
|
TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
|
||||||
GTEST_FLAG(output) = "xml:path" GTEST_PATH_SEP_;
|
GTEST_FLAG_SET(output, "xml:path" GTEST_PATH_SEP_);
|
||||||
const std::string expected_output_file =
|
const std::string expected_output_file =
|
||||||
GetAbsolutePathOf(
|
GetAbsolutePathOf(
|
||||||
FilePath(std::string("path") + GTEST_PATH_SEP_ +
|
FilePath(std::string("path") + GTEST_PATH_SEP_ +
|
||||||
@ -144,28 +144,28 @@ class XmlOutputChangeDirTest : public Test {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefault) {
|
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefault) {
|
||||||
GTEST_FLAG(output) = "";
|
GTEST_FLAG_SET(output, "");
|
||||||
EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,
|
EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,
|
||||||
FilePath("test_detail.xml")).string(),
|
FilePath("test_detail.xml")).string(),
|
||||||
UnitTestOptions::GetAbsolutePathToOutputFile());
|
UnitTestOptions::GetAbsolutePathToOutputFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefaultXML) {
|
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefaultXML) {
|
||||||
GTEST_FLAG(output) = "xml";
|
GTEST_FLAG_SET(output, "xml");
|
||||||
EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,
|
EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,
|
||||||
FilePath("test_detail.xml")).string(),
|
FilePath("test_detail.xml")).string(),
|
||||||
UnitTestOptions::GetAbsolutePathToOutputFile());
|
UnitTestOptions::GetAbsolutePathToOutputFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativeFile) {
|
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativeFile) {
|
||||||
GTEST_FLAG(output) = "xml:filename.abc";
|
GTEST_FLAG_SET(output, "xml:filename.abc");
|
||||||
EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,
|
EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,
|
||||||
FilePath("filename.abc")).string(),
|
FilePath("filename.abc")).string(),
|
||||||
UnitTestOptions::GetAbsolutePathToOutputFile());
|
UnitTestOptions::GetAbsolutePathToOutputFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
|
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
|
||||||
GTEST_FLAG(output) = "xml:path" GTEST_PATH_SEP_;
|
GTEST_FLAG_SET(output, "xml:path" GTEST_PATH_SEP_);
|
||||||
const std::string expected_output_file =
|
const std::string expected_output_file =
|
||||||
FilePath::ConcatPaths(
|
FilePath::ConcatPaths(
|
||||||
original_working_dir_,
|
original_working_dir_,
|
||||||
@ -182,11 +182,11 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
|
|||||||
|
|
||||||
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {
|
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {
|
||||||
#if GTEST_OS_WINDOWS
|
#if GTEST_OS_WINDOWS
|
||||||
GTEST_FLAG(output) = "xml:c:\\tmp\\filename.abc";
|
GTEST_FLAG_SET(output, "xml:c:\\tmp\\filename.abc");
|
||||||
EXPECT_EQ(FilePath("c:\\tmp\\filename.abc").string(),
|
EXPECT_EQ(FilePath("c:\\tmp\\filename.abc").string(),
|
||||||
UnitTestOptions::GetAbsolutePathToOutputFile());
|
UnitTestOptions::GetAbsolutePathToOutputFile());
|
||||||
#else
|
#else
|
||||||
GTEST_FLAG(output) ="xml:/tmp/filename.abc";
|
GTEST_FLAG_SET(output, "xml:/tmp/filename.abc");
|
||||||
EXPECT_EQ(FilePath("/tmp/filename.abc").string(),
|
EXPECT_EQ(FilePath("/tmp/filename.abc").string(),
|
||||||
UnitTestOptions::GetAbsolutePathToOutputFile());
|
UnitTestOptions::GetAbsolutePathToOutputFile());
|
||||||
#endif
|
#endif
|
||||||
@ -199,7 +199,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {
|
|||||||
const std::string path = "/tmp/";
|
const std::string path = "/tmp/";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GTEST_FLAG(output) = "xml:" + path;
|
GTEST_FLAG_SET(output, "xml:" + path);
|
||||||
const std::string expected_output_file =
|
const std::string expected_output_file =
|
||||||
path + GetCurrentExecutableName().string() + ".xml";
|
path + GetCurrentExecutableName().string() + ".xml";
|
||||||
const std::string& output_file =
|
const std::string& output_file =
|
||||||
|
@ -1066,7 +1066,7 @@ class BarEnvironment : public testing::Environment {
|
|||||||
// of them are intended to fail), and then compare the test results
|
// of them are intended to fail), and then compare the test results
|
||||||
// with the "golden" file.
|
// with the "golden" file.
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
testing::GTEST_FLAG(print_time) = false;
|
GTEST_FLAG_SET(print_time, false);
|
||||||
|
|
||||||
// We just run the tests, knowing some of them are intended to fail.
|
// We just run the tests, knowing some of them are intended to fail.
|
||||||
// We will use a separate Python script to compare the output of
|
// We will use a separate Python script to compare the output of
|
||||||
@ -1081,7 +1081,7 @@ int main(int argc, char **argv) {
|
|||||||
std::string("internal_skip_environment_and_ad_hoc_tests")) > 0;
|
std::string("internal_skip_environment_and_ad_hoc_tests")) > 0;
|
||||||
|
|
||||||
#if GTEST_HAS_DEATH_TEST
|
#if GTEST_HAS_DEATH_TEST
|
||||||
if (testing::internal::GTEST_FLAG(internal_run_death_test) != "") {
|
if (GTEST_FLAG_GET(internal_run_death_test) != "") {
|
||||||
// Skip the usual output capturing if we're running as the child
|
// Skip the usual output capturing if we're running as the child
|
||||||
// process of an threadsafe-style death test.
|
// process of an threadsafe-style death test.
|
||||||
# if GTEST_OS_WINDOWS
|
# if GTEST_OS_WINDOWS
|
||||||
|
@ -35,10 +35,6 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/gtest-internal-inl.h"
|
#include "src/gtest-internal-inl.h"
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
GTEST_DECLARE_string_(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
enum FailureType {
|
enum FailureType {
|
||||||
@ -174,7 +170,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
// Verifies that RUN_ALL_TESTS() doesn't do global set-up or
|
// Verifies that RUN_ALL_TESTS() doesn't do global set-up or
|
||||||
// tear-down when there is no test to run.
|
// tear-down when there is no test to run.
|
||||||
testing::GTEST_FLAG(filter) = "-*";
|
GTEST_FLAG_SET(filter, "-*");
|
||||||
Check(RunAllTests(env, NO_FAILURE) == 0,
|
Check(RunAllTests(env, NO_FAILURE) == 0,
|
||||||
"RUN_ALL_TESTS() should return zero, as there is no test to run.");
|
"RUN_ALL_TESTS() should return zero, as there is no test to run.");
|
||||||
Check(!env->set_up_was_run(),
|
Check(!env->set_up_was_run(),
|
||||||
|
@ -35,18 +35,6 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/gtest-internal-inl.h"
|
#include "src/gtest-internal-inl.h"
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
GTEST_DECLARE_string_(death_test_style);
|
|
||||||
GTEST_DECLARE_string_(filter);
|
|
||||||
GTEST_DECLARE_int32_(repeat);
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
using testing::GTEST_FLAG(death_test_style);
|
|
||||||
using testing::GTEST_FLAG(filter);
|
|
||||||
using testing::GTEST_FLAG(repeat);
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// We need this when we are testing Google Test itself and therefore
|
// We need this when we are testing Google Test itself and therefore
|
||||||
@ -103,10 +91,10 @@ int g_death_test_count = 0;
|
|||||||
TEST(BarDeathTest, ThreadSafeAndFast) {
|
TEST(BarDeathTest, ThreadSafeAndFast) {
|
||||||
g_death_test_count++;
|
g_death_test_count++;
|
||||||
|
|
||||||
GTEST_FLAG(death_test_style) = "threadsafe";
|
GTEST_FLAG_SET(death_test_style, "threadsafe");
|
||||||
EXPECT_DEATH_IF_SUPPORTED(::testing::internal::posix::Abort(), "");
|
EXPECT_DEATH_IF_SUPPORTED(::testing::internal::posix::Abort(), "");
|
||||||
|
|
||||||
GTEST_FLAG(death_test_style) = "fast";
|
GTEST_FLAG_SET(death_test_style, "fast");
|
||||||
EXPECT_DEATH_IF_SUPPORTED(::testing::internal::posix::Abort(), "");
|
EXPECT_DEATH_IF_SUPPORTED(::testing::internal::posix::Abort(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +141,7 @@ void TestRepeatUnspecified() {
|
|||||||
|
|
||||||
// Tests the behavior of Google Test when --gtest_repeat has the given value.
|
// Tests the behavior of Google Test when --gtest_repeat has the given value.
|
||||||
void TestRepeat(int repeat) {
|
void TestRepeat(int repeat) {
|
||||||
GTEST_FLAG(repeat) = repeat;
|
GTEST_FLAG_SET(repeat, repeat);
|
||||||
|
|
||||||
ResetCounts();
|
ResetCounts();
|
||||||
GTEST_CHECK_INT_EQ_(repeat > 0 ? 1 : 0, RUN_ALL_TESTS());
|
GTEST_CHECK_INT_EQ_(repeat > 0 ? 1 : 0, RUN_ALL_TESTS());
|
||||||
@ -163,8 +151,8 @@ void TestRepeat(int repeat) {
|
|||||||
// Tests using --gtest_repeat when --gtest_filter specifies an empty
|
// Tests using --gtest_repeat when --gtest_filter specifies an empty
|
||||||
// set of tests.
|
// set of tests.
|
||||||
void TestRepeatWithEmptyFilter(int repeat) {
|
void TestRepeatWithEmptyFilter(int repeat) {
|
||||||
GTEST_FLAG(repeat) = repeat;
|
GTEST_FLAG_SET(repeat, repeat);
|
||||||
GTEST_FLAG(filter) = "None";
|
GTEST_FLAG_SET(filter, "None");
|
||||||
|
|
||||||
ResetCounts();
|
ResetCounts();
|
||||||
GTEST_CHECK_INT_EQ_(0, RUN_ALL_TESTS());
|
GTEST_CHECK_INT_EQ_(0, RUN_ALL_TESTS());
|
||||||
@ -174,8 +162,8 @@ void TestRepeatWithEmptyFilter(int repeat) {
|
|||||||
// Tests using --gtest_repeat when --gtest_filter specifies a set of
|
// Tests using --gtest_repeat when --gtest_filter specifies a set of
|
||||||
// successful tests.
|
// successful tests.
|
||||||
void TestRepeatWithFilterForSuccessfulTests(int repeat) {
|
void TestRepeatWithFilterForSuccessfulTests(int repeat) {
|
||||||
GTEST_FLAG(repeat) = repeat;
|
GTEST_FLAG_SET(repeat, repeat);
|
||||||
GTEST_FLAG(filter) = "*-*ShouldFail";
|
GTEST_FLAG_SET(filter, "*-*ShouldFail");
|
||||||
|
|
||||||
ResetCounts();
|
ResetCounts();
|
||||||
GTEST_CHECK_INT_EQ_(0, RUN_ALL_TESTS());
|
GTEST_CHECK_INT_EQ_(0, RUN_ALL_TESTS());
|
||||||
@ -190,8 +178,8 @@ void TestRepeatWithFilterForSuccessfulTests(int repeat) {
|
|||||||
// Tests using --gtest_repeat when --gtest_filter specifies a set of
|
// Tests using --gtest_repeat when --gtest_filter specifies a set of
|
||||||
// failed tests.
|
// failed tests.
|
||||||
void TestRepeatWithFilterForFailedTests(int repeat) {
|
void TestRepeatWithFilterForFailedTests(int repeat) {
|
||||||
GTEST_FLAG(repeat) = repeat;
|
GTEST_FLAG_SET(repeat, repeat);
|
||||||
GTEST_FLAG(filter) = "*ShouldFail";
|
GTEST_FLAG_SET(filter, "*ShouldFail");
|
||||||
|
|
||||||
ResetCounts();
|
ResetCounts();
|
||||||
GTEST_CHECK_INT_EQ_(1, RUN_ALL_TESTS());
|
GTEST_CHECK_INT_EQ_(1, RUN_ALL_TESTS());
|
||||||
|
@ -50,7 +50,7 @@ void Fail(const char* msg) {
|
|||||||
// Tests that an assertion failure throws a subclass of
|
// Tests that an assertion failure throws a subclass of
|
||||||
// std::runtime_error.
|
// std::runtime_error.
|
||||||
void TestFailureThrowsRuntimeError() {
|
void TestFailureThrowsRuntimeError() {
|
||||||
testing::GTEST_FLAG(throw_on_failure) = true;
|
GTEST_FLAG_SET(throw_on_failure, true);
|
||||||
|
|
||||||
// A successful assertion shouldn't throw.
|
// A successful assertion shouldn't throw.
|
||||||
try {
|
try {
|
||||||
|
@ -37,23 +37,19 @@
|
|||||||
// code once "gtest.h" has been #included.
|
// code once "gtest.h" has been #included.
|
||||||
// Do not move it after other gtest #includes.
|
// Do not move it after other gtest #includes.
|
||||||
TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
|
TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
|
||||||
bool dummy = testing::GTEST_FLAG(also_run_disabled_tests) ||
|
bool dummy =
|
||||||
testing::GTEST_FLAG(break_on_failure) ||
|
GTEST_FLAG_GET(also_run_disabled_tests) ||
|
||||||
testing::GTEST_FLAG(catch_exceptions) ||
|
GTEST_FLAG_GET(break_on_failure) || GTEST_FLAG_GET(catch_exceptions) ||
|
||||||
testing::GTEST_FLAG(color) != "unknown" ||
|
GTEST_FLAG_GET(color) != "unknown" || GTEST_FLAG_GET(fail_fast) ||
|
||||||
testing::GTEST_FLAG(fail_fast) ||
|
GTEST_FLAG_GET(filter) != "unknown" || GTEST_FLAG_GET(list_tests) ||
|
||||||
testing::GTEST_FLAG(filter) != "unknown" ||
|
GTEST_FLAG_GET(output) != "unknown" || GTEST_FLAG_GET(brief) ||
|
||||||
testing::GTEST_FLAG(list_tests) ||
|
GTEST_FLAG_GET(print_time) || GTEST_FLAG_GET(random_seed) ||
|
||||||
testing::GTEST_FLAG(output) != "unknown" ||
|
GTEST_FLAG_GET(repeat) > 0 ||
|
||||||
testing::GTEST_FLAG(brief) || testing::GTEST_FLAG(print_time) ||
|
GTEST_FLAG_GET(recreate_environments_when_repeating) ||
|
||||||
testing::GTEST_FLAG(random_seed) ||
|
GTEST_FLAG_GET(show_internal_stack_frames) || GTEST_FLAG_GET(shuffle) ||
|
||||||
testing::GTEST_FLAG(repeat) > 0 ||
|
GTEST_FLAG_GET(stack_trace_depth) > 0 ||
|
||||||
testing::GTEST_FLAG(recreate_environments_when_repeating) ||
|
GTEST_FLAG_GET(stream_result_to) != "unknown" ||
|
||||||
testing::GTEST_FLAG(show_internal_stack_frames) ||
|
GTEST_FLAG_GET(throw_on_failure);
|
||||||
testing::GTEST_FLAG(shuffle) ||
|
|
||||||
testing::GTEST_FLAG(stack_trace_depth) > 0 ||
|
|
||||||
testing::GTEST_FLAG(stream_result_to) != "unknown" ||
|
|
||||||
testing::GTEST_FLAG(throw_on_failure);
|
|
||||||
EXPECT_TRUE(dummy || !dummy); // Suppresses warning that dummy is unused.
|
EXPECT_TRUE(dummy || !dummy); // Suppresses warning that dummy is unused.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,25 +196,6 @@ using testing::DoubleLE;
|
|||||||
using testing::EmptyTestEventListener;
|
using testing::EmptyTestEventListener;
|
||||||
using testing::Environment;
|
using testing::Environment;
|
||||||
using testing::FloatLE;
|
using testing::FloatLE;
|
||||||
using testing::GTEST_FLAG(also_run_disabled_tests);
|
|
||||||
using testing::GTEST_FLAG(break_on_failure);
|
|
||||||
using testing::GTEST_FLAG(catch_exceptions);
|
|
||||||
using testing::GTEST_FLAG(color);
|
|
||||||
using testing::GTEST_FLAG(death_test_use_fork);
|
|
||||||
using testing::GTEST_FLAG(fail_fast);
|
|
||||||
using testing::GTEST_FLAG(filter);
|
|
||||||
using testing::GTEST_FLAG(list_tests);
|
|
||||||
using testing::GTEST_FLAG(output);
|
|
||||||
using testing::GTEST_FLAG(brief);
|
|
||||||
using testing::GTEST_FLAG(print_time);
|
|
||||||
using testing::GTEST_FLAG(random_seed);
|
|
||||||
using testing::GTEST_FLAG(repeat);
|
|
||||||
using testing::GTEST_FLAG(recreate_environments_when_repeating);
|
|
||||||
using testing::GTEST_FLAG(show_internal_stack_frames);
|
|
||||||
using testing::GTEST_FLAG(shuffle);
|
|
||||||
using testing::GTEST_FLAG(stack_trace_depth);
|
|
||||||
using testing::GTEST_FLAG(stream_result_to);
|
|
||||||
using testing::GTEST_FLAG(throw_on_failure);
|
|
||||||
using testing::IsNotSubstring;
|
using testing::IsNotSubstring;
|
||||||
using testing::IsSubstring;
|
using testing::IsSubstring;
|
||||||
using testing::kMaxStackTraceDepth;
|
using testing::kMaxStackTraceDepth;
|
||||||
@ -267,7 +244,7 @@ using testing::internal::kTestTypeIdInGoogleTest;
|
|||||||
using testing::internal::NativeArray;
|
using testing::internal::NativeArray;
|
||||||
using testing::internal::OsStackTraceGetter;
|
using testing::internal::OsStackTraceGetter;
|
||||||
using testing::internal::OsStackTraceGetterInterface;
|
using testing::internal::OsStackTraceGetterInterface;
|
||||||
using testing::internal::ParseInt32Flag;
|
using testing::internal::ParseFlag;
|
||||||
using testing::internal::RelationToSourceCopy;
|
using testing::internal::RelationToSourceCopy;
|
||||||
using testing::internal::RelationToSourceReference;
|
using testing::internal::RelationToSourceReference;
|
||||||
using testing::internal::ShouldRunTestOnShard;
|
using testing::internal::ShouldRunTestOnShard;
|
||||||
@ -1599,24 +1576,24 @@ class GTestFlagSaverTest : public Test {
|
|||||||
static void SetUpTestSuite() {
|
static void SetUpTestSuite() {
|
||||||
saver_ = new GTestFlagSaver;
|
saver_ = new GTestFlagSaver;
|
||||||
|
|
||||||
GTEST_FLAG(also_run_disabled_tests) = false;
|
GTEST_FLAG_SET(also_run_disabled_tests, false);
|
||||||
GTEST_FLAG(break_on_failure) = false;
|
GTEST_FLAG_SET(break_on_failure, false);
|
||||||
GTEST_FLAG(catch_exceptions) = false;
|
GTEST_FLAG_SET(catch_exceptions, false);
|
||||||
GTEST_FLAG(death_test_use_fork) = false;
|
GTEST_FLAG_SET(death_test_use_fork, false);
|
||||||
GTEST_FLAG(color) = "auto";
|
GTEST_FLAG_SET(color, "auto");
|
||||||
GTEST_FLAG(fail_fast) = false;
|
GTEST_FLAG_SET(fail_fast, false);
|
||||||
GTEST_FLAG(filter) = "";
|
GTEST_FLAG_SET(filter, "");
|
||||||
GTEST_FLAG(list_tests) = false;
|
GTEST_FLAG_SET(list_tests, false);
|
||||||
GTEST_FLAG(output) = "";
|
GTEST_FLAG_SET(output, "");
|
||||||
GTEST_FLAG(brief) = false;
|
GTEST_FLAG_SET(brief, false);
|
||||||
GTEST_FLAG(print_time) = true;
|
GTEST_FLAG_SET(print_time, true);
|
||||||
GTEST_FLAG(random_seed) = 0;
|
GTEST_FLAG_SET(random_seed, 0);
|
||||||
GTEST_FLAG(repeat) = 1;
|
GTEST_FLAG_SET(repeat, 1);
|
||||||
GTEST_FLAG(recreate_environments_when_repeating) = true;
|
GTEST_FLAG_SET(recreate_environments_when_repeating, true);
|
||||||
GTEST_FLAG(shuffle) = false;
|
GTEST_FLAG_SET(shuffle, false);
|
||||||
GTEST_FLAG(stack_trace_depth) = kMaxStackTraceDepth;
|
GTEST_FLAG_SET(stack_trace_depth, kMaxStackTraceDepth);
|
||||||
GTEST_FLAG(stream_result_to) = "";
|
GTEST_FLAG_SET(stream_result_to, "");
|
||||||
GTEST_FLAG(throw_on_failure) = false;
|
GTEST_FLAG_SET(throw_on_failure, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restores the Google Test flags that the tests have modified. This will
|
// Restores the Google Test flags that the tests have modified. This will
|
||||||
@ -1629,43 +1606,43 @@ class GTestFlagSaverTest : public Test {
|
|||||||
// Verifies that the Google Test flags have their default values, and then
|
// Verifies that the Google Test flags have their default values, and then
|
||||||
// modifies each of them.
|
// modifies each of them.
|
||||||
void VerifyAndModifyFlags() {
|
void VerifyAndModifyFlags() {
|
||||||
EXPECT_FALSE(GTEST_FLAG(also_run_disabled_tests));
|
EXPECT_FALSE(GTEST_FLAG_GET(also_run_disabled_tests));
|
||||||
EXPECT_FALSE(GTEST_FLAG(break_on_failure));
|
EXPECT_FALSE(GTEST_FLAG_GET(break_on_failure));
|
||||||
EXPECT_FALSE(GTEST_FLAG(catch_exceptions));
|
EXPECT_FALSE(GTEST_FLAG_GET(catch_exceptions));
|
||||||
EXPECT_STREQ("auto", GTEST_FLAG(color).c_str());
|
EXPECT_STREQ("auto", GTEST_FLAG_GET(color).c_str());
|
||||||
EXPECT_FALSE(GTEST_FLAG(death_test_use_fork));
|
EXPECT_FALSE(GTEST_FLAG_GET(death_test_use_fork));
|
||||||
EXPECT_FALSE(GTEST_FLAG(fail_fast));
|
EXPECT_FALSE(GTEST_FLAG_GET(fail_fast));
|
||||||
EXPECT_STREQ("", GTEST_FLAG(filter).c_str());
|
EXPECT_STREQ("", GTEST_FLAG_GET(filter).c_str());
|
||||||
EXPECT_FALSE(GTEST_FLAG(list_tests));
|
EXPECT_FALSE(GTEST_FLAG_GET(list_tests));
|
||||||
EXPECT_STREQ("", GTEST_FLAG(output).c_str());
|
EXPECT_STREQ("", GTEST_FLAG_GET(output).c_str());
|
||||||
EXPECT_FALSE(GTEST_FLAG(brief));
|
EXPECT_FALSE(GTEST_FLAG_GET(brief));
|
||||||
EXPECT_TRUE(GTEST_FLAG(print_time));
|
EXPECT_TRUE(GTEST_FLAG_GET(print_time));
|
||||||
EXPECT_EQ(0, GTEST_FLAG(random_seed));
|
EXPECT_EQ(0, GTEST_FLAG_GET(random_seed));
|
||||||
EXPECT_EQ(1, GTEST_FLAG(repeat));
|
EXPECT_EQ(1, GTEST_FLAG_GET(repeat));
|
||||||
EXPECT_TRUE(GTEST_FLAG(recreate_environments_when_repeating));
|
EXPECT_TRUE(GTEST_FLAG_GET(recreate_environments_when_repeating));
|
||||||
EXPECT_FALSE(GTEST_FLAG(shuffle));
|
EXPECT_FALSE(GTEST_FLAG_GET(shuffle));
|
||||||
EXPECT_EQ(kMaxStackTraceDepth, GTEST_FLAG(stack_trace_depth));
|
EXPECT_EQ(kMaxStackTraceDepth, GTEST_FLAG_GET(stack_trace_depth));
|
||||||
EXPECT_STREQ("", GTEST_FLAG(stream_result_to).c_str());
|
EXPECT_STREQ("", GTEST_FLAG_GET(stream_result_to).c_str());
|
||||||
EXPECT_FALSE(GTEST_FLAG(throw_on_failure));
|
EXPECT_FALSE(GTEST_FLAG_GET(throw_on_failure));
|
||||||
|
|
||||||
GTEST_FLAG(also_run_disabled_tests) = true;
|
GTEST_FLAG_SET(also_run_disabled_tests, true);
|
||||||
GTEST_FLAG(break_on_failure) = true;
|
GTEST_FLAG_SET(break_on_failure, true);
|
||||||
GTEST_FLAG(catch_exceptions) = true;
|
GTEST_FLAG_SET(catch_exceptions, true);
|
||||||
GTEST_FLAG(color) = "no";
|
GTEST_FLAG_SET(color, "no");
|
||||||
GTEST_FLAG(death_test_use_fork) = true;
|
GTEST_FLAG_SET(death_test_use_fork, true);
|
||||||
GTEST_FLAG(fail_fast) = true;
|
GTEST_FLAG_SET(fail_fast, true);
|
||||||
GTEST_FLAG(filter) = "abc";
|
GTEST_FLAG_SET(filter, "abc");
|
||||||
GTEST_FLAG(list_tests) = true;
|
GTEST_FLAG_SET(list_tests, true);
|
||||||
GTEST_FLAG(output) = "xml:foo.xml";
|
GTEST_FLAG_SET(output, "xml:foo.xml");
|
||||||
GTEST_FLAG(brief) = true;
|
GTEST_FLAG_SET(brief, true);
|
||||||
GTEST_FLAG(print_time) = false;
|
GTEST_FLAG_SET(print_time, false);
|
||||||
GTEST_FLAG(random_seed) = 1;
|
GTEST_FLAG_SET(random_seed, 1);
|
||||||
GTEST_FLAG(repeat) = 100;
|
GTEST_FLAG_SET(repeat, 100);
|
||||||
GTEST_FLAG(recreate_environments_when_repeating) = false;
|
GTEST_FLAG_SET(recreate_environments_when_repeating, false);
|
||||||
GTEST_FLAG(shuffle) = true;
|
GTEST_FLAG_SET(shuffle, true);
|
||||||
GTEST_FLAG(stack_trace_depth) = 1;
|
GTEST_FLAG_SET(stack_trace_depth, 1);
|
||||||
GTEST_FLAG(stream_result_to) = "localhost:1234";
|
GTEST_FLAG_SET(stream_result_to, "localhost:1234");
|
||||||
GTEST_FLAG(throw_on_failure) = true;
|
GTEST_FLAG_SET(throw_on_failure, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -1781,29 +1758,29 @@ TEST(Int32FromGTestEnvTest, ParsesAndReturnsValidValue) {
|
|||||||
}
|
}
|
||||||
#endif // !GTEST_OS_WINDOWS_MOBILE
|
#endif // !GTEST_OS_WINDOWS_MOBILE
|
||||||
|
|
||||||
// Tests ParseInt32Flag().
|
// Tests ParseFlag().
|
||||||
|
|
||||||
// Tests that ParseInt32Flag() returns false and doesn't change the
|
// Tests that ParseInt32Flag() returns false and doesn't change the
|
||||||
// output value when the flag has wrong format
|
// output value when the flag has wrong format
|
||||||
TEST(ParseInt32FlagTest, ReturnsFalseForInvalidFlag) {
|
TEST(ParseInt32FlagTest, ReturnsFalseForInvalidFlag) {
|
||||||
int32_t value = 123;
|
int32_t value = 123;
|
||||||
EXPECT_FALSE(ParseInt32Flag("--a=100", "b", &value));
|
EXPECT_FALSE(ParseFlag("--a=100", "b", &value));
|
||||||
EXPECT_EQ(123, value);
|
EXPECT_EQ(123, value);
|
||||||
|
|
||||||
EXPECT_FALSE(ParseInt32Flag("a=100", "a", &value));
|
EXPECT_FALSE(ParseFlag("a=100", "a", &value));
|
||||||
EXPECT_EQ(123, value);
|
EXPECT_EQ(123, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that ParseInt32Flag() returns false and doesn't change the
|
// Tests that ParseFlag() returns false and doesn't change the
|
||||||
// output value when the flag overflows as an Int32.
|
// output value when the flag overflows as an Int32.
|
||||||
TEST(ParseInt32FlagTest, ReturnsDefaultWhenValueOverflows) {
|
TEST(ParseInt32FlagTest, ReturnsDefaultWhenValueOverflows) {
|
||||||
printf("(expecting 2 warnings)\n");
|
printf("(expecting 2 warnings)\n");
|
||||||
|
|
||||||
int32_t value = 123;
|
int32_t value = 123;
|
||||||
EXPECT_FALSE(ParseInt32Flag("--abc=12345678987654321", "abc", &value));
|
EXPECT_FALSE(ParseFlag("--abc=12345678987654321", "abc", &value));
|
||||||
EXPECT_EQ(123, value);
|
EXPECT_EQ(123, value);
|
||||||
|
|
||||||
EXPECT_FALSE(ParseInt32Flag("--abc=-12345678987654321", "abc", &value));
|
EXPECT_FALSE(ParseFlag("--abc=-12345678987654321", "abc", &value));
|
||||||
EXPECT_EQ(123, value);
|
EXPECT_EQ(123, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1814,10 +1791,10 @@ TEST(ParseInt32FlagTest, ReturnsDefaultWhenValueIsInvalid) {
|
|||||||
printf("(expecting 2 warnings)\n");
|
printf("(expecting 2 warnings)\n");
|
||||||
|
|
||||||
int32_t value = 123;
|
int32_t value = 123;
|
||||||
EXPECT_FALSE(ParseInt32Flag("--abc=A1", "abc", &value));
|
EXPECT_FALSE(ParseFlag("--abc=A1", "abc", &value));
|
||||||
EXPECT_EQ(123, value);
|
EXPECT_EQ(123, value);
|
||||||
|
|
||||||
EXPECT_FALSE(ParseInt32Flag("--abc=12X", "abc", &value));
|
EXPECT_FALSE(ParseFlag("--abc=12X", "abc", &value));
|
||||||
EXPECT_EQ(123, value);
|
EXPECT_EQ(123, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1826,11 +1803,10 @@ TEST(ParseInt32FlagTest, ReturnsDefaultWhenValueIsInvalid) {
|
|||||||
// the range of an Int32.
|
// the range of an Int32.
|
||||||
TEST(ParseInt32FlagTest, ParsesAndReturnsValidValue) {
|
TEST(ParseInt32FlagTest, ParsesAndReturnsValidValue) {
|
||||||
int32_t value = 123;
|
int32_t value = 123;
|
||||||
EXPECT_TRUE(ParseInt32Flag("--" GTEST_FLAG_PREFIX_ "abc=456", "abc", &value));
|
EXPECT_TRUE(ParseFlag("--" GTEST_FLAG_PREFIX_ "abc=456", "abc", &value));
|
||||||
EXPECT_EQ(456, value);
|
EXPECT_EQ(456, value);
|
||||||
|
|
||||||
EXPECT_TRUE(ParseInt32Flag("--" GTEST_FLAG_PREFIX_ "abc=-789",
|
EXPECT_TRUE(ParseFlag("--" GTEST_FLAG_PREFIX_ "abc=-789", "abc", &value));
|
||||||
"abc", &value));
|
|
||||||
EXPECT_EQ(-789, value);
|
EXPECT_EQ(-789, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5756,23 +5732,23 @@ class ParseFlagsTest : public Test {
|
|||||||
protected:
|
protected:
|
||||||
// Clears the flags before each test.
|
// Clears the flags before each test.
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
GTEST_FLAG(also_run_disabled_tests) = false;
|
GTEST_FLAG_SET(also_run_disabled_tests, false);
|
||||||
GTEST_FLAG(break_on_failure) = false;
|
GTEST_FLAG_SET(break_on_failure, false);
|
||||||
GTEST_FLAG(catch_exceptions) = false;
|
GTEST_FLAG_SET(catch_exceptions, false);
|
||||||
GTEST_FLAG(death_test_use_fork) = false;
|
GTEST_FLAG_SET(death_test_use_fork, false);
|
||||||
GTEST_FLAG(fail_fast) = false;
|
GTEST_FLAG_SET(fail_fast, false);
|
||||||
GTEST_FLAG(filter) = "";
|
GTEST_FLAG_SET(filter, "");
|
||||||
GTEST_FLAG(list_tests) = false;
|
GTEST_FLAG_SET(list_tests, false);
|
||||||
GTEST_FLAG(output) = "";
|
GTEST_FLAG_SET(output, "");
|
||||||
GTEST_FLAG(brief) = false;
|
GTEST_FLAG_SET(brief, false);
|
||||||
GTEST_FLAG(print_time) = true;
|
GTEST_FLAG_SET(print_time, true);
|
||||||
GTEST_FLAG(random_seed) = 0;
|
GTEST_FLAG_SET(random_seed, 0);
|
||||||
GTEST_FLAG(repeat) = 1;
|
GTEST_FLAG_SET(repeat, 1);
|
||||||
GTEST_FLAG(recreate_environments_when_repeating) = true;
|
GTEST_FLAG_SET(recreate_environments_when_repeating, true);
|
||||||
GTEST_FLAG(shuffle) = false;
|
GTEST_FLAG_SET(shuffle, false);
|
||||||
GTEST_FLAG(stack_trace_depth) = kMaxStackTraceDepth;
|
GTEST_FLAG_SET(stack_trace_depth, kMaxStackTraceDepth);
|
||||||
GTEST_FLAG(stream_result_to) = "";
|
GTEST_FLAG_SET(stream_result_to, "");
|
||||||
GTEST_FLAG(throw_on_failure) = false;
|
GTEST_FLAG_SET(throw_on_failure, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asserts that two narrow or wide string arrays are equal.
|
// Asserts that two narrow or wide string arrays are equal.
|
||||||
@ -5789,25 +5765,26 @@ class ParseFlagsTest : public Test {
|
|||||||
// Verifies that the flag values match the expected values.
|
// Verifies that the flag values match the expected values.
|
||||||
static void CheckFlags(const Flags& expected) {
|
static void CheckFlags(const Flags& expected) {
|
||||||
EXPECT_EQ(expected.also_run_disabled_tests,
|
EXPECT_EQ(expected.also_run_disabled_tests,
|
||||||
GTEST_FLAG(also_run_disabled_tests));
|
GTEST_FLAG_GET(also_run_disabled_tests));
|
||||||
EXPECT_EQ(expected.break_on_failure, GTEST_FLAG(break_on_failure));
|
EXPECT_EQ(expected.break_on_failure, GTEST_FLAG_GET(break_on_failure));
|
||||||
EXPECT_EQ(expected.catch_exceptions, GTEST_FLAG(catch_exceptions));
|
EXPECT_EQ(expected.catch_exceptions, GTEST_FLAG_GET(catch_exceptions));
|
||||||
EXPECT_EQ(expected.death_test_use_fork, GTEST_FLAG(death_test_use_fork));
|
EXPECT_EQ(expected.death_test_use_fork,
|
||||||
EXPECT_EQ(expected.fail_fast, GTEST_FLAG(fail_fast));
|
GTEST_FLAG_GET(death_test_use_fork));
|
||||||
EXPECT_STREQ(expected.filter, GTEST_FLAG(filter).c_str());
|
EXPECT_EQ(expected.fail_fast, GTEST_FLAG_GET(fail_fast));
|
||||||
EXPECT_EQ(expected.list_tests, GTEST_FLAG(list_tests));
|
EXPECT_STREQ(expected.filter, GTEST_FLAG_GET(filter).c_str());
|
||||||
EXPECT_STREQ(expected.output, GTEST_FLAG(output).c_str());
|
EXPECT_EQ(expected.list_tests, GTEST_FLAG_GET(list_tests));
|
||||||
EXPECT_EQ(expected.brief, GTEST_FLAG(brief));
|
EXPECT_STREQ(expected.output, GTEST_FLAG_GET(output).c_str());
|
||||||
EXPECT_EQ(expected.print_time, GTEST_FLAG(print_time));
|
EXPECT_EQ(expected.brief, GTEST_FLAG_GET(brief));
|
||||||
EXPECT_EQ(expected.random_seed, GTEST_FLAG(random_seed));
|
EXPECT_EQ(expected.print_time, GTEST_FLAG_GET(print_time));
|
||||||
EXPECT_EQ(expected.repeat, GTEST_FLAG(repeat));
|
EXPECT_EQ(expected.random_seed, GTEST_FLAG_GET(random_seed));
|
||||||
|
EXPECT_EQ(expected.repeat, GTEST_FLAG_GET(repeat));
|
||||||
EXPECT_EQ(expected.recreate_environments_when_repeating,
|
EXPECT_EQ(expected.recreate_environments_when_repeating,
|
||||||
GTEST_FLAG(recreate_environments_when_repeating));
|
GTEST_FLAG_GET(recreate_environments_when_repeating));
|
||||||
EXPECT_EQ(expected.shuffle, GTEST_FLAG(shuffle));
|
EXPECT_EQ(expected.shuffle, GTEST_FLAG_GET(shuffle));
|
||||||
EXPECT_EQ(expected.stack_trace_depth, GTEST_FLAG(stack_trace_depth));
|
EXPECT_EQ(expected.stack_trace_depth, GTEST_FLAG_GET(stack_trace_depth));
|
||||||
EXPECT_STREQ(expected.stream_result_to,
|
EXPECT_STREQ(expected.stream_result_to,
|
||||||
GTEST_FLAG(stream_result_to).c_str());
|
GTEST_FLAG_GET(stream_result_to).c_str());
|
||||||
EXPECT_EQ(expected.throw_on_failure, GTEST_FLAG(throw_on_failure));
|
EXPECT_EQ(expected.throw_on_failure, GTEST_FLAG_GET(throw_on_failure));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parses a command line (specified by argc1 and argv1), then
|
// Parses a command line (specified by argc1 and argv1), then
|
||||||
@ -6639,7 +6616,7 @@ TEST(StreamingAssertionsTest, AnyThrow) {
|
|||||||
// Tests that Google Test correctly decides whether to use colors in the output.
|
// Tests that Google Test correctly decides whether to use colors in the output.
|
||||||
|
|
||||||
TEST(ColoredOutputTest, UsesColorsWhenGTestColorFlagIsYes) {
|
TEST(ColoredOutputTest, UsesColorsWhenGTestColorFlagIsYes) {
|
||||||
GTEST_FLAG(color) = "yes";
|
GTEST_FLAG_SET(color, "yes");
|
||||||
|
|
||||||
SetEnv("TERM", "xterm"); // TERM supports colors.
|
SetEnv("TERM", "xterm"); // TERM supports colors.
|
||||||
EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
|
EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
|
||||||
@ -6653,18 +6630,18 @@ TEST(ColoredOutputTest, UsesColorsWhenGTestColorFlagIsYes) {
|
|||||||
TEST(ColoredOutputTest, UsesColorsWhenGTestColorFlagIsAliasOfYes) {
|
TEST(ColoredOutputTest, UsesColorsWhenGTestColorFlagIsAliasOfYes) {
|
||||||
SetEnv("TERM", "dumb"); // TERM doesn't support colors.
|
SetEnv("TERM", "dumb"); // TERM doesn't support colors.
|
||||||
|
|
||||||
GTEST_FLAG(color) = "True";
|
GTEST_FLAG_SET(color, "True");
|
||||||
EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY.
|
EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY.
|
||||||
|
|
||||||
GTEST_FLAG(color) = "t";
|
GTEST_FLAG_SET(color, "t");
|
||||||
EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY.
|
EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY.
|
||||||
|
|
||||||
GTEST_FLAG(color) = "1";
|
GTEST_FLAG_SET(color, "1");
|
||||||
EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY.
|
EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY.
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsNo) {
|
TEST(ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsNo) {
|
||||||
GTEST_FLAG(color) = "no";
|
GTEST_FLAG_SET(color, "no");
|
||||||
|
|
||||||
SetEnv("TERM", "xterm"); // TERM supports colors.
|
SetEnv("TERM", "xterm"); // TERM supports colors.
|
||||||
EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
|
EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
|
||||||
@ -6678,18 +6655,18 @@ TEST(ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsNo) {
|
|||||||
TEST(ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsInvalid) {
|
TEST(ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsInvalid) {
|
||||||
SetEnv("TERM", "xterm"); // TERM supports colors.
|
SetEnv("TERM", "xterm"); // TERM supports colors.
|
||||||
|
|
||||||
GTEST_FLAG(color) = "F";
|
GTEST_FLAG_SET(color, "F");
|
||||||
EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
|
EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
|
||||||
|
|
||||||
GTEST_FLAG(color) = "0";
|
GTEST_FLAG_SET(color, "0");
|
||||||
EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
|
EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
|
||||||
|
|
||||||
GTEST_FLAG(color) = "unknown";
|
GTEST_FLAG_SET(color, "unknown");
|
||||||
EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
|
EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ColoredOutputTest, UsesColorsWhenStdoutIsTty) {
|
TEST(ColoredOutputTest, UsesColorsWhenStdoutIsTty) {
|
||||||
GTEST_FLAG(color) = "auto";
|
GTEST_FLAG_SET(color, "auto");
|
||||||
|
|
||||||
SetEnv("TERM", "xterm"); // TERM supports colors.
|
SetEnv("TERM", "xterm"); // TERM supports colors.
|
||||||
EXPECT_FALSE(ShouldUseColor(false)); // Stdout is not a TTY.
|
EXPECT_FALSE(ShouldUseColor(false)); // Stdout is not a TTY.
|
||||||
@ -6697,7 +6674,7 @@ TEST(ColoredOutputTest, UsesColorsWhenStdoutIsTty) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {
|
TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {
|
||||||
GTEST_FLAG(color) = "auto";
|
GTEST_FLAG_SET(color, "auto");
|
||||||
|
|
||||||
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
|
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
|
||||||
// On Windows, we ignore the TERM variable as it's usually not set.
|
// On Windows, we ignore the TERM variable as it's usually not set.
|
||||||
|
Loading…
Reference in New Issue
Block a user