From 5905ba00fe78e522f7253e837ded3ddb5b946934 Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Wed, 24 Feb 2010 17:21:37 +0000 Subject: [PATCH] Adds threading support (by Vlad Losev); updates the version number (by Zhanyong Wan); adds release notes for 1.5.0 (by Vlad Losev). --- CHANGES | 24 ++++++++++++++++++++++++ Makefile.am | 8 ++++++++ configure.ac | 25 +++++++++++++++++++++++-- include/gmock/gmock-spec-builders.h | 2 +- src/gmock-internal-utils.cc | 2 +- src/gmock-spec-builders.cc | 2 +- 6 files changed, 58 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index f703ac2e..16fc85d8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,27 @@ +Changes for 1.5.0: + + * Support for use in multi-threaded tests on platforms having pthreads + (by virtue of the Google Test thread change) + * The new matcher API lets user-defined matchers generate custom + explanations more directly and efficiently. + * Better expectation failure messages. + * NotNull() and IsNull() now work with smart pointers. + * Field() and Property() now work when the matcher argument is a pointer + passed by reference. + * Regular expression matching on all platforms. + * Added GCC 4.0 support for Google Mock Doctor. + * Added gmock_all_test.cc for compiling most Google Mock tests + in a single file. + * Significantly cleaned up compiler warnings. + * Bug fixes, better test coverage, and implementation clean-ups. + + Potentially breaking changes: + + * Custom matchers defined using MatcherInterface or MakePolymorphicMatcher() + need to be updated after upgrading to Google Mock 1.5.0; matchers defined + using MATCHER or MATCHER_P* aren't affected. + * Dropped support for 'make install'. + Changes for 1.4.0 (we skipped 1.2.* and 1.3.* to match the version of Google Test): diff --git a/Makefile.am b/Makefile.am index c10d81cd..30941d4f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,5 @@ +# Automake file + # Nonstandard package files for distribution. EXTRA_DIST = @@ -16,6 +18,12 @@ DISTCLEANFILES = scripts/gmock-config # directories. AM_CPPFLAGS = $(GTEST_CPPFLAGS) -I$(srcdir)/include +# Modifies compiler and linker flags for pthreads compatibility. +if HAVE_PTHREADS + AM_CXXFLAGS = @PTHREAD_CFLAGS@ -DGTEST_HAS_PTHREAD=1 + AM_LIBS = @PTHREAD_LIBS@ +endif + # Build rules for libraries. lib_LTLIBRARIES = lib/libgmock.la lib/libgmock_main.la diff --git a/configure.ac b/configure.ac index 25ab6f36..8498a6c5 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,7 @@ +m4_include(gtest/m4/acx_pthread.m4) + AC_INIT([Google C++ Mocking Framework], - [1.4.0], + [1.5.0], [googlemock@googlegroups.com], [gmock]) @@ -35,6 +37,25 @@ AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != ":"]) # TODO(chandlerc@google.com) Check for the necessary system headers. +# Configure pthreads. +AC_ARG_WITH([pthreads], + [AS_HELP_STRING([--with-pthreads], + [use pthreads (default is yes)])], + [with_pthreads=$withval], + [with_pthreads=check]) + +have_pthreads=no +AS_IF([test "x$with_pthreads" != "xno"], + [ACX_PTHREAD( + [], + [AS_IF([test "x$with_pthreads" != "xcheck"], + [AC_MSG_FAILURE( + [--with-pthreads was specified, but unable to be used])])]) + have_pthreads="$acx_pthread_ok"]) +AM_CONDITIONAL([HAVE_PTHREADS],[test "x$have_pthreads" == "xyes"]) +AC_SUBST(PTHREAD_CFLAGS) +AC_SUBST(PTHREAD_LIBS) + # GoogleMock currently has hard dependencies upon GoogleTest above and beyond # running its own test suite, so we both provide our own version in # a subdirectory and provide some logic to use a custom version or a system @@ -80,7 +101,7 @@ AC_ARG_VAR([GTEST_VERSION], [The version of Google Test available.]) HAVE_BUILT_GTEST="no" -GTEST_MIN_VERSION="1.4.0" +GTEST_MIN_VERSION="1.5.0" AS_IF([test "x${enable_external_gtest}" = "xyes"], [# Begin filling in variables as we are able. diff --git a/include/gmock/gmock-spec-builders.h b/include/gmock/gmock-spec-builders.h index d8d4749a..9b60f692 100644 --- a/include/gmock/gmock-spec-builders.h +++ b/include/gmock/gmock-spec-builders.h @@ -112,7 +112,7 @@ template class FunctionMockerBase; // expectations when InSequence() is used, and thus affect which // expectation gets picked. Therefore, we sequence all mock function // calls to ensure the integrity of the mock objects' states. -extern Mutex g_gmock_mutex; +GTEST_DECLARE_STATIC_MUTEX_(g_gmock_mutex); // Abstract base class of FunctionMockerBase. This is the // type-agnostic part of the function mocker interface. Its pure diff --git a/src/gmock-internal-utils.cc b/src/gmock-internal-utils.cc index 4c51ec00..cc51836b 100644 --- a/src/gmock-internal-utils.cc +++ b/src/gmock-internal-utils.cc @@ -103,7 +103,7 @@ FailureReporterInterface* GetFailureReporter() { } // Protects global resources (stdout in particular) used by Log(). -static Mutex g_log_mutex(Mutex::NO_CONSTRUCTOR_NEEDED_FOR_STATIC_MUTEX); +static GTEST_DEFINE_STATIC_MUTEX_(g_log_mutex); // Returns true iff a log with the given severity is visible according // to the --gmock_verbose flag. diff --git a/src/gmock-spec-builders.cc b/src/gmock-spec-builders.cc index 02a3227f..dab1a2c9 100644 --- a/src/gmock-spec-builders.cc +++ b/src/gmock-spec-builders.cc @@ -53,7 +53,7 @@ namespace internal { // Protects the mock object registry (in class Mock), all function // mockers, and all expectations. -Mutex g_gmock_mutex(Mutex::NO_CONSTRUCTOR_NEEDED_FOR_STATIC_MUTEX); +GTEST_DEFINE_STATIC_MUTEX_(g_gmock_mutex); // Constructs an ExpectationBase object. ExpectationBase::ExpectationBase(const char* a_file,