Commit 3dddf703 authored by Alexander Alekhin's avatar Alexander Alekhin

ts: re-apply OpenCV-specific patch on googletest 1.8.1

parent f7ccc74e
This diff is collapsed.
...@@ -35,7 +35,15 @@ ...@@ -35,7 +35,15 @@
// This line ensures that gtest.h can be compiled on its own, even // This line ensures that gtest.h can be compiled on its own, even
// when it's fused. // when it's fused.
#include "gtest/gtest.h" #include "precomp.hpp"
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
# if __GNUC__ >= 5
# pragma GCC diagnostic ignored "-Wsuggest-override"
# endif
#endif
// The following lines pull in the real gtest *.cc files. // The following lines pull in the real gtest *.cc files.
// Copyright 2005, Google Inc. // Copyright 2005, Google Inc.
...@@ -487,6 +495,7 @@ const char kBreakOnFailureFlag[] = "break_on_failure"; ...@@ -487,6 +495,7 @@ const char kBreakOnFailureFlag[] = "break_on_failure";
const char kCatchExceptionsFlag[] = "catch_exceptions"; const char kCatchExceptionsFlag[] = "catch_exceptions";
const char kColorFlag[] = "color"; const char kColorFlag[] = "color";
const char kFilterFlag[] = "filter"; const char kFilterFlag[] = "filter";
const char kParamFilterFlag[] = "param_filter";
const char kListTestsFlag[] = "list_tests"; const char kListTestsFlag[] = "list_tests";
const char kOutputFlag[] = "output"; const char kOutputFlag[] = "output";
const char kPrintTimeFlag[] = "print_time"; const char kPrintTimeFlag[] = "print_time";
...@@ -567,6 +576,7 @@ class GTestFlagSaver { ...@@ -567,6 +576,7 @@ class GTestFlagSaver {
death_test_style_ = GTEST_FLAG(death_test_style); death_test_style_ = GTEST_FLAG(death_test_style);
death_test_use_fork_ = GTEST_FLAG(death_test_use_fork); death_test_use_fork_ = GTEST_FLAG(death_test_use_fork);
filter_ = GTEST_FLAG(filter); filter_ = GTEST_FLAG(filter);
param_filter_ = GTEST_FLAG(param_filter);
internal_run_death_test_ = GTEST_FLAG(internal_run_death_test); internal_run_death_test_ = GTEST_FLAG(internal_run_death_test);
list_tests_ = GTEST_FLAG(list_tests); list_tests_ = GTEST_FLAG(list_tests);
output_ = GTEST_FLAG(output); output_ = GTEST_FLAG(output);
...@@ -589,6 +599,7 @@ class GTestFlagSaver { ...@@ -589,6 +599,7 @@ class GTestFlagSaver {
GTEST_FLAG(death_test_style) = death_test_style_; GTEST_FLAG(death_test_style) = death_test_style_;
GTEST_FLAG(death_test_use_fork) = death_test_use_fork_; GTEST_FLAG(death_test_use_fork) = death_test_use_fork_;
GTEST_FLAG(filter) = filter_; GTEST_FLAG(filter) = filter_;
GTEST_FLAG(param_filter) = param_filter_;
GTEST_FLAG(internal_run_death_test) = internal_run_death_test_; GTEST_FLAG(internal_run_death_test) = internal_run_death_test_;
GTEST_FLAG(list_tests) = list_tests_; GTEST_FLAG(list_tests) = list_tests_;
GTEST_FLAG(output) = output_; GTEST_FLAG(output) = output_;
...@@ -611,6 +622,7 @@ class GTestFlagSaver { ...@@ -611,6 +622,7 @@ class GTestFlagSaver {
std::string death_test_style_; std::string death_test_style_;
bool death_test_use_fork_; bool death_test_use_fork_;
std::string filter_; std::string filter_;
std::string param_filter_;
std::string internal_run_death_test_; std::string internal_run_death_test_;
bool list_tests_; bool list_tests_;
std::string output_; std::string output_;
...@@ -1718,6 +1730,12 @@ GTEST_DEFINE_bool_( ...@@ -1718,6 +1730,12 @@ GTEST_DEFINE_bool_(
"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.");
GTEST_DEFINE_string_(
param_filter,
internal::StringFromGTestEnv("param_filter", GetDefaultFilter()),
"Same syntax and semantics as for param, but these patterns "
"have to match the test's parameters.");
GTEST_DEFINE_bool_(list_tests, false, GTEST_DEFINE_bool_(list_tests, false,
"List all tests without running them."); "List all tests without running them.");
...@@ -4592,6 +4610,14 @@ void PrettyUnitTestResultPrinter::OnTestIterationStart( ...@@ -4592,6 +4610,14 @@ void PrettyUnitTestResultPrinter::OnTestIterationStart(
"Note: %s filter = %s\n", GTEST_NAME_, filter); "Note: %s filter = %s\n", GTEST_NAME_, filter);
} }
const char* const param_filter = GTEST_FLAG(param_filter).c_str();
// Ditto.
if (!String::CStringEquals(param_filter, kUniversalFilter)) {
ColoredPrintf(COLOR_YELLOW,
"Note: %s parameter filter = %s\n", GTEST_NAME_, param_filter);
}
if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) { if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {
const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1); const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
ColoredPrintf(COLOR_YELLOW, ColoredPrintf(COLOR_YELLOW,
...@@ -4636,6 +4662,7 @@ void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) { ...@@ -4636,6 +4662,7 @@ void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) {
void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) { void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {
ColoredPrintf(COLOR_GREEN, "[ RUN ] "); ColoredPrintf(COLOR_GREEN, "[ RUN ] ");
PrintTestName(test_info.test_case_name(), test_info.name()); PrintTestName(test_info.test_case_name(), test_info.name());
PrintFullTestCommentIfPresent(test_info);
printf("\n"); printf("\n");
fflush(stdout); fflush(stdout);
} }
...@@ -5961,13 +5988,13 @@ UnitTest* UnitTest::GetInstance() { ...@@ -5961,13 +5988,13 @@ UnitTest* UnitTest::GetInstance() {
// default implementation. Use this implementation to keep good OO // default implementation. Use this implementation to keep good OO
// design with private destructor. // design with private destructor.
#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) #if (defined(_MSC_VER) && _MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
static UnitTest* const instance = new UnitTest; static UnitTest* const instance = new UnitTest;
return instance; return instance;
#else #else
static UnitTest instance; static UnitTest instance;
return &instance; return &instance;
#endif // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) #endif // (defined(_MSC_VER) && _MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
} }
// Gets the number of successful test cases. // Gets the number of successful test cases.
...@@ -6813,9 +6840,15 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) { ...@@ -6813,9 +6840,15 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
kDisableTestFilter); kDisableTestFilter);
test_info->is_disabled_ = is_disabled; test_info->is_disabled_ = is_disabled;
const std::string value_param(test_info->value_param() == NULL ?
"" : test_info->value_param());
const bool matches_filter = const bool matches_filter =
internal::UnitTestOptions::FilterMatchesTest(test_case_name, internal::UnitTestOptions::FilterMatchesTest(test_case_name,
test_name); test_name) &&
internal::UnitTestOptions::MatchesFilter(value_param,
GTEST_FLAG(param_filter).c_str());
test_info->matches_filter_ = matches_filter; test_info->matches_filter_ = matches_filter;
const bool is_runnable = const bool is_runnable =
...@@ -7189,6 +7222,12 @@ static const char kColorEncodedHelpMessage[] = ...@@ -7189,6 +7222,12 @@ static const char kColorEncodedHelpMessage[] =
" Run only the tests whose name matches one of the positive patterns but\n" " Run only the tests whose name matches one of the positive patterns but\n"
" none of the negative patterns. '?' matches any single character; '*'\n" " none of the negative patterns. '?' matches any single character; '*'\n"
" matches any substring; ':' separates two patterns.\n" " matches any substring; ':' separates two patterns.\n"
" @G--" GTEST_FLAG_PREFIX_ "param_filter=@YPOSITIVE_PATTERNS"
"[@G-@YNEGATIVE_PATTERNS]@D\n"
" Like @G--" GTEST_FLAG_PREFIX_
"filter@D, but applies to the test's parameter. If a\n"
" test is not parameterized, its parameter is considered to be the\n"
" empty string.\n"
" @G--" GTEST_FLAG_PREFIX_ "also_run_disabled_tests@D\n" " @G--" GTEST_FLAG_PREFIX_ "also_run_disabled_tests@D\n"
" Run all disabled tests too.\n" " Run all disabled tests too.\n"
"\n" "\n"
...@@ -7254,6 +7293,7 @@ static bool ParseGoogleTestFlag(const char* const arg) { ...@@ -7254,6 +7293,7 @@ static bool ParseGoogleTestFlag(const char* const arg) {
ParseBoolFlag(arg, kDeathTestUseFork, ParseBoolFlag(arg, kDeathTestUseFork,
&GTEST_FLAG(death_test_use_fork)) || &GTEST_FLAG(death_test_use_fork)) ||
ParseStringFlag(arg, kFilterFlag, &GTEST_FLAG(filter)) || ParseStringFlag(arg, kFilterFlag, &GTEST_FLAG(filter)) ||
ParseStringFlag(arg, kParamFilterFlag, &GTEST_FLAG(param_filter)) ||
ParseStringFlag(arg, kInternalRunDeathTestFlag, ParseStringFlag(arg, kInternalRunDeathTestFlag,
&GTEST_FLAG(internal_run_death_test)) || &GTEST_FLAG(internal_run_death_test)) ||
ParseBoolFlag(arg, kListTestsFlag, &GTEST_FLAG(list_tests)) || ParseBoolFlag(arg, kListTestsFlag, &GTEST_FLAG(list_tests)) ||
...@@ -9096,6 +9136,7 @@ namespace internal { ...@@ -9096,6 +9136,7 @@ namespace internal {
// of them. // of them.
const char kPathSeparator = '\\'; const char kPathSeparator = '\\';
const char kAlternatePathSeparator = '/'; const char kAlternatePathSeparator = '/';
//const char kPathSeparatorString[] = "\\";
const char kAlternatePathSeparatorString[] = "/"; const char kAlternatePathSeparatorString[] = "/";
# if GTEST_OS_WINDOWS_MOBILE # if GTEST_OS_WINDOWS_MOBILE
// Windows CE doesn't have a current directory. You should not use // Windows CE doesn't have a current directory. You should not use
...@@ -9109,6 +9150,7 @@ const char kCurrentDirectoryString[] = ".\\"; ...@@ -9109,6 +9150,7 @@ const char kCurrentDirectoryString[] = ".\\";
# endif // GTEST_OS_WINDOWS_MOBILE # endif // GTEST_OS_WINDOWS_MOBILE
#else #else
const char kPathSeparator = '/'; const char kPathSeparator = '/';
//const char kPathSeparatorString[] = "/";
const char kCurrentDirectoryString[] = "./"; const char kCurrentDirectoryString[] = "./";
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
...@@ -11390,5 +11432,7 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames( ...@@ -11390,5 +11432,7 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames(
#endif // GTEST_HAS_TYPED_TEST_P #endif // GTEST_HAS_TYPED_TEST_P
void* g_parameter_ = NULL;
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment