diff --git a/googlemock/include/gmock/internal/custom/gmock-generated-actions.h b/googlemock/include/gmock/internal/custom/gmock-generated-actions.h index c655fd0103..bd88c6edd6 100644 --- a/googlemock/include/gmock/internal/custom/gmock-generated-actions.h +++ b/googlemock/include/gmock/internal/custom/gmock-generated-actions.h @@ -1,149 +1,6 @@ // GOOGLETEST_CM0002 DO NOT DELETE + #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ #define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ -#include "gmock/internal/gmock-port.h" -#if GTEST_GOOGLE3_MODE_ - -#include -#include - -#include "base/callback.h" -#include "gmock/gmock-actions.h" - -namespace testing { -namespace internal { - -// Implements the Invoke(callback) action. -template -class InvokeCallbackAction; - -template -class InvokeCallbackAction { - public: - // The c'tor takes ownership of the callback. - explicit InvokeCallbackAction(CallbackType* callback) : callback_(callback) { - callback->CheckIsRepeatable(); // Makes sure the callback is permanent. - } - - R operator()(Args... args) const { - return callback_->Run(std::forward(args)...); - } - - private: - const std::shared_ptr callback_; -}; - -// Implements the InvokeWithoutArgs(callback) action. -template -class InvokeCallbackWithoutArgsAction { - const std::shared_ptr callback_; - - public: - // The c'tor takes ownership of the callback. - explicit InvokeCallbackWithoutArgsAction(CallbackType* callback) - : callback_(callback) { - callback->CheckIsRepeatable(); // Makes sure the callback is permanent. - } - - template - auto operator()(const Args&...) -> decltype(this->callback_->Run()) { - return callback_->Run(); - } -}; - -template -struct TypeIdentity { - using type = T; -}; - -inline TypeIdentity CallbackSignatureImpl(Closure*); -template -TypeIdentity CallbackSignatureImpl(ResultCallback*); - -template -TypeIdentity CallbackSignatureImpl(Callback1*); -template -TypeIdentity CallbackSignatureImpl(ResultCallback1*); - -template -TypeIdentity CallbackSignatureImpl(Callback2*); -template -TypeIdentity CallbackSignatureImpl(ResultCallback2*); - -template -TypeIdentity CallbackSignatureImpl(Callback3*); -template -TypeIdentity CallbackSignatureImpl(ResultCallback3*); - -template -TypeIdentity CallbackSignatureImpl(Callback4*); -template -TypeIdentity CallbackSignatureImpl(ResultCallback4*); - -template -TypeIdentity CallbackSignatureImpl(Callback5*); -template -TypeIdentity CallbackSignatureImpl(ResultCallback5*); - -template -using CallbackSignature = typename decltype( - internal::CallbackSignatureImpl(std::declval()))::type; - -// Specialization for protocol buffers. -// We support setting a proto2::Message, which doesn't have an assignment -// operator. -template -struct SetArgumentPointeeAction< - N, A, - typename std::enable_if::value>::type> { - A value; - - template - void operator()(const Args&... args) const { - ::std::get(std::tie(args...))->CopyFrom(value); - } -}; - -// Add Invoke overloads for google3 Callback types. - -template > -auto InvokeArgument(C* cb, Args... args) -> decltype(cb->Run(args...)) { - return cb->Run(args...); -} - -} // namespace internal - -// Add Invoke overloads for google3 Callback types. - -// Creates an action that invokes the given callback with the mock -// function's arguments. The action takes ownership of the callback -// and verifies that it's permanent. -// -// google3 doesn't support callbacks with more than 5 -// arguments yet, so we only support invoking callbacks with up to -// 5 arguments. - -template -internal::InvokeCallbackAction> -Invoke(Callback* callback) { - return internal::InvokeCallbackAction>( - callback); -} - -// Creates an action that invokes the given callback with no argument. -// The action takes ownership of the callback and verifies that it's -// permanent. -template > -internal::InvokeCallbackWithoutArgsAction InvokeWithoutArgs( - Callback* callback) { - return internal::InvokeCallbackWithoutArgsAction(callback); -} - -} // namespace testing - -#endif // GTEST_GOOGLE3_MODE_ - #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ diff --git a/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump b/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump deleted file mode 100644 index 67c221f14c..0000000000 --- a/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump +++ /dev/null @@ -1,12 +0,0 @@ -$$ -*- mode: c++; -*- -$$ This is a Pump source file. Please use Pump to convert -$$ it to callback-actions.h. -$$ -$var max_callback_arity = 5 -$$}} This meta comment fixes auto-indentation in editors. - -// GOOGLETEST_CM0002 DO NOT DELETE -#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ -#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ - -#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ diff --git a/googlemock/include/gmock/internal/custom/gmock-matchers.h b/googlemock/include/gmock/internal/custom/gmock-matchers.h index b60c6b8367..14aafaabe6 100644 --- a/googlemock/include/gmock/internal/custom/gmock-matchers.h +++ b/googlemock/include/gmock/internal/custom/gmock-matchers.h @@ -33,39 +33,4 @@ #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_ #define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_ - -#include - -#include "gmock/internal/gmock-port.h" -#if GTEST_GOOGLE3_MODE_ -#include "base/callback.h" - -// Realistically this file should be included from gmock-matchers.h -#include "gmock/gmock-matchers.h" - -namespace testing { -namespace internal { - -// Specialization for permanent callbacks. -template -struct CallableTraits*> { - typedef ResType ResultType; - using StorageType = std::shared_ptr>; - typedef ResultCallback1 Callback; - - static void CheckIsValid(const StorageType& callback) { - GTEST_CHECK_(callback != nullptr) - << "NULL callback is passed into ResultOf()."; - callback->CheckIsRepeatable(); - } - template - static ResType Invoke(const StorageType& callback, T arg) { - return callback->Run(arg); - } -}; - -} // namespace internal -} // namespace testing -#endif // GTEST_GOOGLE3_MODE_ - #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_ diff --git a/googlemock/include/gmock/internal/custom/gmock-port.h b/googlemock/include/gmock/internal/custom/gmock-port.h index a6d1fb87fb..0030fe9111 100644 --- a/googlemock/include/gmock/internal/custom/gmock-port.h +++ b/googlemock/include/gmock/internal/custom/gmock-port.h @@ -36,29 +36,4 @@ #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ #define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ -#include "gtest/internal/gtest-port.h" - -#if GTEST_GOOGLE3_MODE_ - -// Defines this iff Google Mock can use google3 callbacks. This is -// internal as a user shouldn't rely on Google Mock to tell him -// whether he can use google3 callbacks. -# include "base/callback.h" -# define GMOCK_HAS_GOOGLE3_CALLBACK_ 1 - -// Macros for declaring flags. -# define GMOCK_DECLARE_bool_(name) DECLARE_bool(gmock_##name) -# define GMOCK_DECLARE_int32_(name) DECLARE_int32(gmock_##name) -# define GMOCK_DECLARE_string_(name) DECLARE_string(gmock_##name) - -// Macros for defining flags. -# define GMOCK_DEFINE_bool_(name, default_val, doc) \ - DEFINE_bool(gmock_##name, default_val, doc) -# define GMOCK_DEFINE_int32_(name, default_val, doc) \ - DEFINE_int32(gmock_##name, default_val, doc) -# define GMOCK_DEFINE_string_(name, default_val, doc) \ - DEFINE_string(gmock_##name, default_val, doc) - -#endif // GTEST_GOOGLE3_MODE_ - #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ diff --git a/googletest/include/gtest/internal/custom/gtest-port.h b/googletest/include/gtest/internal/custom/gtest-port.h index 0973a10561..cd85d956d2 100644 --- a/googletest/include/gtest/internal/custom/gtest-port.h +++ b/googletest/include/gtest/internal/custom/gtest-port.h @@ -33,170 +33,5 @@ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ -#include "gtest/internal/gtest-port-arch.h" - -#include - -// NOTE: -// GUNIT_NO_GOOGLE3 - Only used when compiled on Linux. Define it -// to remove dependency on google3 - some features -// are unavailable in this mode. - -#define GTEST_FOR_GOOGLE_ 1 // Defined to 1 iff compiled inside Google. - -// We define these even in non-google3 mode. - -#define GTEST_FLAG(name) FLAGS_gunit_##name - -#define GTEST_DEV_EMAIL_ "opensource-gtest@@google.com" -#define GTEST_FLAG_PREFIX_ "gunit_" -#define GTEST_FLAG_PREFIX_DASH_ "gunit-" -#define GTEST_FLAG_PREFIX_UPPER_ "GUNIT_" -#define GTEST_NAME_ "Google Test" -#define GTEST_PROJECT_URL_ "http://go/gunit/" -#define GTEST_DEFAULT_DEATH_TEST_STYLE "threadsafe" - -// OS_MACOSX is defined by Blaze, when cross-compiling (on Linux) to -// Mac OS X. -// See also testing/base/public/BUILD for notes about GTEST_INTERNAL_PG3_MODE. -#if !defined(GUNIT_NO_GOOGLE3) && (GTEST_OS_CYGWIN || GTEST_OS_LINUX || \ - defined(OS_MACOSX)) -# define GTEST_GOOGLE3_MODE_ 1 -#endif - -#if GTEST_GOOGLE3_MODE_ - -#define GTEST_HAS_ABSL 1 - -#define GTEST_INIT_GOOGLE_TEST_NAME_ "InitGoogle" - -// Tell Google Test that hash_map/hash_set are available. -// Only used for testing. -#define GTEST_HAS_HASH_MAP_ 1 -#define GTEST_HAS_HASH_SET_ 1 - -// base/commandlineoptions.h has its own --flagfile flag. -# define GTEST_USE_OWN_FLAGFILE_FLAG_ 0 - -// base/commandlineflags.h provides its own GetArgvs() -# define GTEST_CUSTOM_GET_ARGVS_() ::GetArgvs() - -#include "base/callback.h" -#include "base/logging_extensions.h" -#include "base/synchronization.h" -#include "thread/thread.h" - -// Provide the PCRE regex library. -#include "util/regexp/re2/re2.h" -# define GTEST_USES_PCRE 1 -namespace testing { -namespace internal { -// This is almost 'using RE = ::RE2', except that it disambiguates -// RE::RE(std::string). It cannot be merged into the RE implementation below, -// since this version will support embedded NUL characters. -class RE { - public: - RE(absl::string_view regex) : regex_(new RE2(regex)) {} // NOLINT - RE(const char* regex) : RE(absl::string_view(regex)) {} // NOLINT - RE(const std::string& regex) : RE(absl::string_view(regex)) {} // NOLINT - RE(const RE& other) : RE(other.pattern()) {} - - // Returns the string representation of the regex. - const std::string& pattern() const { return regex_->pattern(); } - - static bool FullMatch(absl::string_view str, const RE& re) { - return RE2::FullMatch(str, *re.regex_); - } - static bool PartialMatch(absl::string_view str, const RE& re) { - return RE2::PartialMatch(str, *re.regex_); - } - - private: - std::unique_ptr regex_; -}; - -} // namespace internal -} // namespace testing - -// For flags. -# include "base/commandlineflags.h" - -#define GTEST_FLAG_SAVER_ absl::FlagSaver - -// Macros for declaring flags. -# define GTEST_DECLARE_bool_(name) DECLARE_bool(gunit_##name) -# define GTEST_DECLARE_int32_(name) DECLARE_int32(gunit_##name) -# define GTEST_DECLARE_string_(name) DECLARE_string(gunit_##name) - -// Macros for defining flags. -# define GTEST_DEFINE_bool_(name, default_val, doc) \ - DEFINE_bool(gunit_##name, default_val, doc) -# define GTEST_DEFINE_int32_(name, default_val, doc) \ - DEFINE_int32(gunit_##name, default_val, doc) -# define GTEST_DEFINE_string_(name, default_val, doc) \ - DEFINE_string(gunit_##name, default_val, doc) - -# define GTEST_GET_BOOL_FROM_ENV_(flag, default_val) \ - ::BoolFromEnv(FlagToEnvVar(flag).c_str(), default_val) -# define GTEST_GET_INT32_FROM_ENV_(flag, default_val) \ - ::Int32FromEnv(FlagToEnvVar(flag).c_str(), default_val) -# define GTEST_GET_STRING_FROM_ENV_(flag, default_val) \ - ::StringFromEnv(FlagToEnvVar(flag).c_str(), default_val) - -// For logging. -# include "third_party/absl/base/log_severity.h" -# include "base/logging.h" -# define GTEST_LOG_(severity) LOG(severity) -namespace testing { -namespace internal { -using ::LogToStderr; -inline void FlushInfoLog() { FlushLogFiles(base_logging::INFO); } -} // namespace internal -} // namespace testing - -# define GTEST_CHECK_(condition) CHECK(condition) - -// For CheckedDowncastToActualType -# include "base/casts.h" -# define GTEST_HAS_DOWNCAST_ 1 - -# define GTEST_HAS_NOTIFICATION_ 1 -#include "absl/synchronization/notification.h" -namespace testing { -namespace internal { -using ::absl::Notification; -} // namespace internal -} // namespace testing - -# define GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ 1 -# include "base/mutex.h" -# include "thread/threadlocal.h" -namespace testing { -namespace internal { -using absl::Mutex; -using absl::MutexLock; -using ::ThreadLocal; - -// Forward-declares a static mutex. -# define GTEST_DECLARE_STATIC_MUTEX_(mutex) extern absl::Mutex mutex - -// Defines and statically initializes a static mutex. -# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \ - absl::Mutex mutex(absl::kConstInit) -} // namespace internal -} // namespace testing - -// For thread annotations. -# include "third_party/absl/base/thread_annotations.h" -# define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks) \ - ABSL_EXCLUSIVE_LOCKS_REQUIRED(locks) -# define GTEST_LOCK_EXCLUDED_(locks) ABSL_LOCKS_EXCLUDED(locks) - -#endif // GTEST_GOOGLE3_MODE_ - -// Pre-r11 Android NDK releases for x86 and x86_64 do not have abi libraries. -# if GTEST_OS_LINUX_ANDROID && (defined(__i386__) || defined(__x86_64__)) -# define GTEST_HAS_CXXABI_H_ 0 -# endif #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ diff --git a/googletest/include/gtest/internal/custom/gtest-printers.h b/googletest/include/gtest/internal/custom/gtest-printers.h index 669e48455a..eb4467abca 100644 --- a/googletest/include/gtest/internal/custom/gtest-printers.h +++ b/googletest/include/gtest/internal/custom/gtest-printers.h @@ -38,83 +38,5 @@ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ -// absl:google3-begin(Custom Implementation) - -#include "gtest/gtest-printers.h" - -#if GTEST_GOOGLE3_MODE_ -#include "absl/status/statusor.h" -#include "absl/strings/cord.h" -#include "util/task/codes.pb.h" -#include "util/task/codes.proto.h" -#include "util/task/status.h" - -namespace testing { -namespace internal { - -// Specializations for types related to util::Status. We define these -// printers here to avoid widening the //util/task API. - -template <> -class UniversalPrinter< ::util::ErrorSpace> { - public: - static void Print(const ::util::ErrorSpace& space, ::std::ostream* os) { - *os << space.SpaceName(); - } -}; - -template <> -class UniversalPrinter< ::util::error::Code> { - public: - static void Print(::util::error::Code code, ::std::ostream* os) { - if (::util::error::Code_IsValid(code)) { - *os << ::util::error::Code_Name(code); - } else { - *os << static_cast(code); - } - } -}; - -template -class UniversalPrinter > { - public: - static void Print(const absl::StatusOr& status_or, ::std::ostream* os) { - *os << status_or.status(); - if (status_or.ok()) { - *os << ": "; - UniversalPrint(status_or.value(), os); - } - } -}; - -class FormatForComparisonAsStringImpl { - public: - static ::std::string Format(const char* value) { - return ::testing::PrintToString(value); - } -}; - -// If a C string is compared with a absl::string_view or Cord, we know it's -// meant to point to a NUL-terminated string, and thus can print it as a string. - -template <> -class FormatForComparison - : public FormatForComparisonAsStringImpl {}; -template <> -class FormatForComparison - : public FormatForComparisonAsStringImpl {}; - -template <> -class FormatForComparison - : public FormatForComparisonAsStringImpl {}; -template <> -class FormatForComparison - : public FormatForComparisonAsStringImpl {}; - -} // namespace internal -} // namespace testing - -#endif // GTEST_GOOGLE3_MODE_ -// absl:google3-end #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ diff --git a/googletest/include/gtest/internal/custom/gtest.h b/googletest/include/gtest/internal/custom/gtest.h index 20fb7bcb24..4c8e07be23 100644 --- a/googletest/include/gtest/internal/custom/gtest.h +++ b/googletest/include/gtest/internal/custom/gtest.h @@ -34,105 +34,4 @@ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ -#include "gtest/gtest.h" -#include "third_party/googletest/googletest/src/gtest-internal-inl.h" - -#if GTEST_GOOGLE3_MODE_ - -#define GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 1 - -#include -#include - -namespace testing { -namespace internal { - -// In google3 we use ::InitGoogle instead. -#define GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_ \ - ::testing::internal::InitGoogleTestForGoogle3 -void InitGoogleTestForGoogle3(int* argc, char** argv); -void InitGoogleTestForGoogle3(int* argc, wchar_t** argv); - -#define GTEST_OS_STACK_TRACE_GETTER_ \ - ::testing::internal::Google3OsStackTraceGetter - -// Google3 implementation of the stack trace getter. -class Google3OsStackTraceGetter : public OsStackTraceGetterInterface { - public: - Google3OsStackTraceGetter() : caller_frame_(nullptr) {} - - std::string CurrentStackTrace(int max_depth, int skip_count) override - GTEST_LOCK_EXCLUDED_(mutex_); - - void UponLeavingGTest() override GTEST_LOCK_EXCLUDED_(mutex_); - - private: - Mutex mutex_; // protects all internal state - - // We save the stack frame below the frame that calls user code. - // We do this because the address of the frame immediately below - // the user code changes between the call to UponLeavingGTest() - // and any calls to CurrentStackTrace() from within the user code. - void* caller_frame_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(Google3OsStackTraceGetter); -}; - -#define GTEST_CUSTOM_TEST_EVENT_LISTENER_ \ - ::testing::internal::GoogleProcessStateListener - -// Report process state changes to Google3 base, after the unit test -// has been initialized, and before it is torn down, as well as at -// the start and end of each test case and test. -class GoogleProcessStateListener : public EmptyTestEventListener { - public: - GoogleProcessStateListener() {} - ~GoogleProcessStateListener() override; - - void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) override; - void OnEnvironmentsTearDownStart(const UnitTest& unit_test) override; - void OnTestSuiteStart(const TestSuite& test_case) override; - void OnTestSuiteEnd(const TestSuite& test_case) override; - void OnTestStart(const TestInfo& test_info) override; - void OnTestEnd(const TestInfo& test_info) override; - - private: - GTEST_DISALLOW_COPY_AND_ASSIGN_(GoogleProcessStateListener); -}; // class GoogleProcessStateListener - - -// For KilledBySignal. -bool KilledBySignalOverride(int signum, int exit_status, bool* result); - -#define GTEST_KILLED_BY_SIGNAL_OVERRIDE_ \ - ::testing::internal::KilledBySignalOverride - -// Override --debugger_command (if any) with an empty one: -// we don't want the child to have a debugger automagically attaching -// to it when it (expectedly) dies. -// Also, enable --logtostderr. -::std::vector GetGoogle3DeathTestCommandLineArgs(); - -#define GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_() \ - ::testing::internal::GetGoogle3DeathTestCommandLineArgs() - - -// For b/11021341, disable (slow) AddressToLineNumberDecorator. -void Google3DeathTestChildSetup(); - -#define GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_() \ - ::testing::internal::Google3DeathTestChildSetup() - -// returns temp directory for test in Google3 manner -std::string GetGoogle3TestTempDir(); - -// In google3 we use ::testing:GetTestTmpdir() instead. -#define GTEST_CUSTOM_TEMPDIR_FUNCTION_ \ - ::testing::internal::GetGoogle3TestTempDir - -} // namespace internal - -} // namespace testing -#endif // GTEST_GOOGLE3_MODE_ - #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_