aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-02-21 12:17:38 +0000
committerTorne (Richard Coles) <torne@google.com>2014-02-21 12:17:38 +0000
commit65df883d09205766c521f2e6c126f4070a423141 (patch)
treeb604cd1d242d6f9cd70b2640c3f7dc4ea1783bdb
parent9881c8ebdd868a15bdefc0b01aa8b819c42076ef (diff)
parent95b9854df47a9f1bdcca4e8364477972b2082dda (diff)
downloadgtest-idea133-weekly-release.tar.gz
This commit was generated by merge_to_master.py. Change-Id: Ifdd14275a751fa5fa27587c154b28a720497aec1
-rw-r--r--CHANGES27
-rw-r--r--CMakeLists.txt28
-rw-r--r--Makefile.am1
-rw-r--r--README6
-rw-r--r--cmake/internal_utils.cmake21
-rw-r--r--configure.ac4
-rw-r--r--include/gtest/gtest-printers.h124
-rw-r--r--include/gtest/gtest.h109
-rw-r--r--include/gtest/internal/gtest-internal.h13
-rw-r--r--include/gtest/internal/gtest-port.h185
-rw-r--r--include/gtest/internal/gtest-tuple.h8
-rw-r--r--include/gtest/internal/gtest-tuple.h.pump8
-rw-r--r--scripts/common.py83
-rwxr-xr-xscripts/gtest-config.in2
-rwxr-xr-xscripts/release_docs.py158
-rw-r--r--src/gtest-filepath.cc2
-rw-r--r--src/gtest-internal-inl.h18
-rw-r--r--src/gtest-printers.cc6
-rw-r--r--src/gtest.cc531
-rw-r--r--test/gtest-death-test_test.cc53
-rw-r--r--test/gtest-param-test_test.cc7
-rw-r--r--test/gtest-printers_test.cc164
-rw-r--r--test/gtest-typed-test_test.cc3
-rw-r--r--test/gtest-unittest-api_test.cc4
-rwxr-xr-xtest/gtest_break_on_failure_unittest.py24
-rwxr-xr-xtest/gtest_catch_exceptions_test.py22
-rwxr-xr-xtest/gtest_list_tests_unittest.py92
-rw-r--r--test/gtest_list_tests_unittest_.cc78
-rw-r--r--test/gtest_output_test_golden_lin.txt5
-rw-r--r--test/gtest_premature_exit_test.cc143
-rwxr-xr-xtest/gtest_test_utils.py21
-rw-r--r--test/gtest_unittest.cc248
-rwxr-xr-xtest/gtest_xml_output_unittest.py39
-rw-r--r--test/gtest_xml_output_unittest_.cc10
-rwxr-xr-xtest/gtest_xml_test_utils.py12
-rw-r--r--xcode/gtest.xcodeproj/project.pbxproj57
36 files changed, 1888 insertions, 428 deletions
diff --git a/CHANGES b/CHANGES
index 5919245..0552132 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,30 @@
+Changes for 1.7.0:
+
+* New feature: death tests are supported on OpenBSD and in iOS
+ simulator now.
+* New feature: Google Test now implements a protocol to allow
+ a test runner to detect that a test program has exited
+ prematurely and report it as a failure (before it would be
+ falsely reported as a success if the exit code is 0).
+* New feature: Test::RecordProperty() can now be used outside of the
+ lifespan of a test method, in which case it will be attributed to
+ the current test case or the test program in the XML report.
+* New feature (potentially breaking): --gtest_list_tests now prints
+ the type parameters and value parameters for each test.
+* Improvement: char pointers and char arrays are now escaped properly
+ in failure messages.
+* Improvement: failure summary in XML reports now includes file and
+ line information.
+* Improvement: the <testsuites> XML element now has a timestamp attribute.
+* Improvement: When --gtest_filter is specified, XML report now doesn't
+ contain information about tests that are filtered out.
+* Fixed the bug where long --gtest_filter flag values are truncated in
+ death tests.
+* Potentially breaking change: RUN_ALL_TESTS() is now implemented as a
+ function instead of a macro in order to work better with Clang.
+* Compatibility fixes with C++ 11 and various platforms.
+* Bug/warning fixes.
+
Changes for 1.6.0:
* New feature: ADD_FAILURE_AT() for reporting a test failure at the
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 64527f7..bd78cfe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,6 +59,16 @@ include_directories(
# Where Google Test's libraries can be found.
link_directories(${gtest_BINARY_DIR}/src)
+# Summary of tuple support for Microsoft Visual Studio:
+# Compiler version(MS) version(cmake) Support
+# ---------- ----------- -------------- -----------------------------
+# <= VS 2010 <= 10 <= 1600 Use Google Tests's own tuple.
+# VS 2012 11 1700 std::tr1::tuple + _VARIADIC_MAX=10
+# VS 2013 12 1800 std::tr1::tuple
+if (MSVC AND MSVC_VERSION EQUAL 1700)
+ add_definitions(/D _VARIADIC_MAX=10)
+endif()
+
########################################################################
#
# Defines the gtest & gtest_main libraries. User tests should link
@@ -77,7 +87,7 @@ target_link_libraries(gtest_main gtest)
#
# They are not built by default. To build them, set the
# gtest_build_samples option to ON. You can do it by running ccmake
-# or specifying the -Dbuild_gtest_samples=ON flag when running cmake.
+# or specifying the -Dgtest_build_samples=ON flag when running cmake.
if (gtest_build_samples)
cxx_executable(sample1_unittest samples gtest_main samples/sample1.cc)
@@ -124,6 +134,8 @@ if (gtest_build_tests)
test/gtest-param-test2_test.cc)
cxx_test(gtest-port_test gtest_main)
cxx_test(gtest_pred_impl_unittest gtest_main)
+ cxx_test(gtest_premature_exit_test gtest
+ test/gtest_premature_exit_test.cc)
cxx_test(gtest-printers_test gtest_main)
cxx_test(gtest_prod_test gtest_main
test/production.cc)
@@ -169,12 +181,10 @@ if (gtest_build_tests)
PROPERTIES
COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
- if (NOT MSVC OR NOT MSVC_VERSION EQUAL 1600)
- # The C++ Standard specifies tuple_element<int, class>.
- # Yet MSVC 10's <utility> declares tuple_element<size_t, class>.
- # That declaration conflicts with our own standard-conforming
- # tuple implementation. Therefore using our own tuple with
- # MSVC 10 doesn't compile.
+ if (NOT MSVC OR MSVC_VERSION LESS 1600) # 1600 is Visual Studio 2010.
+ # Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that
+ # conflict with our own definitions. Therefore using our own tuple does not
+ # work on those compilers.
cxx_library(gtest_main_use_own_tuple "${cxx_use_own_tuple}"
src/gtest-all.cc src/gtest_main.cc)
@@ -192,8 +202,8 @@ if (gtest_build_tests)
cxx_executable(gtest_break_on_failure_unittest_ test gtest)
py_test(gtest_break_on_failure_unittest)
- # MSVC 7.1 does not support STL with exceptions disabled.
- if (NOT MSVC OR MSVC_VERSION GREATER 1310)
+ # Visual Studio .NET 2003 does not support STL with exceptions disabled.
+ if (NOT MSVC OR MSVC_VERSION GREATER 1310) # 1310 is Visual Studio .NET 2003
cxx_executable_with_flags(
gtest_catch_exceptions_no_ex_test_
"${cxx_no_exception}"
diff --git a/Makefile.am b/Makefile.am
index 788c475..9c96b42 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -58,6 +58,7 @@ EXTRA_DIST += \
test/gtest-param-test_test.cc \
test/gtest-param-test_test.h \
test/gtest-port_test.cc \
+ test/gtest_premature_exit_test.cc \
test/gtest-printers_test.cc \
test/gtest-test-part_test.cc \
test/gtest-tuple_test.cc \
diff --git a/README b/README
index 26f35a8..404bf3b 100644
--- a/README
+++ b/README
@@ -72,7 +72,7 @@ Getting the Source
There are two primary ways of getting Google Test's source code: you
can download a stable source release in your preferred archive format,
-or directly check out the source from our Subversion (SVN) repositary.
+or directly check out the source from our Subversion (SVN) repository.
The SVN checkout requires a few extra steps and some extra software
packages on your system, but lets you track the latest development and
make patches much more easily, so we highly encourage it.
@@ -157,7 +157,7 @@ it.
### Using CMake ###
Google Test comes with a CMake build script (CMakeLists.txt) that can
-be used on a wide range of platforms ("C" stands for cross-platofrm.).
+be used on a wide range of platforms ("C" stands for cross-platform.).
If you don't have CMake installed already, you can download it for
free from http://www.cmake.org/.
@@ -177,7 +177,7 @@ last command with
If you are on a *nix system, you should now see a Makefile in the
current directory. Just type 'make' to build gtest.
-If you use Windows and have Vistual Studio installed, a gtest.sln file
+If you use Windows and have Visual Studio installed, a gtest.sln file
and several .vcproj files will be created. You can then build them
using Visual Studio.
diff --git a/cmake/internal_utils.cmake b/cmake/internal_utils.cmake
index 8cb2189..93e6dbb 100644
--- a/cmake/internal_utils.cmake
+++ b/cmake/internal_utils.cmake
@@ -37,7 +37,7 @@ macro(fix_default_compiler_settings_)
# We prefer more strict warning checking for building Google Test.
# Replaces /W3 with /W4 in defaults.
- string(REPLACE "/W3" "-W4" ${flag_var} "${${flag_var}}")
+ string(REPLACE "/W3" "/W4" ${flag_var} "${${flag_var}}")
endforeach()
endif()
endmacro()
@@ -55,8 +55,8 @@ macro(config_compiler_and_linker)
if (MSVC)
# Newlines inside flags variables break CMake's NMake generator.
# TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
- set(cxx_base_flags "-GS -W4 -WX -wd4127 -wd4251 -wd4275 -nologo -J -Zi")
- if (MSVC_VERSION LESS 1400)
+ set(cxx_base_flags "-GS -W4 -WX -wd4251 -wd4275 -nologo -J -Zi")
+ if (MSVC_VERSION LESS 1400) # 1400 is Visual Studio 2005
# Suppress spurious warnings MSVC 7.1 sometimes issues.
# Forcing value to bool.
set(cxx_base_flags "${cxx_base_flags} -wd4800")
@@ -66,6 +66,21 @@ macro(config_compiler_and_linker)
# Resolved overload was found by argument-dependent lookup.
set(cxx_base_flags "${cxx_base_flags} -wd4675")
endif()
+ if (MSVC_VERSION LESS 1500) # 1500 is Visual Studio 2008
+ # Conditional expression is constant.
+ # When compiling with /W4, we get several instances of C4127
+ # (Conditional expression is constant). In our code, we disable that
+ # warning on a case-by-case basis. However, on Visual Studio 2005,
+ # the warning fires on std::list. Therefore on that compiler and earlier,
+ # we disable the warning project-wide.
+ set(cxx_base_flags "${cxx_base_flags} -wd4127")
+ endif()
+ if (NOT (MSVC_VERSION LESS 1700)) # 1700 is Visual Studio 2012.
+ # Suppress "unreachable code" warning on VS 2012 and later.
+ # http://stackoverflow.com/questions/3232669 explains the issue.
+ set(cxx_base_flags "${cxx_base_flags} -wd4702")
+ endif()
+
set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
diff --git a/configure.ac b/configure.ac
index 37b298e..cc592e1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@ m4_include(m4/acx_pthread.m4)
# "[1.0.1]"). It also asumes that there won't be any closing parenthesis
# between "AC_INIT(" and the closing ")" including comments and strings.
AC_INIT([Google C++ Testing Framework],
- [1.6.0],
+ [1.7.0],
[googletestframework@googlegroups.com],
[gtest])
@@ -55,7 +55,7 @@ AS_IF([test "x$with_pthreads" != "xno"],
[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"])
+AM_CONDITIONAL([HAVE_PTHREADS],[test "x$have_pthreads" = "xyes"])
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_LIBS)
diff --git a/include/gtest/gtest-printers.h b/include/gtest/gtest-printers.h
index 0639d9f..852d44a 100644
--- a/include/gtest/gtest-printers.h
+++ b/include/gtest/gtest-printers.h
@@ -103,6 +103,10 @@
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-internal.h"
+#if GTEST_HAS_STD_TUPLE_
+# include <tuple>
+#endif
+
namespace testing {
// Definitions in the 'internal' and 'internal2' name spaces are
@@ -480,14 +484,16 @@ inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
}
#endif // GTEST_HAS_STD_WSTRING
-#if GTEST_HAS_TR1_TUPLE
-// Overload for ::std::tr1::tuple. Needed for printing function arguments,
-// which are packed as tuples.
-
+#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
// Helper function for printing a tuple. T must be instantiated with
// a tuple type.
template <typename T>
void PrintTupleTo(const T& t, ::std::ostream* os);
+#endif // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
+
+#if GTEST_HAS_TR1_TUPLE
+// Overload for ::std::tr1::tuple. Needed for printing function arguments,
+// which are packed as tuples.
// Overloaded PrintTo() for tuples of various arities. We support
// tuples of up-to 10 fields. The following implementation works
@@ -561,6 +567,13 @@ void PrintTo(
}
#endif // GTEST_HAS_TR1_TUPLE
+#if GTEST_HAS_STD_TUPLE_
+template <typename... Types>
+void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {
+ PrintTupleTo(t, os);
+}
+#endif // GTEST_HAS_STD_TUPLE_
+
// Overload for std::pair.
template <typename T1, typename T2>
void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
@@ -756,16 +769,65 @@ void UniversalPrint(const T& value, ::std::ostream* os) {
UniversalPrinter<T1>::Print(value, os);
}
-#if GTEST_HAS_TR1_TUPLE
typedef ::std::vector<string> Strings;
+// TuplePolicy<TupleT> must provide:
+// - tuple_size
+// size of tuple TupleT.
+// - get<size_t I>(const TupleT& t)
+// static function extracting element I of tuple TupleT.
+// - tuple_element<size_t I>::type
+// type of element I of tuple TupleT.
+template <typename TupleT>
+struct TuplePolicy;
+
+#if GTEST_HAS_TR1_TUPLE
+template <typename TupleT>
+struct TuplePolicy {
+ typedef TupleT Tuple;
+ static const size_t tuple_size = ::std::tr1::tuple_size<Tuple>::value;
+
+ template <size_t I>
+ struct tuple_element : ::std::tr1::tuple_element<I, Tuple> {};
+
+ template <size_t I>
+ static typename AddReference<
+ const typename ::std::tr1::tuple_element<I, Tuple>::type>::type get(
+ const Tuple& tuple) {
+ return ::std::tr1::get<I>(tuple);
+ }
+};
+template <typename TupleT>
+const size_t TuplePolicy<TupleT>::tuple_size;
+#endif // GTEST_HAS_TR1_TUPLE
+
+#if GTEST_HAS_STD_TUPLE_
+template <typename... Types>
+struct TuplePolicy< ::std::tuple<Types...> > {
+ typedef ::std::tuple<Types...> Tuple;
+ static const size_t tuple_size = ::std::tuple_size<Tuple>::value;
+
+ template <size_t I>
+ struct tuple_element : ::std::tuple_element<I, Tuple> {};
+
+ template <size_t I>
+ static const typename ::std::tuple_element<I, Tuple>::type& get(
+ const Tuple& tuple) {
+ return ::std::get<I>(tuple);
+ }
+};
+template <typename... Types>
+const size_t TuplePolicy< ::std::tuple<Types...> >::tuple_size;
+#endif // GTEST_HAS_STD_TUPLE_
+
+#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
// This helper template allows PrintTo() for tuples and
// UniversalTersePrintTupleFieldsToStrings() to be defined by
// induction on the number of tuple fields. The idea is that
// TuplePrefixPrinter<N>::PrintPrefixTo(t, os) prints the first N
// fields in tuple t, and can be defined in terms of
// TuplePrefixPrinter<N - 1>.
-
+//
// The inductive case.
template <size_t N>
struct TuplePrefixPrinter {
@@ -773,9 +835,14 @@ struct TuplePrefixPrinter {
template <typename Tuple>
static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);
- *os << ", ";
- UniversalPrinter<typename ::std::tr1::tuple_element<N - 1, Tuple>::type>
- ::Print(::std::tr1::get<N - 1>(t), os);
+ GTEST_INTENTIONAL_CONST_COND_PUSH_
+ if (N > 1) {
+ GTEST_INTENTIONAL_CONST_COND_POP_
+ *os << ", ";
+ }
+ UniversalPrinter<
+ typename TuplePolicy<Tuple>::template tuple_element<N - 1>::type>
+ ::Print(TuplePolicy<Tuple>::template get<N - 1>(t), os);
}
// Tersely prints the first N fields of a tuple to a string vector,
@@ -784,12 +851,12 @@ struct TuplePrefixPrinter {
static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);
::std::stringstream ss;
- UniversalTersePrint(::std::tr1::get<N - 1>(t), &ss);
+ UniversalTersePrint(TuplePolicy<Tuple>::template get<N - 1>(t), &ss);
strings->push_back(ss.str());
}
};
-// Base cases.
+// Base case.
template <>
struct TuplePrefixPrinter<0> {
template <typename Tuple>
@@ -798,34 +865,13 @@ struct TuplePrefixPrinter<0> {
template <typename Tuple>
static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}
};
-// We have to specialize the entire TuplePrefixPrinter<> class
-// template here, even though the definition of
-// TersePrintPrefixToStrings() is the same as the generic version, as
-// Embarcadero (formerly CodeGear, formerly Borland) C++ doesn't
-// support specializing a method template of a class template.
-template <>
-struct TuplePrefixPrinter<1> {
- template <typename Tuple>
- static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
- UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::
- Print(::std::tr1::get<0>(t), os);
- }
-
- template <typename Tuple>
- static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
- ::std::stringstream ss;
- UniversalTersePrint(::std::tr1::get<0>(t), &ss);
- strings->push_back(ss.str());
- }
-};
-// Helper function for printing a tuple. T must be instantiated with
-// a tuple type.
-template <typename T>
-void PrintTupleTo(const T& t, ::std::ostream* os) {
+// Helper function for printing a tuple.
+// Tuple must be either std::tr1::tuple or std::tuple type.
+template <typename Tuple>
+void PrintTupleTo(const Tuple& t, ::std::ostream* os) {
*os << "(";
- TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>::
- PrintPrefixTo(t, os);
+ TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::PrintPrefixTo(t, os);
*os << ")";
}
@@ -835,11 +881,11 @@ void PrintTupleTo(const T& t, ::std::ostream* os) {
template <typename Tuple>
Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
Strings result;
- TuplePrefixPrinter< ::std::tr1::tuple_size<Tuple>::value>::
+ TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::
TersePrintPrefixToStrings(value, &result);
return result;
}
-#endif // GTEST_HAS_TR1_TUPLE
+#endif // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
} // namespace internal
diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h
index 6d13ff6..6fa0a39 100644
--- a/include/gtest/gtest.h
+++ b/include/gtest/gtest.h
@@ -158,6 +158,7 @@ class StreamingListenerTest;
class TestResultAccessor;
class TestEventListenersAccessor;
class TestEventRepeater;
+class UnitTestRecordPropertyTestHelper;
class WindowsDeathTest;
class UnitTestImpl* GetUnitTestImpl();
void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
@@ -381,20 +382,21 @@ class GTEST_API_ Test {
// non-fatal) failure.
static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
- // Logs a property for the current test. Only the last value for a given
- // key is remembered.
- // These are public static so they can be called from utility functions
- // that are not members of the test fixture.
- // The arguments are const char* instead strings, as Google Test is used
- // on platforms where string doesn't compile.
- //
- // Note that a driving consideration for these RecordProperty methods
- // was to produce xml output suited to the Greenspan charting utility,
- // which at present will only chart values that fit in a 32-bit int. It
- // is the user's responsibility to restrict their values to 32-bit ints
- // if they intend them to be used with Greenspan.
- static void RecordProperty(const char* key, const char* value);
- static void RecordProperty(const char* key, int value);
+ // Logs a property for the current test, test case, or for the entire
+ // invocation of the test program when used outside of the context of a
+ // test case. Only the last value for a given key is remembered. These
+ // are public static so they can be called from utility functions that are
+ // not members of the test fixture. Calls to RecordProperty made during
+ // lifespan of the test (from the moment its constructor starts to the
+ // moment its destructor finishes) will be output in XML as attributes of
+ // the <testcase> element. Properties recorded from fixture's
+ // SetUpTestCase or TearDownTestCase are logged as attributes of the
+ // corresponding <testsuite> element. Calls to RecordProperty made in the
+ // global context (before or after invocation of RUN_ALL_TESTS and from
+ // SetUp/TearDown method of Environment objects registered with Google
+ // Test) will be output as attributes of the <testsuites> element.
+ static void RecordProperty(const std::string& key, const std::string& value);
+ static void RecordProperty(const std::string& key, int value);
protected:
// Creates a Test object.
@@ -463,7 +465,7 @@ class TestProperty {
// C'tor. TestProperty does NOT have a default constructor.
// Always use this constructor (with parameters) to create a
// TestProperty object.
- TestProperty(const char* a_key, const char* a_value) :
+ TestProperty(const std::string& a_key, const std::string& a_value) :
key_(a_key), value_(a_value) {
}
@@ -478,7 +480,7 @@ class TestProperty {
}
// Sets a new value, overriding the one supplied in the constructor.
- void SetValue(const char* new_value) {
+ void SetValue(const std::string& new_value) {
value_ = new_value;
}
@@ -537,6 +539,7 @@ class GTEST_API_ TestResult {
private:
friend class TestInfo;
+ friend class TestCase;
friend class UnitTest;
friend class internal::DefaultGlobalTestPartResultReporter;
friend class internal::ExecDeathTest;
@@ -561,13 +564,16 @@ class GTEST_API_ TestResult {
// a non-fatal failure if invalid (e.g., if it conflicts with reserved
// key names). If a property is already recorded for the same key, the
// value will be updated, rather than storing multiple values for the same
- // key.
- void RecordProperty(const TestProperty& test_property);
+ // key. xml_element specifies the element for which the property is being
+ // recorded and is used for validation.
+ void RecordProperty(const std::string& xml_element,
+ const TestProperty& test_property);
// Adds a failure if the key is a reserved attribute of Google Test
// testcase tags. Returns true if the property is valid.
// TODO(russr): Validate attribute names are legal and human readable.
- static bool ValidateTestProperty(const TestProperty& test_property);
+ static bool ValidateTestProperty(const std::string& xml_element,
+ const TestProperty& test_property);
// Adds a test part result to the list.
void AddTestPartResult(const TestPartResult& test_part_result);
@@ -640,9 +646,9 @@ class GTEST_API_ TestInfo {
return NULL;
}
- // Returns true if this test should run, that is if the test is not disabled
- // (or it is disabled but the also_run_disabled_tests flag has been specified)
- // and its full name matches the user-specified filter.
+ // Returns true if this test should run, that is if the test is not
+ // disabled (or it is disabled but the also_run_disabled_tests flag has
+ // been specified) and its full name matches the user-specified filter.
//
// Google Test allows the user to filter the tests by their full names.
// The full name of a test Bar in test case Foo is defined as
@@ -658,6 +664,14 @@ class GTEST_API_ TestInfo {
// contains the character 'A' or starts with "Foo.".
bool should_run() const { return should_run_; }
+ // Returns true iff this test will appear in the XML report.
+ bool is_reportable() const {
+ // For now, the XML report includes all tests matching the filter.
+ // In the future, we may trim tests that are excluded because of
+ // sharding.
+ return matches_filter_;
+ }
+
// Returns the result of the test.
const TestResult* result() const { return &result_; }
@@ -770,9 +784,15 @@ class GTEST_API_ TestCase {
// Gets the number of failed tests in this test case.
int failed_test_count() const;
+ // Gets the number of disabled tests that will be reported in the XML report.
+ int reportable_disabled_test_count() const;
+
// Gets the number of disabled tests in this test case.
int disabled_test_count() const;
+ // Gets the number of tests to be printed in the XML report.
+ int reportable_test_count() const;
+
// Get the number of tests in this test case that should run.
int test_to_run_count() const;
@@ -792,6 +812,10 @@ class GTEST_API_ TestCase {
// total_test_count() - 1. If i is not in that range, returns NULL.
const TestInfo* GetTestInfo(int i) const;
+ // Returns the TestResult that holds test properties recorded during
+ // execution of SetUpTestCase and TearDownTestCase.
+ const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; }
+
private:
friend class Test;
friend class internal::UnitTestImpl;
@@ -844,11 +868,22 @@ class GTEST_API_ TestCase {
return test_info->should_run() && test_info->result()->Failed();
}
+ // Returns true iff the test is disabled and will be reported in the XML
+ // report.
+ static bool TestReportableDisabled(const TestInfo* test_info) {
+ return test_info->is_reportable() && test_info->is_disabled_;
+ }
+
// Returns true iff test is disabled.
static bool TestDisabled(const TestInfo* test_info) {
return test_info->is_disabled_;
}
+ // Returns true iff this test will appear in the XML report.
+ static bool TestReportable(const TestInfo* test_info) {
+ return test_info->is_reportable();
+ }
+
// Returns true if the given test should run.
static bool ShouldRunTest(const TestInfo* test_info) {
return test_info->should_run();
@@ -880,6 +915,9 @@ class GTEST_API_ TestCase {
bool should_run_;
// Elapsed time, in milliseconds.
TimeInMillis elapsed_time_;
+ // Holds test properties recorded during execution of SetUpTestCase and
+ // TearDownTestCase.
+ TestResult ad_hoc_test_result_;
// We disallow copying TestCases.
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestCase);
@@ -1138,9 +1176,15 @@ class GTEST_API_ UnitTest {
// Gets the number of failed tests.
int failed_test_count() const;
+ // Gets the number of disabled tests that will be reported in the XML report.
+ int reportable_disabled_test_count() const;
+
// Gets the number of disabled tests.
int disabled_test_count() const;
+ // Gets the number of tests to be printed in the XML report.
+ int reportable_test_count() const;
+
// Gets the number of all tests.
int total_test_count() const;
@@ -1165,6 +1209,10 @@ class GTEST_API_ UnitTest {
// total_test_case_count() - 1. If i is not in that range, returns NULL.
const TestCase* GetTestCase(int i) const;
+ // Returns the TestResult containing information on test failures and
+ // properties logged outside of individual test cases.
+ const TestResult& ad_hoc_test_result() const;
+
// Returns the list of event listeners that can be used to track events
// inside Google Test.
TestEventListeners& listeners();
@@ -1192,9 +1240,12 @@ class GTEST_API_ UnitTest {
const std::string& os_stack_trace)
GTEST_LOCK_EXCLUDED_(mutex_);
- // Adds a TestProperty to the current TestResult object. If the result already
- // contains a property with the same key, the value will be updated.
- void RecordPropertyForCurrentTest(const char* key, const char* value);
+ // Adds a TestProperty to the current TestResult object when invoked from
+ // inside a test, to current TestCase's ad_hoc_test_result_ when invoked
+ // from SetUpTestCase or TearDownTestCase, or to the global property set
+ // when invoked elsewhere. If the result already contains a property with
+ // the same key, the value will be updated.
+ void RecordProperty(const std::string& key, const std::string& value);
// Gets the i-th test case among all the test cases. i can range from 0 to
// total_test_case_count() - 1. If i is not in that range, returns NULL.
@@ -1210,6 +1261,7 @@ class GTEST_API_ UnitTest {
friend class internal::AssertHelper;
friend class internal::ScopedTrace;
friend class internal::StreamingListenerTest;
+ friend class internal::UnitTestRecordPropertyTestHelper;
friend Environment* AddGlobalTestEnvironment(Environment* env);
friend internal::UnitTestImpl* internal::GetUnitTestImpl();
friend void internal::ReportFailureInUnknownLocation(
@@ -1755,7 +1807,12 @@ class WithParamInterface {
// references static data, to reduce the opportunity for incorrect uses
// like writing 'WithParamInterface<bool>::GetParam()' for a test that
// uses a fixture whose parameter type is int.
- const ParamType& GetParam() const { return *parameter_; }
+ const ParamType& GetParam() const {
+ GTEST_CHECK_(parameter_ != NULL)
+ << "GetParam() can only be called inside a value-parameterized test "
+ << "-- did you intend to write TEST_P instead of TEST_F?";
+ return *parameter_;
+ }
private:
// Sets parameter value. The caller is responsible for making sure the value
diff --git a/include/gtest/internal/gtest-internal.h b/include/gtest/internal/gtest-internal.h
index 1604725..f58f65f 100644
--- a/include/gtest/internal/gtest-internal.h
+++ b/include/gtest/internal/gtest-internal.h
@@ -51,6 +51,7 @@
#endif
#include <ctype.h>
+#include <float.h>
#include <string.h>
#include <iomanip>
#include <limits>
@@ -294,6 +295,9 @@ class FloatingPoint {
return ReinterpretBits(kExponentBitMask);
}
+ // Returns the maximum representable finite floating-point number.
+ static RawType Max();
+
// Non-static methods
// Returns the bits that represents this number.
@@ -374,6 +378,13 @@ class FloatingPoint {
FloatingPointUnion u_;
};
+// We cannot use std::numeric_limits<T>::max() as it clashes with the max()
+// macro defined by <windows.h>.
+template <>
+inline float FloatingPoint<float>::Max() { return FLT_MAX; }
+template <>
+inline double FloatingPoint<double>::Max() { return DBL_MAX; }
+
// Typedefs the instances of the FloatingPoint template class that we
// care to use.
typedef FloatingPoint<float> Float;
@@ -773,7 +784,7 @@ class ImplicitlyConvertible {
// MakeFrom() is an expression whose type is From. We cannot simply
// use From(), as the type From may not have a public default
// constructor.
- static From MakeFrom();
+ static typename AddReference<From>::type MakeFrom();
// These two functions are overloaded. Given an expression
// Helper(x), the compiler will pick the first version if x can be
diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h
index dc4fe0c..a117676 100644
--- a/include/gtest/internal/gtest-port.h
+++ b/include/gtest/internal/gtest-port.h
@@ -30,8 +30,11 @@
// Authors: wan@google.com (Zhanyong Wan)
//
// Low-level types and utilities for porting Google Test to various
-// platforms. They are subject to change without notice. DO NOT USE
-// THEM IN USER CODE.
+// platforms. All macros ending with _ and symbols defined in an
+// internal namespace are subject to change without notice. Code
+// outside Google Test MUST NOT USE THEM DIRECTLY. Macros that don't
+// end with _ are part of Google Test's public API and can be used by
+// code outside Google Test.
//
// This file is fundamental to Google Test. All other Google Test source
// files are expected to #include this. Therefore, it cannot #include
@@ -40,9 +43,30 @@
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
-// The user can define the following macros in the build script to
-// control Google Test's behavior. If the user doesn't define a macro
-// in this list, Google Test will define it.
+// Environment-describing macros
+// -----------------------------
+//
+// Google Test can be used in many different environments. Macros in
+// this section tell Google Test what kind of environment it is being
+// used in, such that Google Test can provide environment-specific
+// features and implementations.
+//
+// Google Test tries to automatically detect the properties of its
+// environment, so users usually don't need to worry about these
+// macros. However, the automatic detection is not perfect.
+// Sometimes it's necessary for a user to define some of the following
+// macros in the build script to override Google Test's decisions.
+//
+// If the user doesn't define a macro in the list, Google Test will
+// provide a default definition. After this header is #included, all
+// macros in this list will be defined to either 1 or 0.
+//
+// Notes to maintainers:
+// - Each macro here is a user-tweakable knob; do not grow the list
+// lightly.
+// - Use #if to key off these macros. Don't use #ifdef or "#if
+// defined(...)", which will not work as these macros are ALWAYS
+// defined.
//
// GTEST_HAS_CLONE - Define it to 1/0 to indicate that clone(2)
// is/isn't available.
@@ -86,10 +110,15 @@
// - Define to 1 when compiling Google Test itself
// as a shared library.
-// This header defines the following utilities:
+// Platform-indicating macros
+// --------------------------
+//
+// Macros indicating the platform on which Google Test is being used
+// (a macro is defined to 1 if compiled on the given platform;
+// otherwise UNDEFINED -- it's never defined to 0.). Google Test
+// defines these macros automatically. Code outside Google Test MUST
+// NOT define them.
//
-// Macros indicating the current platform (defined to 1 if compiled on
-// the given platform; otherwise undefined):
// GTEST_OS_AIX - IBM AIX
// GTEST_OS_CYGWIN - Cygwin
// GTEST_OS_HPUX - HP-UX
@@ -116,22 +145,50 @@
// googletestframework@googlegroups.com (patches for fixing them are
// even more welcome!).
//
-// Note that it is possible that none of the GTEST_OS_* macros are defined.
+// It is possible that none of the GTEST_OS_* macros are defined.
+
+// Feature-indicating macros
+// -------------------------
+//
+// Macros indicating which Google Test features are available (a macro
+// is defined to 1 if the corresponding feature is supported;
+// otherwise UNDEFINED -- it's never defined to 0.). Google Test
+// defines these macros automatically. Code outside Google Test MUST
+// NOT define them.
+//
+// These macros are public so that portable tests can be written.
+// Such tests typically surround code using a feature with an #if
+// which controls that code. For example:
+//
+// #if GTEST_HAS_DEATH_TEST
+// EXPECT_DEATH(DoSomethingDeadly());
+// #endif
//
-// Macros indicating available Google Test features (defined to 1 if
-// the corresponding feature is supported; otherwise undefined):
// GTEST_HAS_COMBINE - the Combine() function (for value-parameterized
// tests)
// GTEST_HAS_DEATH_TEST - death tests
// GTEST_HAS_PARAM_TEST - value-parameterized tests
// GTEST_HAS_TYPED_TEST - typed tests
// GTEST_HAS_TYPED_TEST_P - type-parameterized tests
+// GTEST_IS_THREADSAFE - Google Test is thread-safe.
// GTEST_USES_POSIX_RE - enhanced POSIX regex is used. Do not confuse with
// GTEST_HAS_POSIX_RE (see above) which users can
// define themselves.
// GTEST_USES_SIMPLE_RE - our own simple regex is used;
// the above two are mutually exclusive.
// GTEST_CAN_COMPARE_NULL - accepts untyped NULL in EXPECT_EQ().
+
+// Misc public macros
+// ------------------
+//
+// GTEST_FLAG(flag_name) - references the variable corresponding to
+// the given Google Test flag.
+
+// Internal utilities
+// ------------------
+//
+// The following macros and utilities are for Google Test's INTERNAL
+// use only. Code outside Google Test MUST NOT USE THEM DIRECTLY.
//
// Macros for basic C++ coding:
// GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
@@ -140,13 +197,18 @@
// GTEST_DISALLOW_ASSIGN_ - disables operator=.
// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used.
+// GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is
+// suppressed (constant conditional).
+// GTEST_INTENTIONAL_CONST_COND_POP_ - finish code section where MSVC C4127
+// is suppressed.
+//
+// C++11 feature wrappers:
+//
+// GTEST_MOVE_ - portability wrapper for std::move.
//
// Synchronization:
// Mutex, MutexLock, ThreadLocal, GetThreadCount()
-// - synchronization primitives.
-// GTEST_IS_THREADSAFE - defined to 1 to indicate that the above
-// synchronization primitives have real implementations
-// and Google Test is thread-safe; or 0 otherwise.
+// - synchronization primitives.
//
// Template meta programming:
// is_pointer - as in TR1; needed on Symbian and IBM XL C/C++ only.
@@ -182,7 +244,6 @@
// BiggestInt - the biggest signed integer type.
//
// Command-line utilities:
-// GTEST_FLAG() - references a flag.
// GTEST_DECLARE_*() - declares a flag.
// GTEST_DEFINE_*() - defines a flag.
// GetInjectableArgvs() - returns the command line as a vector of strings.
@@ -211,6 +272,7 @@
#include <iostream> // NOLINT
#include <sstream> // NOLINT
#include <string> // NOLINT
+#include <utility>
#define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
#define GTEST_FLAG_PREFIX_ "gtest_"
@@ -282,6 +344,38 @@
# endif
#endif
+// C++11 specifies that <initializer_list> provides std::initializer_list. Use
+// that if gtest is used in C++11 mode and libstdc++ isn't very old (binaries
+// targeting OS X 10.6 can build with clang but need to use gcc4.2's
+// libstdc++).
+#if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325)
+# define GTEST_HAS_STD_INITIALIZER_LIST_ 1
+#endif
+
+// C++11 specifies that <tuple> provides std::tuple.
+// Some platforms still might not have it, however.
+#if GTEST_LANG_CXX11
+# define GTEST_HAS_STD_TUPLE_ 1
+# if defined(__clang__)
+// Inspired by http://clang.llvm.org/docs/LanguageExtensions.html#__has_include
+# if defined(__has_include) && !__has_include(<tuple>)
+# undef GTEST_HAS_STD_TUPLE_
+# endif
+# elif defined(_MSC_VER)
+// Inspired by boost/config/stdlib/dinkumware.hpp
+# if defined(_CPPLIB_VER) && _CPPLIB_VER < 520
+# undef GTEST_HAS_STD_TUPLE_
+# endif
+# elif defined(__GLIBCXX__)
+// Inspired by boost/config/stdlib/libstdcpp3.hpp,
+// http://gcc.gnu.org/gcc-4.2/changes.html and
+// http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch01.html#manual.intro.status.standard.200x
+# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
+# undef GTEST_HAS_STD_TUPLE_
+# endif
+# endif
+#endif
+
// Brings in definitions for functions used in the testing::internal::posix
// namespace (read, write, close, chdir, isatty, stat). We do not currently
// use them on Windows Mobile.
@@ -738,6 +832,31 @@ using ::std::tuple_size;
# define GTEST_MUST_USE_RESULT_
#endif // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC
+#if GTEST_LANG_CXX11
+# define GTEST_MOVE_(x) ::std::move(x) // NOLINT
+#else
+# define GTEST_MOVE_(x) x
+#endif
+
+// MS C++ compiler emits warning when a conditional expression is compile time
+// constant. In some contexts this warning is false positive and needs to be
+// suppressed. Use the following two macros in such cases:
+//
+// GTEST_INTENTIONAL_CONST_COND_PUSH_
+// while (true) {
+// GTEST_INTENTIONAL_CONST_COND_POP_
+// }
+#if defined(_MSC_VER)
+# define GTEST_INTENTIONAL_CONST_COND_PUSH_ \
+ __pragma(warning(push)) \
+ __pragma(warning(disable: 4127))
+# define GTEST_INTENTIONAL_CONST_COND_POP_ \
+ __pragma(warning(pop))
+#else
+# define GTEST_INTENTIONAL_CONST_COND_PUSH_
+# define GTEST_INTENTIONAL_CONST_COND_POP_
+#endif
+
// Determine whether the compiler supports Microsoft's Structured Exception
// Handling. This is supported by several Windows compilers but generally
// does not exist on any other system.
@@ -782,6 +901,31 @@ using ::std::tuple_size;
# define GTEST_HAS_CXXABI_H_ 0
#endif
+// A function level attribute to disable checking for use of uninitialized
+// memory when built with MemorySanitizer.
+#if defined(__clang__)
+# if __has_feature(memory_sanitizer)
+# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ \
+ __attribute__((no_sanitize_memory))
+# else
+# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
+# endif // __has_feature(memory_sanitizer)
+#else
+# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
+#endif // __clang__
+
+// A function level attribute to disable AddressSanitizer instrumentation.
+#if defined(__clang__)
+# if __has_feature(address_sanitizer)
+# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \
+ __attribute__((no_sanitize_address))
+# else
+# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
+# endif // __has_feature(address_sanitizer)
+#else
+# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
+#endif // __clang__
+
namespace testing {
class Message;
@@ -797,8 +941,8 @@ class Secret;
// expression is true. For example, you could use it to verify the
// size of a static array:
//
-// GTEST_COMPILE_ASSERT_(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES,
-// content_type_names_incorrect_size);
+// GTEST_COMPILE_ASSERT_(GTEST_ARRAY_SIZE_(names) == NUM_NAMES,
+// names_incorrect_size);
//
// or to make sure a struct is smaller than a certain size:
//
@@ -866,6 +1010,9 @@ struct StaticAssertTypeEqHelper;
template <typename T>
struct StaticAssertTypeEqHelper<T, T> {};
+// Evaluates to the number of elements in 'array'.
+#define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0]))
+
#if GTEST_HAS_GLOBAL_STRING
typedef ::string string;
#else
@@ -1124,7 +1271,9 @@ inline To DownCast_(From* f) { // so we only accept pointers
// for compile-time type checking, and has no overhead in an
// optimized build at run-time, as it will be optimized away
// completely.
+ GTEST_INTENTIONAL_CONST_COND_PUSH_
if (false) {
+ GTEST_INTENTIONAL_CONST_COND_POP_
const To to = NULL;
::testing::internal::ImplicitCast_<From*>(to);
}
diff --git a/include/gtest/internal/gtest-tuple.h b/include/gtest/internal/gtest-tuple.h
index 7b3dfc3..e9b4053 100644
--- a/include/gtest/internal/gtest-tuple.h
+++ b/include/gtest/internal/gtest-tuple.h
@@ -53,6 +53,14 @@
private:
#endif
+// Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that conflict
+// with our own definitions. Therefore using our own tuple does not work on
+// those compilers.
+#if defined(_MSC_VER) && _MSC_VER >= 1600 /* 1600 is Visual Studio 2010 */
+# error "gtest's tuple doesn't compile on Visual Studio 2010 or later. \
+GTEST_USE_OWN_TR1_TUPLE must be set to 0 on those compilers."
+#endif
+
// GTEST_n_TUPLE_(T) is the type of an n-tuple.
#define GTEST_0_TUPLE_(T) tuple<>
#define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \
diff --git a/include/gtest/internal/gtest-tuple.h.pump b/include/gtest/internal/gtest-tuple.h.pump
index c7d9e03..429ddfe 100644
--- a/include/gtest/internal/gtest-tuple.h.pump
+++ b/include/gtest/internal/gtest-tuple.h.pump
@@ -52,6 +52,14 @@ $$ This meta comment fixes auto-indentation in Emacs. }}
private:
#endif
+// Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that conflict
+// with our own definitions. Therefore using our own tuple does not work on
+// those compilers.
+#if defined(_MSC_VER) && _MSC_VER >= 1600 /* 1600 is Visual Studio 2010 */
+# error "gtest's tuple doesn't compile on Visual Studio 2010 or later. \
+GTEST_USE_OWN_TR1_TUPLE must be set to 0 on those compilers."
+#endif
+
$range i 0..n-1
$range j 0..n
diff --git a/scripts/common.py b/scripts/common.py
new file mode 100644
index 0000000..3c0347a
--- /dev/null
+++ b/scripts/common.py
@@ -0,0 +1,83 @@
+# Copyright 2013 Google Inc. All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""Shared utilities for writing scripts for Google Test/Mock."""
+
+__author__ = 'wan@google.com (Zhanyong Wan)'
+
+
+import os
+import re
+
+
+# Matches the line from 'svn info .' output that describes what SVN
+# path the current local directory corresponds to. For example, in
+# a googletest SVN workspace's trunk/test directory, the output will be:
+#
+# URL: https://googletest.googlecode.com/svn/trunk/test
+_SVN_INFO_URL_RE = re.compile(r'^URL: https://(\w+)\.googlecode\.com/svn(.*)')
+
+
+def GetCommandOutput(command):
+ """Runs the shell command and returns its stdout as a list of lines."""
+
+ f = os.popen(command, 'r')
+ lines = [line.strip() for line in f.readlines()]
+ f.close()
+ return lines
+
+
+def GetSvnInfo():
+ """Returns the project name and the current SVN workspace's root path."""
+
+ for line in GetCommandOutput('svn info .'):
+ m = _SVN_INFO_URL_RE.match(line)
+ if m:
+ project = m.group(1) # googletest or googlemock
+ rel_path = m.group(2)
+ root = os.path.realpath(rel_path.count('/') * '../')
+ return project, root
+
+ return None, None
+
+
+def GetSvnTrunk():
+ """Returns the current SVN workspace's trunk root path."""
+
+ _, root = GetSvnInfo()
+ return root + '/trunk' if root else None
+
+
+def IsInGTestSvn():
+ project, _ = GetSvnInfo()
+ return project == 'googletest'
+
+
+def IsInGMockSvn():
+ project, _ = GetSvnInfo()
+ return project == 'googlemock'
diff --git a/scripts/gtest-config.in b/scripts/gtest-config.in
index 9c72638..780f843 100755
--- a/scripts/gtest-config.in
+++ b/scripts/gtest-config.in
@@ -209,7 +209,7 @@ if test "${this_bindir}" = "${this_bindir%${bindir}}"; then
# The path to the script doesn't end in the bindir sequence from Autoconf,
# assume that we are in a build tree.
build_dir=`dirname ${this_bindir}`
- src_dir=`cd ${this_bindir}/@top_srcdir@; pwd -P`
+ src_dir=`cd ${this_bindir}; cd @top_srcdir@; pwd -P`
# TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we
# should work to remove it, and/or remove libtool altogether, replacing it
diff --git a/scripts/release_docs.py b/scripts/release_docs.py
new file mode 100755
index 0000000..1291347
--- /dev/null
+++ b/scripts/release_docs.py
@@ -0,0 +1,158 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 Google Inc. All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""Script for branching Google Test/Mock wiki pages for a new version.
+
+SYNOPSIS
+ release_docs.py NEW_RELEASE_VERSION
+
+ Google Test and Google Mock's external user documentation is in
+ interlinked wiki files. When we release a new version of
+ Google Test or Google Mock, we need to branch the wiki files
+ such that users of a specific version of Google Test/Mock can
+ look up documenation relevant for that version. This script
+ automates that process by:
+
+ - branching the current wiki pages (which document the
+ behavior of the SVN trunk head) to pages for the specified
+ version (e.g. branching FAQ.wiki to V2_6_FAQ.wiki when
+ NEW_RELEASE_VERSION is 2.6);
+ - updating the links in the branched files to point to the branched
+ version (e.g. a link in V2_6_FAQ.wiki that pointed to
+ Primer.wiki#Anchor will now point to V2_6_Primer.wiki#Anchor).
+
+ NOTE: NEW_RELEASE_VERSION must be a NEW version number for
+ which the wiki pages don't yet exist; otherwise you'll get SVN
+ errors like "svn: Path 'V1_7_PumpManual.wiki' is not a
+ directory" when running the script.
+
+EXAMPLE
+ $ cd PATH/TO/GTEST_SVN_WORKSPACE/trunk
+ $ scripts/release_docs.py 2.6 # create wiki pages for v2.6
+ $ svn status # verify the file list
+ $ svn diff # verify the file contents
+ $ svn commit -m "release wiki pages for v2.6"
+"""
+
+__author__ = 'wan@google.com (Zhanyong Wan)'
+
+import os
+import re
+import sys
+
+import common
+
+
+# Wiki pages that shouldn't be branched for every gtest/gmock release.
+GTEST_UNVERSIONED_WIKIS = ['DevGuide.wiki']
+GMOCK_UNVERSIONED_WIKIS = [
+ 'DesignDoc.wiki',
+ 'DevGuide.wiki',
+ 'KnownIssues.wiki'
+ ]
+
+
+def DropWikiSuffix(wiki_filename):
+ """Removes the .wiki suffix (if any) from the given filename."""
+
+ return (wiki_filename[:-len('.wiki')] if wiki_filename.endswith('.wiki')
+ else wiki_filename)
+
+
+class WikiBrancher(object):
+ """Branches ..."""
+
+ def __init__(self, dot_version):
+ self.project, svn_root_path = common.GetSvnInfo()
+ if self.project not in ('googletest', 'googlemock'):
+ sys.exit('This script must be run in a gtest or gmock SVN workspace.')
+ self.wiki_dir = svn_root_path + '/wiki'
+ # Turn '2.6' to 'V2_6_'.
+ self.version_prefix = 'V' + dot_version.replace('.', '_') + '_'
+ self.files_to_branch = self.GetFilesToBranch()
+ page_names = [DropWikiSuffix(f) for f in self.files_to_branch]
+ # A link to Foo.wiki is in one of the following forms:
+ # [Foo words]
+ # [Foo#Anchor words]
+ # [http://code.google.com/.../wiki/Foo words]
+ # [http://code.google.com/.../wiki/Foo#Anchor words]
+ # We want to replace 'Foo' with 'V2_6_Foo' in the above cases.
+ self.search_for_re = re.compile(
+ # This regex matches either
+ # [Foo
+ # or
+ # /wiki/Foo
+ # followed by a space or a #, where Foo is the name of an
+ # unversioned wiki page.
+ r'(\[|/wiki/)(%s)([ #])' % '|'.join(page_names))
+ self.replace_with = r'\1%s\2\3' % (self.version_prefix,)
+
+ def GetFilesToBranch(self):
+ """Returns a list of .wiki file names that need to be branched."""
+
+ unversioned_wikis = (GTEST_UNVERSIONED_WIKIS if self.project == 'googletest'
+ else GMOCK_UNVERSIONED_WIKIS)
+ return [f for f in os.listdir(self.wiki_dir)
+ if (f.endswith('.wiki') and
+ not re.match(r'^V\d', f) and # Excluded versioned .wiki files.
+ f not in unversioned_wikis)]
+
+ def BranchFiles(self):
+ """Branches the .wiki files needed to be branched."""
+
+ print 'Branching %d .wiki files:' % (len(self.files_to_branch),)
+ os.chdir(self.wiki_dir)
+ for f in self.files_to_branch:
+ command = 'svn cp %s %s%s' % (f, self.version_prefix, f)
+ print command
+ os.system(command)
+
+ def UpdateLinksInBranchedFiles(self):
+
+ for f in self.files_to_branch:
+ source_file = os.path.join(self.wiki_dir, f)
+ versioned_file = os.path.join(self.wiki_dir, self.version_prefix + f)
+ print 'Updating links in %s.' % (versioned_file,)
+ text = file(source_file, 'r').read()
+ new_text = self.search_for_re.sub(self.replace_with, text)
+ file(versioned_file, 'w').write(new_text)
+
+
+def main():
+ if len(sys.argv) != 2:
+ sys.exit(__doc__)
+
+ brancher = WikiBrancher(sys.argv[1])
+ brancher.BranchFiles()
+ brancher.UpdateLinksInBranchedFiles()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/src/gtest-filepath.cc b/src/gtest-filepath.cc
index 6be58b6..d221cfd 100644
--- a/src/gtest-filepath.cc
+++ b/src/gtest-filepath.cc
@@ -70,7 +70,6 @@ namespace internal {
// of them.
const char kPathSeparator = '\\';
const char kAlternatePathSeparator = '/';
-const char kPathSeparatorString[] = "\\";
const char kAlternatePathSeparatorString[] = "/";
# if GTEST_OS_WINDOWS_MOBILE
// Windows CE doesn't have a current directory. You should not use
@@ -84,7 +83,6 @@ const char kCurrentDirectoryString[] = ".\\";
# endif // GTEST_OS_WINDOWS_MOBILE
#else
const char kPathSeparator = '/';
-const char kPathSeparatorString[] = "/";
const char kCurrentDirectoryString[] = "./";
#endif // GTEST_OS_WINDOWS
diff --git a/src/gtest-internal-inl.h b/src/gtest-internal-inl.h
index d661043..35df303 100644
--- a/src/gtest-internal-inl.h
+++ b/src/gtest-internal-inl.h
@@ -348,8 +348,7 @@ class TestPropertyKeyIs {
// Constructor.
//
// TestPropertyKeyIs has NO default constructor.
- explicit TestPropertyKeyIs(const char* key)
- : key_(key) {}
+ explicit TestPropertyKeyIs(const std::string& key) : key_(key) {}
// Returns true iff the test name of test property matches on key_.
bool operator()(const TestProperty& test_property) const {
@@ -551,9 +550,15 @@ class GTEST_API_ UnitTestImpl {
// Gets the number of failed tests.
int failed_test_count() const;
+ // Gets the number of disabled tests that will be reported in the XML report.
+ int reportable_disabled_test_count() const;
+
// Gets the number of disabled tests.
int disabled_test_count() const;
+ // Gets the number of tests to be printed in the XML report.
+ int reportable_test_count() const;
+
// Gets the number of all tests.
int total_test_count() const;
@@ -712,6 +717,12 @@ class GTEST_API_ UnitTestImpl {
ad_hoc_test_result_.Clear();
}
+ // Adds a TestProperty to the current TestResult object when invoked in a
+ // context of a test or a test case, or to the global property set. If the
+ // result already contains a property with the same key, the value will be
+ // updated.
+ void RecordProperty(const TestProperty& test_property);
+
enum ReactionToSharding {
HONOR_SHARDING_PROTOCOL,
IGNORE_SHARDING_PROTOCOL
@@ -1038,8 +1049,9 @@ bool ParseNaturalNumber(const ::std::string& str, Integer* number) {
class TestResultAccessor {
public:
static void RecordProperty(TestResult* test_result,
+ const std::string& xml_element,
const TestProperty& property) {
- test_result->RecordProperty(property);
+ test_result->RecordProperty(xml_element, property);
}
static void ClearTestPartResults(TestResult* test_result) {
diff --git a/src/gtest-printers.cc b/src/gtest-printers.cc
index 75fa408..29c799a 100644
--- a/src/gtest-printers.cc
+++ b/src/gtest-printers.cc
@@ -56,6 +56,8 @@ namespace {
using ::std::ostream;
// Prints a segment of bytes in the given object.
+GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
+GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start,
size_t count, ostream* os) {
char text[5] = "";
@@ -252,6 +254,8 @@ void PrintTo(wchar_t wc, ostream* os) {
// The array starts at begin, the length is len, it may include '\0' characters
// and may not be NUL-terminated.
template <typename CharType>
+GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
+GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
static void PrintCharsAsStringTo(
const CharType* begin, size_t len, ostream* os) {
const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\"";
@@ -273,6 +277,8 @@ static void PrintCharsAsStringTo(
// Prints a (const) char/wchar_t array of 'len' elements, starting at address
// 'begin'. CharType must be either char or wchar_t.
template <typename CharType>
+GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
+GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
static void UniversalPrintCharArray(
const CharType* begin, size_t len, ostream* os) {
// The code
diff --git a/src/gtest.cc b/src/gtest.cc
index 62b6929..6de53dd 100644
--- a/src/gtest.cc
+++ b/src/gtest.cc
@@ -182,6 +182,10 @@ bool g_help_flag = false;
} // namespace internal
+static const char* GetDefaultFilter() {
+ return kUniversalFilter;
+}
+
GTEST_DEFINE_bool_(
also_run_disabled_tests,
internal::BoolFromGTestEnv("also_run_disabled_tests", false),
@@ -204,11 +208,11 @@ GTEST_DEFINE_string_(
"Whether to use colors in the output. Valid values: yes, no, "
"and auto. 'auto' means to use colors if the output is "
"being sent to a terminal and the TERM environment variable "
- "is set to xterm, xterm-color, xterm-256color, linux or cygwin.");
+ "is set to a terminal type that supports colors.");
GTEST_DEFINE_string_(
filter,
- internal::StringFromGTestEnv("filter", kUniversalFilter),
+ internal::StringFromGTestEnv("filter", GetDefaultFilter()),
"A colon-separated list of glob (not regex) patterns "
"for filtering the tests to run, optionally followed by a "
"'-' and a : separated list of negative patterns (tests to "
@@ -731,11 +735,22 @@ int UnitTestImpl::failed_test_count() const {
return SumOverTestCaseList(test_cases_, &TestCase::failed_test_count);
}
+// Gets the number of disabled tests that will be reported in the XML report.
+int UnitTestImpl::reportable_disabled_test_count() const {
+ return SumOverTestCaseList(test_cases_,
+ &TestCase::reportable_disabled_test_count);
+}
+
// Gets the number of disabled tests.
int UnitTestImpl::disabled_test_count() const {
return SumOverTestCaseList(test_cases_, &TestCase::disabled_test_count);
}
+// Gets the number of tests to be printed in the XML report.
+int UnitTestImpl::reportable_test_count() const {
+ return SumOverTestCaseList(test_cases_, &TestCase::reportable_test_count);
+}
+
// Gets the number of all tests.
int UnitTestImpl::total_test_count() const {
return SumOverTestCaseList(test_cases_, &TestCase::total_test_count);
@@ -1716,8 +1731,9 @@ void TestResult::AddTestPartResult(const TestPartResult& test_part_result) {
// Adds a test property to the list. If a property with the same key as the
// supplied property is already represented, the value of this test_property
// replaces the old value for that key.
-void TestResult::RecordProperty(const TestProperty& test_property) {
- if (!ValidateTestProperty(test_property)) {
+void TestResult::RecordProperty(const std::string& xml_element,
+ const TestProperty& test_property) {
+ if (!ValidateTestProperty(xml_element, test_property)) {
return;
}
internal::MutexLock lock(&test_properites_mutex_);
@@ -1731,21 +1747,94 @@ void TestResult::RecordProperty(const TestProperty& test_property) {
property_with_matching_key->SetValue(test_property.value());
}
-// Adds a failure if the key is a reserved attribute of Google Test
-// testcase tags. Returns true if the property is valid.
-bool TestResult::ValidateTestProperty(const TestProperty& test_property) {
- const std::string& key = test_property.key();
- if (key == "name" || key == "status" || key == "time" || key == "classname") {
- ADD_FAILURE()
- << "Reserved key used in RecordProperty(): "
- << key
- << " ('name', 'status', 'time', and 'classname' are reserved by "
- << GTEST_NAME_ << ")";
+// The list of reserved attributes used in the <testsuites> element of XML
+// output.
+static const char* const kReservedTestSuitesAttributes[] = {
+ "disabled",
+ "errors",
+ "failures",
+ "name",
+ "random_seed",
+ "tests",
+ "time",
+ "timestamp"
+};
+
+// The list of reserved attributes used in the <testsuite> element of XML
+// output.
+static const char* const kReservedTestSuiteAttributes[] = {
+ "disabled",
+ "errors",
+ "failures",
+ "name",
+ "tests",
+ "time"
+};
+
+// The list of reserved attributes used in the <testcase> element of XML output.
+static const char* const kReservedTestCaseAttributes[] = {
+ "classname",
+ "name",
+ "status",
+ "time",
+ "type_param",
+ "value_param"
+};
+
+template <int kSize>
+std::vector<std::string> ArrayAsVector(const char* const (&array)[kSize]) {
+ return std::vector<std::string>(array, array + kSize);
+}
+
+static std::vector<std::string> GetReservedAttributesForElement(
+ const std::string& xml_element) {
+ if (xml_element == "testsuites") {
+ return ArrayAsVector(kReservedTestSuitesAttributes);
+ } else if (xml_element == "testsuite") {
+ return ArrayAsVector(kReservedTestSuiteAttributes);
+ } else if (xml_element == "testcase") {
+ return ArrayAsVector(kReservedTestCaseAttributes);
+ } else {
+ GTEST_CHECK_(false) << "Unrecognized xml_element provided: " << xml_element;
+ }
+ // This code is unreachable but some compilers may not realizes that.
+ return std::vector<std::string>();
+}
+
+static std::string FormatWordList(const std::vector<std::string>& words) {
+ Message word_list;
+ for (size_t i = 0; i < words.size(); ++i) {
+ if (i > 0 && words.size() > 2) {
+ word_list << ", ";
+ }
+ if (i == words.size() - 1) {
+ word_list << "and ";
+ }
+ word_list << "'" << words[i] << "'";
+ }
+ return word_list.GetString();
+}
+
+bool ValidateTestPropertyName(const std::string& property_name,
+ const std::vector<std::string>& reserved_names) {
+ if (std::find(reserved_names.begin(), reserved_names.end(), property_name) !=
+ reserved_names.end()) {
+ ADD_FAILURE() << "Reserved key used in RecordProperty(): " << property_name
+ << " (" << FormatWordList(reserved_names)
+ << " are reserved by " << GTEST_NAME_ << ")";
return false;
}
return true;
}
+// Adds a failure if the key is a reserved attribute of the element named
+// xml_element. Returns true if the property is valid.
+bool TestResult::ValidateTestProperty(const std::string& xml_element,
+ const TestProperty& test_property) {
+ return ValidateTestPropertyName(test_property.key(),
+ GetReservedAttributesForElement(xml_element));
+}
+
// Clears the object.
void TestResult::Clear() {
test_part_results_.clear();
@@ -1821,12 +1910,12 @@ void Test::TearDown() {
}
// Allows user supplied key value pairs to be recorded for later output.
-void Test::RecordProperty(const char* key, const char* value) {
- UnitTest::GetInstance()->RecordPropertyForCurrentTest(key, value);
+void Test::RecordProperty(const std::string& key, const std::string& value) {
+ UnitTest::GetInstance()->RecordProperty(key, value);
}
// Allows user supplied key value pairs to be recorded for later output.
-void Test::RecordProperty(const char* key, int value) {
+void Test::RecordProperty(const std::string& key, int value) {
Message value_message;
value_message << value;
RecordProperty(key, value_message.GetString().c_str());
@@ -2264,10 +2353,21 @@ int TestCase::failed_test_count() const {
return CountIf(test_info_list_, TestFailed);
}
+// Gets the number of disabled tests that will be reported in the XML report.
+int TestCase::reportable_disabled_test_count() const {
+ return CountIf(test_info_list_, TestReportableDisabled);
+}
+
+// Gets the number of disabled tests in this test case.
int TestCase::disabled_test_count() const {
return CountIf(test_info_list_, TestDisabled);
}
+// Gets the number of tests to be printed in the XML report.
+int TestCase::reportable_test_count() const {
+ return CountIf(test_info_list_, TestReportable);
+}
+
// Get the number of tests in this test case that should run.
int TestCase::test_to_run_count() const {
return CountIf(test_info_list_, ShouldRunTest);
@@ -2355,6 +2455,7 @@ void TestCase::Run() {
// Clears the results of all tests in this test case.
void TestCase::ClearResult() {
+ ad_hoc_test_result_.Clear();
ForEach(test_info_list_, TestInfo::ClearTestResult);
}
@@ -2497,6 +2598,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
String::CStringEquals(term, "xterm-color") ||
String::CStringEquals(term, "xterm-256color") ||
String::CStringEquals(term, "screen") ||
+ String::CStringEquals(term, "screen-256color") ||
String::CStringEquals(term, "linux") ||
String::CStringEquals(term, "cygwin");
return stdout_is_tty && term_supports_color;
@@ -2562,6 +2664,11 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
va_end(args);
}
+// Text printed in Google Test's text output and --gunit_list_tests
+// output to label the type parameter and value parameter for a test.
+static const char kTypeParamLabel[] = "TypeParam";
+static const char kValueParamLabel[] = "GetParam()";
+
void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
const char* const type_param = test_info.type_param();
const char* const value_param = test_info.value_param();
@@ -2569,12 +2676,12 @@ void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
if (type_param != NULL || value_param != NULL) {
printf(", where ");
if (type_param != NULL) {
- printf("TypeParam = %s", type_param);
+ printf("%s = %s", kTypeParamLabel, type_param);
if (value_param != NULL)
printf(" and ");
}
if (value_param != NULL) {
- printf("GetParam() = %s", value_param);
+ printf("%s = %s", kValueParamLabel, value_param);
}
}
}
@@ -2659,7 +2766,7 @@ void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) {
if (test_case.type_param() == NULL) {
printf("\n");
} else {
- printf(", where TypeParam = %s\n", test_case.type_param());
+ printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param());
}
fflush(stdout);
}
@@ -2770,7 +2877,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
num_failures == 1 ? "TEST" : "TESTS");
}
- int num_disabled = unit_test.disabled_test_count();
+ int num_disabled = unit_test.reportable_disabled_test_count();
if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
if (!num_failures) {
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
@@ -2924,13 +3031,13 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
// is_attribute is true, the text is meant to appear as an attribute
// value, and normalizable whitespace is preserved by replacing it
// with character references.
- static std::string EscapeXml(const char* str, bool is_attribute);
+ static std::string EscapeXml(const std::string& str, bool is_attribute);
// Returns the given string with all characters invalid in XML removed.
- static string RemoveInvalidXmlCharacters(const string& str);
+ static std::string RemoveInvalidXmlCharacters(const std::string& str);
// Convenience wrapper around EscapeXml when str is an attribute value.
- static std::string EscapeXmlAttribute(const char* str) {
+ static std::string EscapeXmlAttribute(const std::string& str) {
return EscapeXml(str, true);
}
@@ -2939,6 +3046,13 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
return EscapeXml(str, false);
}
+ // Verifies that the given attribute belongs to the given element and
+ // streams the attribute as XML.
+ static void OutputXmlAttribute(std::ostream* stream,
+ const std::string& element_name,
+ const std::string& name,
+ const std::string& value);
+
// Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
static void OutputXmlCDataSection(::std::ostream* stream, const char* data);
@@ -2948,10 +3062,12 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
const TestInfo& test_info);
// Prints an XML representation of a TestCase object
- static void PrintXmlTestCase(FILE* out, const TestCase& test_case);
+ static void PrintXmlTestCase(::std::ostream* stream,
+ const TestCase& test_case);
// Prints an XML summary of unit_test to output stream out.
- static void PrintXmlUnitTest(FILE* out, const UnitTest& unit_test);
+ static void PrintXmlUnitTest(::std::ostream* stream,
+ const UnitTest& unit_test);
// Produces a string representing the test properties in a result as space
// delimited XML attributes based on the property key="value" pairs.
@@ -3002,7 +3118,9 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
fflush(stderr);
exit(EXIT_FAILURE);
}
- PrintXmlUnitTest(xmlout, unit_test);
+ std::stringstream stream;
+ PrintXmlUnitTest(&stream, unit_test);
+ fprintf(xmlout, "%s", StringStreamToString(&stream).c_str());
fclose(xmlout);
}
@@ -3019,43 +3137,42 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
// TODO(wan): It might be nice to have a minimally invasive, human-readable
// escaping scheme for invalid characters, rather than dropping them.
std::string XmlUnitTestResultPrinter::EscapeXml(
- const char* str, bool is_attribute) {
+ const std::string& str, bool is_attribute) {
Message m;
- if (str != NULL) {
- for (const char* src = str; *src; ++src) {
- switch (*src) {
- case '<':
- m << "&lt;";
- break;
- case '>':
- m << "&gt;";
- break;
- case '&':
- m << "&amp;";
- break;
- case '\'':
- if (is_attribute)
- m << "&apos;";
- else
- m << '\'';
- break;
- case '"':
- if (is_attribute)
- m << "&quot;";
+ for (size_t i = 0; i < str.size(); ++i) {
+ const char ch = str[i];
+ switch (ch) {
+ case '<':
+ m << "&lt;";
+ break;
+ case '>':
+ m << "&gt;";
+ break;
+ case '&':
+ m << "&amp;";
+ break;
+ case '\'':
+ if (is_attribute)
+ m << "&apos;";
+ else
+ m << '\'';
+ break;
+ case '"':
+ if (is_attribute)
+ m << "&quot;";
+ else
+ m << '"';
+ break;
+ default:
+ if (IsValidXmlCharacter(ch)) {
+ if (is_attribute && IsNormalizableWhitespace(ch))
+ m << "&#x" << String::FormatByte(static_cast<unsigned char>(ch))
+ << ";";
else
- m << '"';
- break;
- default:
- if (IsValidXmlCharacter(*src)) {
- if (is_attribute && IsNormalizableWhitespace(*src))
- m << "&#x" << String::FormatByte(static_cast<unsigned char>(*src))
- << ";";
- else
- m << *src;
- }
- break;
- }
+ m << ch;
+ }
+ break;
}
}
@@ -3065,10 +3182,11 @@ std::string XmlUnitTestResultPrinter::EscapeXml(
// Returns the given string with all characters invalid in XML removed.
// Currently invalid characters are dropped from the string. An
// alternative is to replace them with certain characters such as . or ?.
-string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters(const string& str) {
- string output;
+std::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters(
+ const std::string& str) {
+ std::string output;
output.reserve(str.size());
- for (string::const_iterator it = str.begin(); it != str.end(); ++it)
+ for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
if (IsValidXmlCharacter(*it))
output.push_back(*it);
@@ -3144,30 +3262,47 @@ void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
*stream << "]]>";
}
+void XmlUnitTestResultPrinter::OutputXmlAttribute(
+ std::ostream* stream,
+ const std::string& element_name,
+ const std::string& name,
+ const std::string& value) {
+ const std::vector<std::string>& allowed_names =
+ GetReservedAttributesForElement(element_name);
+
+ GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=
+ allowed_names.end())
+ << "Attribute " << name << " is not allowed for element <" << element_name
+ << ">.";
+
+ *stream << " " << name << "=\"" << EscapeXmlAttribute(value) << "\"";
+}
+
// Prints an XML representation of a TestInfo object.
// TODO(wan): There is also value in printing properties with the plain printer.
void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
const char* test_case_name,
const TestInfo& test_info) {
const TestResult& result = *test_info.result();
- *stream << " <testcase name=\""
- << EscapeXmlAttribute(test_info.name()).c_str() << "\"";
+ const std::string kTestcase = "testcase";
+
+ *stream << " <testcase";
+ OutputXmlAttribute(stream, kTestcase, "name", test_info.name());
if (test_info.value_param() != NULL) {
- *stream << " value_param=\"" << EscapeXmlAttribute(test_info.value_param())
- << "\"";
+ OutputXmlAttribute(stream, kTestcase, "value_param",
+ test_info.value_param());
}
if (test_info.type_param() != NULL) {
- *stream << " type_param=\"" << EscapeXmlAttribute(test_info.type_param())
- << "\"";
+ OutputXmlAttribute(stream, kTestcase, "type_param", test_info.type_param());
}
- *stream << " status=\""
- << (test_info.should_run() ? "run" : "notrun")
- << "\" time=\""
- << FormatTimeInMillisAsSeconds(result.elapsed_time())
- << "\" classname=\"" << EscapeXmlAttribute(test_case_name).c_str()
- << "\"" << TestPropertiesAsXmlAttributes(result).c_str();
+ OutputXmlAttribute(stream, kTestcase, "status",
+ test_info.should_run() ? "run" : "notrun");
+ OutputXmlAttribute(stream, kTestcase, "time",
+ FormatTimeInMillisAsSeconds(result.elapsed_time()));
+ OutputXmlAttribute(stream, kTestcase, "classname", test_case_name);
+ *stream << TestPropertiesAsXmlAttributes(result);
int failures = 0;
for (int i = 0; i < result.total_part_count(); ++i) {
@@ -3195,45 +3330,68 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
}
// Prints an XML representation of a TestCase object
-void XmlUnitTestResultPrinter::PrintXmlTestCase(FILE* out,
+void XmlUnitTestResultPrinter::PrintXmlTestCase(std::ostream* stream,
const TestCase& test_case) {
- fprintf(out,
- " <testsuite name=\"%s\" tests=\"%d\" failures=\"%d\" "
- "disabled=\"%d\" ",
- EscapeXmlAttribute(test_case.name()).c_str(),
- test_case.total_test_count(),
- test_case.failed_test_count(),
- test_case.disabled_test_count());
- fprintf(out,
- "errors=\"0\" time=\"%s\">\n",
- FormatTimeInMillisAsSeconds(test_case.elapsed_time()).c_str());
+ const std::string kTestsuite = "testsuite";
+ *stream << " <" << kTestsuite;
+ OutputXmlAttribute(stream, kTestsuite, "name", test_case.name());
+ OutputXmlAttribute(stream, kTestsuite, "tests",
+ StreamableToString(test_case.reportable_test_count()));
+ OutputXmlAttribute(stream, kTestsuite, "failures",
+ StreamableToString(test_case.failed_test_count()));
+ OutputXmlAttribute(
+ stream, kTestsuite, "disabled",
+ StreamableToString(test_case.reportable_disabled_test_count()));
+ OutputXmlAttribute(stream, kTestsuite, "errors", "0");
+ OutputXmlAttribute(stream, kTestsuite, "time",
+ FormatTimeInMillisAsSeconds(test_case.elapsed_time()));
+ *stream << TestPropertiesAsXmlAttributes(test_case.ad_hoc_test_result())
+ << ">\n";
+
for (int i = 0; i < test_case.total_test_count(); ++i) {
- ::std::stringstream stream;
- OutputXmlTestInfo(&stream, test_case.name(), *test_case.GetTestInfo(i));
- fprintf(out, "%s", StringStreamToString(&stream).c_str());
+ if (test_case.GetTestInfo(i)->is_reportable())
+ OutputXmlTestInfo(stream, test_case.name(), *test_case.GetTestInfo(i));
}
- fprintf(out, " </testsuite>\n");
+ *stream << " </" << kTestsuite << ">\n";
}
// Prints an XML summary of unit_test to output stream out.
-void XmlUnitTestResultPrinter::PrintXmlUnitTest(FILE* out,
+void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream,
const UnitTest& unit_test) {
- fprintf(out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- fprintf(out,
- "<testsuites tests=\"%d\" failures=\"%d\" disabled=\"%d\" "
- "errors=\"0\" timestamp=\"%s\" time=\"%s\" ",
- unit_test.total_test_count(),
- unit_test.failed_test_count(),
- unit_test.disabled_test_count(),
- FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp()).c_str(),
- FormatTimeInMillisAsSeconds(unit_test.elapsed_time()).c_str());
+ const std::string kTestsuites = "testsuites";
+
+ *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ *stream << "<" << kTestsuites;
+
+ OutputXmlAttribute(stream, kTestsuites, "tests",
+ StreamableToString(unit_test.reportable_test_count()));
+ OutputXmlAttribute(stream, kTestsuites, "failures",
+ StreamableToString(unit_test.failed_test_count()));
+ OutputXmlAttribute(
+ stream, kTestsuites, "disabled",
+ StreamableToString(unit_test.reportable_disabled_test_count()));
+ OutputXmlAttribute(stream, kTestsuites, "errors", "0");
+ OutputXmlAttribute(
+ stream, kTestsuites, "timestamp",
+ FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp()));
+ OutputXmlAttribute(stream, kTestsuites, "time",
+ FormatTimeInMillisAsSeconds(unit_test.elapsed_time()));
+
if (GTEST_FLAG(shuffle)) {
- fprintf(out, "random_seed=\"%d\" ", unit_test.random_seed());
+ OutputXmlAttribute(stream, kTestsuites, "random_seed",
+ StreamableToString(unit_test.random_seed()));
}
- fprintf(out, "name=\"AllTests\">\n");
- for (int i = 0; i < unit_test.total_test_case_count(); ++i)
- PrintXmlTestCase(out, *unit_test.GetTestCase(i));
- fprintf(out, "</testsuites>\n");
+
+ *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result());
+
+ OutputXmlAttribute(stream, kTestsuites, "name", "AllTests");
+ *stream << ">\n";
+
+ for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
+ if (unit_test.GetTestCase(i)->reportable_test_count() > 0)
+ PrintXmlTestCase(stream, *unit_test.GetTestCase(i));
+ }
+ *stream << "</" << kTestsuites << ">\n";
}
// Produces a string representing the test properties in a result as space
@@ -3365,6 +3523,35 @@ const char* const
OsStackTraceGetter::kElidedFramesMarker =
"... " GTEST_NAME_ " internal frames ...";
+// A helper class that creates the premature-exit file in its
+// constructor and deletes the file in its destructor.
+class ScopedPrematureExitFile {
+ public:
+ explicit ScopedPrematureExitFile(const char* premature_exit_filepath)
+ : premature_exit_filepath_(premature_exit_filepath) {
+ // If a path to the premature-exit file is specified...
+ if (premature_exit_filepath != NULL && *premature_exit_filepath != '\0') {
+ // create the file with a single "0" character in it. I/O
+ // errors are ignored as there's nothing better we can do and we
+ // don't want to fail the test because of this.
+ FILE* pfile = posix::FOpen(premature_exit_filepath, "w");
+ fwrite("0", 1, 1, pfile);
+ fclose(pfile);
+ }
+ }
+
+ ~ScopedPrematureExitFile() {
+ if (premature_exit_filepath_ != NULL && *premature_exit_filepath_ != '\0') {
+ remove(premature_exit_filepath_);
+ }
+ }
+
+ private:
+ const char* const premature_exit_filepath_;
+
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile);
+};
+
} // namespace internal
// class TestEventListeners
@@ -3451,7 +3638,7 @@ void TestEventListeners::SuppressEventForwarding() {
// We don't protect this under mutex_ as a user is not supposed to
// call this before main() starts, from which point on the return
// value will never change.
-UnitTest * UnitTest::GetInstance() {
+UnitTest* UnitTest::GetInstance() {
// When compiled with MSVC 7.1 in optimized mode, destroying the
// UnitTest object upon exiting the program messes up the exit code,
// causing successful tests to appear failed. We have to use a
@@ -3501,11 +3688,21 @@ int UnitTest::successful_test_count() const {
// Gets the number of failed tests.
int UnitTest::failed_test_count() const { return impl()->failed_test_count(); }
+// Gets the number of disabled tests that will be reported in the XML report.
+int UnitTest::reportable_disabled_test_count() const {
+ return impl()->reportable_disabled_test_count();
+}
+
// Gets the number of disabled tests.
int UnitTest::disabled_test_count() const {
return impl()->disabled_test_count();
}
+// Gets the number of tests to be printed in the XML report.
+int UnitTest::reportable_test_count() const {
+ return impl()->reportable_test_count();
+}
+
// Gets the number of all tests.
int UnitTest::total_test_count() const { return impl()->total_test_count(); }
@@ -3536,6 +3733,12 @@ const TestCase* UnitTest::GetTestCase(int i) const {
return impl()->GetTestCase(i);
}
+// Returns the TestResult containing information on test failures and
+// properties logged outside of individual test cases.
+const TestResult& UnitTest::ad_hoc_test_result() const {
+ return *impl()->ad_hoc_test_result();
+}
+
// Gets the i-th test case among all the test cases. i can range from 0 to
// total_test_case_count() - 1. If i is not in that range, returns NULL.
TestCase* UnitTest::GetMutableTestCase(int i) {
@@ -3571,13 +3774,12 @@ Environment* UnitTest::AddEnvironment(Environment* env) {
// assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call
// this to report their results. The user code should use the
// assertion macros instead of calling this directly.
-GTEST_LOCK_EXCLUDED_(mutex_)
void UnitTest::AddTestPartResult(
TestPartResult::Type result_type,
const char* file_name,
int line_number,
const std::string& message,
- const std::string& os_stack_trace) {
+ const std::string& os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_) {
Message msg;
msg << message;
@@ -3634,12 +3836,14 @@ void UnitTest::AddTestPartResult(
}
}
-// Creates and adds a property to the current TestResult. If a property matching
-// the supplied value already exists, updates its value instead.
-void UnitTest::RecordPropertyForCurrentTest(const char* key,
- const char* value) {
- const TestProperty test_property(key, value);
- impl_->current_test_result()->RecordProperty(test_property);
+// Adds a TestProperty to the current TestResult object when invoked from
+// inside a test, to current TestCase's ad_hoc_test_result_ when invoked
+// from SetUpTestCase or TearDownTestCase, or to the global property set
+// when invoked elsewhere. If the result already contains a property with
+// the same key, the value will be updated.
+void UnitTest::RecordProperty(const std::string& key,
+ const std::string& value) {
+ impl_->RecordProperty(TestProperty(key, value));
}
// Runs all tests in this UnitTest object and prints the result.
@@ -3648,14 +3852,39 @@ void UnitTest::RecordPropertyForCurrentTest(const char* key,
// We don't protect this under mutex_, as we only support calling it
// from the main thread.
int UnitTest::Run() {
+ const bool in_death_test_child_process =
+ internal::GTEST_FLAG(internal_run_death_test).length() > 0;
+
+ // Google Test implements this protocol for catching that a test
+ // program exits before returning control to Google Test:
+ //
+ // 1. Upon start, Google Test creates a file whose absolute path
+ // is specified by the environment variable
+ // TEST_PREMATURE_EXIT_FILE.
+ // 2. When Google Test has finished its work, it deletes the file.
+ //
+ // This allows a test runner to set TEST_PREMATURE_EXIT_FILE before
+ // running a Google-Test-based test program and check the existence
+ // of the file at the end of the test execution to see if it has
+ // exited prematurely.
+
+ // If we are in the child process of a death test, don't
+ // create/delete the premature exit file, as doing so is unnecessary
+ // and will confuse the parent process. Otherwise, create/delete
+ // the file upon entering/leaving this function. If the program
+ // somehow exits before this function has a chance to return, the
+ // premature-exit file will be left undeleted, causing a test runner
+ // that understands the premature-exit-file protocol to report the
+ // test as having failed.
+ const internal::ScopedPrematureExitFile premature_exit_file(
+ in_death_test_child_process ?
+ NULL : internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE"));
+
// Captures the value of GTEST_FLAG(catch_exceptions). This value will be
// used for the duration of the program.
impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions));
#if GTEST_HAS_SEH
- const bool in_death_test_child_process =
- internal::GTEST_FLAG(internal_run_death_test).length() > 0;
-
// Either the user wants Google Test to catch exceptions thrown by the
// tests or this is executing in the context of death test child
// process. In either case the user does not want to see pop-up dialogs
@@ -3794,7 +4023,6 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent)
start_timestamp_(0),
elapsed_time_(0),
#if GTEST_HAS_DEATH_TEST
- internal_run_death_test_flag_(NULL),
death_test_factory_(new DefaultDeathTestFactory),
#endif
// Will be overridden by the flag before first use.
@@ -3812,6 +4040,28 @@ UnitTestImpl::~UnitTestImpl() {
delete os_stack_trace_getter_;
}
+// Adds a TestProperty to the current TestResult object when invoked in a
+// context of a test, to current test case's ad_hoc_test_result when invoke
+// from SetUpTestCase/TearDownTestCase, or to the global property set
+// otherwise. If the result already contains a property with the same key,
+// the value will be updated.
+void UnitTestImpl::RecordProperty(const TestProperty& test_property) {
+ std::string xml_element;
+ TestResult* test_result; // TestResult appropriate for property recording.
+
+ if (current_test_info_ != NULL) {
+ xml_element = "testcase";
+ test_result = &(current_test_info_->result_);
+ } else if (current_test_case_ != NULL) {
+ xml_element = "testsuite";
+ test_result = &(current_test_case_->ad_hoc_test_result_);
+ } else {
+ xml_element = "testsuites";
+ test_result = &ad_hoc_test_result_;
+ }
+ test_result->RecordProperty(xml_element, test_property);
+}
+
#if GTEST_HAS_DEATH_TEST
// Disables event forwarding if the control is currently in a death test
// subprocess. Must not be called before InitGoogleTest.
@@ -4255,8 +4505,33 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
return num_selected_tests;
}
+// Prints the given C-string on a single line by replacing all '\n'
+// characters with string "\\n". If the output takes more than
+// max_length characters, only prints the first max_length characters
+// and "...".
+static void PrintOnOneLine(const char* str, int max_length) {
+ if (str != NULL) {
+ for (int i = 0; *str != '\0'; ++str) {
+ if (i >= max_length) {
+ printf("...");
+ break;
+ }
+ if (*str == '\n') {
+ printf("\\n");
+ i += 2;
+ } else {
+ printf("%c", *str);
+ ++i;
+ }
+ }
+ }
+}
+
// Prints the names of the tests matching the user-specified filter flag.
void UnitTestImpl::ListTestsMatchingFilter() {
+ // Print at most this many characters for each type/value parameter.
+ const int kMaxParamLength = 250;
+
for (size_t i = 0; i < test_cases_.size(); i++) {
const TestCase* const test_case = test_cases_[i];
bool printed_test_case_name = false;
@@ -4267,9 +4542,23 @@ void UnitTestImpl::ListTestsMatchingFilter() {
if (test_info->matches_filter_) {
if (!printed_test_case_name) {
printed_test_case_name = true;
- printf("%s.\n", test_case->name());
+ printf("%s.", test_case->name());
+ if (test_case->type_param() != NULL) {
+ printf(" # %s = ", kTypeParamLabel);
+ // We print the type parameter on a single line to make
+ // the output easy to parse by a program.
+ PrintOnOneLine(test_case->type_param(), kMaxParamLength);
+ }
+ printf("\n");
+ }
+ printf(" %s", test_info->name());
+ if (test_info->value_param() != NULL) {
+ printf(" # %s = ", kValueParamLabel);
+ // We print the value parameter on a single line to make the
+ // output easy to parse by a program.
+ PrintOnOneLine(test_info->value_param(), kMaxParamLength);
}
- printf(" %s\n", test_info->name());
+ printf("\n");
}
}
}
diff --git a/test/gtest-death-test_test.cc b/test/gtest-death-test_test.cc
index e857bc8..c2d26df 100644
--- a/test/gtest-death-test_test.cc
+++ b/test/gtest-death-test_test.cc
@@ -45,7 +45,6 @@ using testing::internal::AlwaysTrue;
# else
# include <unistd.h>
# include <sys/wait.h> // For waitpid.
-# include <limits> // For std::numeric_limits.
# endif // GTEST_OS_WINDOWS
# include <limits.h>
@@ -1123,17 +1122,16 @@ TEST(AutoHandleTest, AutoHandleWorks) {
# if GTEST_OS_WINDOWS
typedef unsigned __int64 BiggestParsable;
typedef signed __int64 BiggestSignedParsable;
-const BiggestParsable kBiggestParsableMax = ULLONG_MAX;
-const BiggestSignedParsable kBiggestSignedParsableMax = LLONG_MAX;
# else
typedef unsigned long long BiggestParsable;
typedef signed long long BiggestSignedParsable;
-const BiggestParsable kBiggestParsableMax =
- ::std::numeric_limits<BiggestParsable>::max();
-const BiggestSignedParsable kBiggestSignedParsableMax =
- ::std::numeric_limits<BiggestSignedParsable>::max();
# endif // GTEST_OS_WINDOWS
+// We cannot use std::numeric_limits<T>::max() as it clashes with the
+// max() macro defined by <windows.h>.
+const BiggestParsable kBiggestParsableMax = ULLONG_MAX;
+const BiggestSignedParsable kBiggestSignedParsableMax = LLONG_MAX;
+
TEST(ParseNaturalNumberTest, RejectsInvalidFormat) {
BiggestParsable result = 0;
@@ -1289,6 +1287,27 @@ TEST(ConditionalDeathMacrosTest, AssertDeatDoesNotReturnhIfUnsupported) {
FuncWithAssert(&n);
EXPECT_EQ(1, n);
}
+
+TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInFastStyle) {
+ testing::GTEST_FLAG(death_test_style) = "fast";
+ EXPECT_FALSE(InDeathTestChild());
+ EXPECT_DEATH({
+ fprintf(stderr, InDeathTestChild() ? "Inside" : "Outside");
+ fflush(stderr);
+ _exit(1);
+ }, "Inside");
+}
+
+TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInThreadSafeStyle) {
+ testing::GTEST_FLAG(death_test_style) = "threadsafe";
+ EXPECT_FALSE(InDeathTestChild());
+ EXPECT_DEATH({
+ fprintf(stderr, InDeathTestChild() ? "Inside" : "Outside");
+ fflush(stderr);
+ _exit(1);
+ }, "Inside");
+}
+
#endif // GTEST_HAS_DEATH_TEST
// Tests that the death test macros expand to code which may or may not
@@ -1341,26 +1360,6 @@ TEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) {
#endif // _MSC_VER
}
-TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInFastStyle) {
- testing::GTEST_FLAG(death_test_style) = "fast";
- EXPECT_FALSE(InDeathTestChild());
- EXPECT_DEATH({
- fprintf(stderr, InDeathTestChild() ? "Inside" : "Outside");
- fflush(stderr);
- _exit(1);
- }, "Inside");
-}
-
-TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInThreadSafeStyle) {
- testing::GTEST_FLAG(death_test_style) = "threadsafe";
- EXPECT_FALSE(InDeathTestChild());
- EXPECT_DEATH({
- fprintf(stderr, InDeathTestChild() ? "Inside" : "Outside");
- fflush(stderr);
- _exit(1);
- }, "Inside");
-}
-
// Tests that a test case whose name ends with "DeathTest" works fine
// on Windows.
TEST(NotADeathTest, Test) {
diff --git a/test/gtest-param-test_test.cc b/test/gtest-param-test_test.cc
index 7b6f7e2..f60cb8a 100644
--- a/test/gtest-param-test_test.cc
+++ b/test/gtest-param-test_test.cc
@@ -865,6 +865,13 @@ TEST_P(ParameterizedDerivedTest, SeesSequence) {
EXPECT_EQ(GetParam(), global_count_++);
}
+class ParameterizedDeathTest : public ::testing::TestWithParam<int> { };
+
+TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
+ EXPECT_DEATH_IF_SUPPORTED(GetParam(),
+ ".* value-parameterized test .*");
+}
+
INSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5));
#endif // GTEST_HAS_PARAM_TEST
diff --git a/test/gtest-printers_test.cc b/test/gtest-printers_test.cc
index 45610f8..d34a85e 100644
--- a/test/gtest-printers_test.cc
+++ b/test/gtest-printers_test.cc
@@ -125,6 +125,7 @@ namespace foo {
class UnprintableInFoo {
public:
UnprintableInFoo() : z_(0) { memcpy(xy_, "\xEF\x12\x0\x0\x34\xAB\x0\x0", 8); }
+ double z() const { return z_; }
private:
char xy_[8];
double z_;
@@ -209,15 +210,15 @@ using ::testing::internal::UniversalTersePrintTupleFieldsToStrings;
using ::testing::internal::kReference;
using ::testing::internal::string;
-#if GTEST_HAS_TR1_TUPLE
-using ::std::tr1::make_tuple;
-using ::std::tr1::tuple;
-#endif
-
-#if _MSC_VER
-// MSVC defines the following classes in the ::stdext namespace while
-// gcc defines them in the :: namespace. Note that they are not part
-// of the C++ standard.
+// The hash_* classes are not part of the C++ standard. STLport
+// defines them in namespace std. MSVC defines them in ::stdext. GCC
+// defines them in ::.
+#ifdef _STLP_HASH_MAP // We got <hash_map> from STLport.
+using ::std::hash_map;
+using ::std::hash_set;
+using ::std::hash_multimap;
+using ::std::hash_multiset;
+#elif _MSC_VER
using ::stdext::hash_map;
using ::stdext::hash_set;
using ::stdext::hash_multimap;
@@ -409,8 +410,6 @@ TEST(PrintCStringTest, EscapesProperly) {
Print(p));
}
-
-
// MSVC compiler can be configured to define whar_t as a typedef
// of unsigned short. Defining an overload for const wchar_t* in that case
// would cause pointers to unsigned shorts be printed as wide strings,
@@ -980,46 +979,47 @@ TEST(PrintStlContainerTest, ConstIterator) {
}
#if GTEST_HAS_TR1_TUPLE
-// Tests printing tuples.
+// Tests printing ::std::tr1::tuples.
// Tuples of various arities.
-TEST(PrintTupleTest, VariousSizes) {
- tuple<> t0;
+TEST(PrintTr1TupleTest, VariousSizes) {
+ ::std::tr1::tuple<> t0;
EXPECT_EQ("()", Print(t0));
- tuple<int> t1(5);
+ ::std::tr1::tuple<int> t1(5);
EXPECT_EQ("(5)", Print(t1));
- tuple<char, bool> t2('a', true);
+ ::std::tr1::tuple<char, bool> t2('a', true);
EXPECT_EQ("('a' (97, 0x61), true)", Print(t2));
- tuple<bool, int, int> t3(false, 2, 3);
+ ::std::tr1::tuple<bool, int, int> t3(false, 2, 3);
EXPECT_EQ("(false, 2, 3)", Print(t3));
- tuple<bool, int, int, int> t4(false, 2, 3, 4);
+ ::std::tr1::tuple<bool, int, int, int> t4(false, 2, 3, 4);
EXPECT_EQ("(false, 2, 3, 4)", Print(t4));
- tuple<bool, int, int, int, bool> t5(false, 2, 3, 4, true);
+ ::std::tr1::tuple<bool, int, int, int, bool> t5(false, 2, 3, 4, true);
EXPECT_EQ("(false, 2, 3, 4, true)", Print(t5));
- tuple<bool, int, int, int, bool, int> t6(false, 2, 3, 4, true, 6);
+ ::std::tr1::tuple<bool, int, int, int, bool, int> t6(false, 2, 3, 4, true, 6);
EXPECT_EQ("(false, 2, 3, 4, true, 6)", Print(t6));
- tuple<bool, int, int, int, bool, int, int> t7(false, 2, 3, 4, true, 6, 7);
+ ::std::tr1::tuple<bool, int, int, int, bool, int, int> t7(
+ false, 2, 3, 4, true, 6, 7);
EXPECT_EQ("(false, 2, 3, 4, true, 6, 7)", Print(t7));
- tuple<bool, int, int, int, bool, int, int, bool> t8(
+ ::std::tr1::tuple<bool, int, int, int, bool, int, int, bool> t8(
false, 2, 3, 4, true, 6, 7, true);
EXPECT_EQ("(false, 2, 3, 4, true, 6, 7, true)", Print(t8));
- tuple<bool, int, int, int, bool, int, int, bool, int> t9(
+ ::std::tr1::tuple<bool, int, int, int, bool, int, int, bool, int> t9(
false, 2, 3, 4, true, 6, 7, true, 9);
EXPECT_EQ("(false, 2, 3, 4, true, 6, 7, true, 9)", Print(t9));
const char* const str = "8";
// VC++ 2010's implementation of tuple of C++0x is deficient, requiring
// an explicit type cast of NULL to be used.
- tuple<bool, char, short, testing::internal::Int32, // NOLINT
+ ::std::tr1::tuple<bool, char, short, testing::internal::Int32, // NOLINT
testing::internal::Int64, float, double, const char*, void*, string>
t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str,
ImplicitCast_<void*>(NULL), "10");
@@ -1029,13 +1029,73 @@ TEST(PrintTupleTest, VariousSizes) {
}
// Nested tuples.
-TEST(PrintTupleTest, NestedTuple) {
- tuple<tuple<int, bool>, char> nested(make_tuple(5, true), 'a');
+TEST(PrintTr1TupleTest, NestedTuple) {
+ ::std::tr1::tuple< ::std::tr1::tuple<int, bool>, char> nested(
+ ::std::tr1::make_tuple(5, true), 'a');
EXPECT_EQ("((5, true), 'a' (97, 0x61))", Print(nested));
}
#endif // GTEST_HAS_TR1_TUPLE
+#if GTEST_LANG_CXX11
+// Tests printing ::std::tuples.
+
+// Tuples of various arities.
+TEST(PrintStdTupleTest, VariousSizes) {
+ ::std::tuple<> t0;
+ EXPECT_EQ("()", Print(t0));
+
+ ::std::tuple<int> t1(5);
+ EXPECT_EQ("(5)", Print(t1));
+
+ ::std::tuple<char, bool> t2('a', true);
+ EXPECT_EQ("('a' (97, 0x61), true)", Print(t2));
+
+ ::std::tuple<bool, int, int> t3(false, 2, 3);
+ EXPECT_EQ("(false, 2, 3)", Print(t3));
+
+ ::std::tuple<bool, int, int, int> t4(false, 2, 3, 4);
+ EXPECT_EQ("(false, 2, 3, 4)", Print(t4));
+
+ ::std::tuple<bool, int, int, int, bool> t5(false, 2, 3, 4, true);
+ EXPECT_EQ("(false, 2, 3, 4, true)", Print(t5));
+
+ ::std::tuple<bool, int, int, int, bool, int> t6(false, 2, 3, 4, true, 6);
+ EXPECT_EQ("(false, 2, 3, 4, true, 6)", Print(t6));
+
+ ::std::tuple<bool, int, int, int, bool, int, int> t7(
+ false, 2, 3, 4, true, 6, 7);
+ EXPECT_EQ("(false, 2, 3, 4, true, 6, 7)", Print(t7));
+
+ ::std::tuple<bool, int, int, int, bool, int, int, bool> t8(
+ false, 2, 3, 4, true, 6, 7, true);
+ EXPECT_EQ("(false, 2, 3, 4, true, 6, 7, true)", Print(t8));
+
+ ::std::tuple<bool, int, int, int, bool, int, int, bool, int> t9(
+ false, 2, 3, 4, true, 6, 7, true, 9);
+ EXPECT_EQ("(false, 2, 3, 4, true, 6, 7, true, 9)", Print(t9));
+
+ const char* const str = "8";
+ // VC++ 2010's implementation of tuple of C++0x is deficient, requiring
+ // an explicit type cast of NULL to be used.
+ ::std::tuple<bool, char, short, testing::internal::Int32, // NOLINT
+ testing::internal::Int64, float, double, const char*, void*, string>
+ t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str,
+ ImplicitCast_<void*>(NULL), "10");
+ EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
+ " pointing to \"8\", NULL, \"10\")",
+ Print(t10));
+}
+
+// Nested tuples.
+TEST(PrintStdTupleTest, NestedTuple) {
+ ::std::tuple< ::std::tuple<int, bool>, char> nested(
+ ::std::make_tuple(5, true), 'a');
+ EXPECT_EQ("((5, true), 'a' (97, 0x61))", Print(nested));
+}
+
+#endif // GTEST_LANG_CXX11
+
// Tests printing user-defined unprintable types.
// Unprintable types in the global namespace.
@@ -1528,28 +1588,31 @@ TEST(UniversalPrintTest, WorksForCharArray) {
#if GTEST_HAS_TR1_TUPLE
-TEST(UniversalTersePrintTupleFieldsToStringsTest, PrintsEmptyTuple) {
- Strings result = UniversalTersePrintTupleFieldsToStrings(make_tuple());
+TEST(UniversalTersePrintTupleFieldsToStringsTestWithTr1, PrintsEmptyTuple) {
+ Strings result = UniversalTersePrintTupleFieldsToStrings(
+ ::std::tr1::make_tuple());
EXPECT_EQ(0u, result.size());
}
-TEST(UniversalTersePrintTupleFieldsToStringsTest, PrintsOneTuple) {
- Strings result = UniversalTersePrintTupleFieldsToStrings(make_tuple(1));
+TEST(UniversalTersePrintTupleFieldsToStringsTestWithTr1, PrintsOneTuple) {
+ Strings result = UniversalTersePrintTupleFieldsToStrings(
+ ::std::tr1::make_tuple(1));
ASSERT_EQ(1u, result.size());
EXPECT_EQ("1", result[0]);
}
-TEST(UniversalTersePrintTupleFieldsToStringsTest, PrintsTwoTuple) {
- Strings result = UniversalTersePrintTupleFieldsToStrings(make_tuple(1, 'a'));
+TEST(UniversalTersePrintTupleFieldsToStringsTestWithTr1, PrintsTwoTuple) {
+ Strings result = UniversalTersePrintTupleFieldsToStrings(
+ ::std::tr1::make_tuple(1, 'a'));
ASSERT_EQ(2u, result.size());
EXPECT_EQ("1", result[0]);
EXPECT_EQ("'a' (97, 0x61)", result[1]);
}
-TEST(UniversalTersePrintTupleFieldsToStringsTest, PrintsTersely) {
+TEST(UniversalTersePrintTupleFieldsToStringsTestWithTr1, PrintsTersely) {
const int n = 1;
Strings result = UniversalTersePrintTupleFieldsToStrings(
- tuple<const int&, const char*>(n, "a"));
+ ::std::tr1::tuple<const int&, const char*>(n, "a"));
ASSERT_EQ(2u, result.size());
EXPECT_EQ("1", result[0]);
EXPECT_EQ("\"a\"", result[1]);
@@ -1557,5 +1620,38 @@ TEST(UniversalTersePrintTupleFieldsToStringsTest, PrintsTersely) {
#endif // GTEST_HAS_TR1_TUPLE
+#if GTEST_HAS_STD_TUPLE_
+
+TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsEmptyTuple) {
+ Strings result = UniversalTersePrintTupleFieldsToStrings(::std::make_tuple());
+ EXPECT_EQ(0u, result.size());
+}
+
+TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsOneTuple) {
+ Strings result = UniversalTersePrintTupleFieldsToStrings(
+ ::std::make_tuple(1));
+ ASSERT_EQ(1u, result.size());
+ EXPECT_EQ("1", result[0]);
+}
+
+TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTwoTuple) {
+ Strings result = UniversalTersePrintTupleFieldsToStrings(
+ ::std::make_tuple(1, 'a'));
+ ASSERT_EQ(2u, result.size());
+ EXPECT_EQ("1", result[0]);
+ EXPECT_EQ("'a' (97, 0x61)", result[1]);
+}
+
+TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTersely) {
+ const int n = 1;
+ Strings result = UniversalTersePrintTupleFieldsToStrings(
+ ::std::tuple<const int&, const char*>(n, "a"));
+ ASSERT_EQ(2u, result.size());
+ EXPECT_EQ("1", result[0]);
+ EXPECT_EQ("\"a\"", result[1]);
+}
+
+#endif // GTEST_HAS_STD_TUPLE_
+
} // namespace gtest_printers_test
} // namespace testing
diff --git a/test/gtest-typed-test_test.cc b/test/gtest-typed-test_test.cc
index dd4ba43..c3e66c2 100644
--- a/test/gtest-typed-test_test.cc
+++ b/test/gtest-typed-test_test.cc
@@ -29,10 +29,11 @@
//
// Author: wan@google.com (Zhanyong Wan)
+#include "test/gtest-typed-test_test.h"
+
#include <set>
#include <vector>
-#include "test/gtest-typed-test_test.h"
#include "gtest/gtest.h"
using testing::Test;
diff --git a/test/gtest-unittest-api_test.cc b/test/gtest-unittest-api_test.cc
index 07083e5..b1f5168 100644
--- a/test/gtest-unittest-api_test.cc
+++ b/test/gtest-unittest-api_test.cc
@@ -54,7 +54,7 @@ class UnitTestHelper {
public:
// Returns the array of pointers to all test cases sorted by the test case
// name. The caller is responsible for deleting the array.
- static TestCase const** const GetSortedTestCases() {
+ static TestCase const** GetSortedTestCases() {
UnitTest& unit_test = *UnitTest::GetInstance();
TestCase const** const test_cases =
new const TestCase*[unit_test.total_test_case_count()];
@@ -83,7 +83,7 @@ class UnitTestHelper {
// Returns the array of pointers to all tests in a particular test case
// sorted by the test name. The caller is responsible for deleting the
// array.
- static TestInfo const** const GetSortedTests(const TestCase* test_case) {
+ static TestInfo const** GetSortedTests(const TestCase* test_case) {
TestInfo const** const tests =
new const TestInfo*[test_case->total_test_count()];
diff --git a/test/gtest_break_on_failure_unittest.py b/test/gtest_break_on_failure_unittest.py
index c819183..78f3e0f 100755
--- a/test/gtest_break_on_failure_unittest.py
+++ b/test/gtest_break_on_failure_unittest.py
@@ -66,21 +66,15 @@ EXE_PATH = gtest_test_utils.GetTestExecutablePath(
'gtest_break_on_failure_unittest_')
-# Utilities.
-
-
-environ = os.environ.copy()
-
-
-def SetEnvVar(env_var, value):
- """Sets an environment variable to a given value; unsets it when the
- given value is None.
- """
-
- if value is not None:
- environ[env_var] = value
- elif env_var in environ:
- del environ[env_var]
+environ = gtest_test_utils.environ
+SetEnvVar = gtest_test_utils.SetEnvVar
+
+# Tests in this file run a Google-Test-based test program and expect it
+# to terminate prematurely. Therefore they are incompatible with
+# the premature-exit-file protocol by design. Unset the
+# premature-exit filepath to prevent Google Test from creating
+# the file.
+SetEnvVar(gtest_test_utils.PREMATURE_EXIT_FILE_ENV_VAR, None)
def Run(command):
diff --git a/test/gtest_catch_exceptions_test.py b/test/gtest_catch_exceptions_test.py
index d7ef10e..e6fc22f 100755
--- a/test/gtest_catch_exceptions_test.py
+++ b/test/gtest_catch_exceptions_test.py
@@ -57,14 +57,27 @@ EX_EXE_PATH = gtest_test_utils.GetTestExecutablePath(
EXE_PATH = gtest_test_utils.GetTestExecutablePath(
'gtest_catch_exceptions_no_ex_test_')
-TEST_LIST = gtest_test_utils.Subprocess([EXE_PATH, LIST_TESTS_FLAG]).output
+environ = gtest_test_utils.environ
+SetEnvVar = gtest_test_utils.SetEnvVar
+
+# Tests in this file run a Google-Test-based test program and expect it
+# to terminate prematurely. Therefore they are incompatible with
+# the premature-exit-file protocol by design. Unset the
+# premature-exit filepath to prevent Google Test from creating
+# the file.
+SetEnvVar(gtest_test_utils.PREMATURE_EXIT_FILE_ENV_VAR, None)
+
+TEST_LIST = gtest_test_utils.Subprocess(
+ [EXE_PATH, LIST_TESTS_FLAG], env=environ).output
SUPPORTS_SEH_EXCEPTIONS = 'ThrowsSehException' in TEST_LIST
if SUPPORTS_SEH_EXCEPTIONS:
- BINARY_OUTPUT = gtest_test_utils.Subprocess([EXE_PATH]).output
+ BINARY_OUTPUT = gtest_test_utils.Subprocess([EXE_PATH], env=environ).output
+
+EX_BINARY_OUTPUT = gtest_test_utils.Subprocess(
+ [EX_EXE_PATH], env=environ).output
-EX_BINARY_OUTPUT = gtest_test_utils.Subprocess([EX_EXE_PATH]).output
# The tests.
if SUPPORTS_SEH_EXCEPTIONS:
@@ -212,7 +225,8 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
uncaught_exceptions_ex_binary_output = gtest_test_utils.Subprocess(
[EX_EXE_PATH,
NO_CATCH_EXCEPTIONS_FLAG,
- FITLER_OUT_SEH_TESTS_FLAG]).output
+ FITLER_OUT_SEH_TESTS_FLAG],
+ env=environ).output
self.assert_('Unhandled C++ exception terminating the program'
in uncaught_exceptions_ex_binary_output)
diff --git a/test/gtest_list_tests_unittest.py b/test/gtest_list_tests_unittest.py
index ce8c3ef..925b09d 100755
--- a/test/gtest_list_tests_unittest.py
+++ b/test/gtest_list_tests_unittest.py
@@ -40,6 +40,7 @@ Google Test) the command line flags.
__author__ = 'phanna@google.com (Patrick Hanna)'
import gtest_test_utils
+import re
# Constants.
@@ -52,38 +53,63 @@ EXE_PATH = gtest_test_utils.GetTestExecutablePath('gtest_list_tests_unittest_')
# The expected output when running gtest_list_tests_unittest_ with
# --gtest_list_tests
-EXPECTED_OUTPUT_NO_FILTER = """FooDeathTest.
+EXPECTED_OUTPUT_NO_FILTER_RE = re.compile(r"""FooDeathTest\.
Test1
-Foo.
+Foo\.
Bar1
Bar2
DISABLED_Bar3
-Abc.
+Abc\.
Xyz
Def
-FooBar.
+FooBar\.
Baz
-FooTest.
+FooTest\.
Test1
DISABLED_Test2
Test3
-"""
+TypedTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
+ TestA
+ TestB
+TypedTest/1\. # TypeParam = int\s*\*
+ TestA
+ TestB
+TypedTest/2\. # TypeParam = .*MyArray<bool,\s*42>
+ TestA
+ TestB
+My/TypeParamTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
+ TestA
+ TestB
+My/TypeParamTest/1\. # TypeParam = int\s*\*
+ TestA
+ TestB
+My/TypeParamTest/2\. # TypeParam = .*MyArray<bool,\s*42>
+ TestA
+ TestB
+MyInstantiation/ValueParamTest\.
+ TestA/0 # GetParam\(\) = one line
+ TestA/1 # GetParam\(\) = two\\nlines
+ TestA/2 # GetParam\(\) = a very\\nlo{241}\.\.\.
+ TestB/0 # GetParam\(\) = one line
+ TestB/1 # GetParam\(\) = two\\nlines
+ TestB/2 # GetParam\(\) = a very\\nlo{241}\.\.\.
+""")
# The expected output when running gtest_list_tests_unittest_ with
# --gtest_list_tests and --gtest_filter=Foo*.
-EXPECTED_OUTPUT_FILTER_FOO = """FooDeathTest.
+EXPECTED_OUTPUT_FILTER_FOO_RE = re.compile(r"""FooDeathTest\.
Test1
-Foo.
+Foo\.
Bar1
Bar2
DISABLED_Bar3
-FooBar.
+FooBar\.
Baz
-FooTest.
+FooTest\.
Test1
DISABLED_Test2
Test3
-"""
+""")
# Utilities.
@@ -100,19 +126,18 @@ def Run(args):
class GTestListTestsUnitTest(gtest_test_utils.TestCase):
"""Tests using the --gtest_list_tests flag to list all tests."""
- def RunAndVerify(self, flag_value, expected_output, other_flag):
+ def RunAndVerify(self, flag_value, expected_output_re, other_flag):
"""Runs gtest_list_tests_unittest_ and verifies that it prints
the correct tests.
Args:
- flag_value: value of the --gtest_list_tests flag;
- None if the flag should not be present.
-
- expected_output: the expected output after running command;
-
- other_flag: a different flag to be passed to command
- along with gtest_list_tests;
- None if the flag should not be present.
+ flag_value: value of the --gtest_list_tests flag;
+ None if the flag should not be present.
+ expected_output_re: regular expression that matches the expected
+ output after running command;
+ other_flag: a different flag to be passed to command
+ along with gtest_list_tests;
+ None if the flag should not be present.
"""
if flag_value is None:
@@ -132,36 +157,41 @@ class GTestListTestsUnitTest(gtest_test_utils.TestCase):
output = Run(args)
- msg = ('when %s is %s, the output of "%s" is "%s".' %
- (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output))
-
- if expected_output is not None:
- self.assert_(output == expected_output, msg)
+ if expected_output_re:
+ self.assert_(
+ expected_output_re.match(output),
+ ('when %s is %s, the output of "%s" is "%s",\n'
+ 'which does not match regex "%s"' %
+ (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output,
+ expected_output_re.pattern)))
else:
- self.assert_(output != EXPECTED_OUTPUT_NO_FILTER, msg)
+ self.assert_(
+ not EXPECTED_OUTPUT_NO_FILTER_RE.match(output),
+ ('when %s is %s, the output of "%s" is "%s"'%
+ (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output)))
def testDefaultBehavior(self):
"""Tests the behavior of the default mode."""
self.RunAndVerify(flag_value=None,
- expected_output=None,
+ expected_output_re=None,
other_flag=None)
def testFlag(self):
"""Tests using the --gtest_list_tests flag."""
self.RunAndVerify(flag_value='0',
- expected_output=None,
+ expected_output_re=None,
other_flag=None)
self.RunAndVerify(flag_value='1',
- expected_output=EXPECTED_OUTPUT_NO_FILTER,
+ expected_output_re=EXPECTED_OUTPUT_NO_FILTER_RE,
other_flag=None)
def testOverrideNonFilterFlags(self):
"""Tests that --gtest_list_tests overrides the non-filter flags."""
self.RunAndVerify(flag_value='1',
- expected_output=EXPECTED_OUTPUT_NO_FILTER,
+ expected_output_re=EXPECTED_OUTPUT_NO_FILTER_RE,
other_flag='--gtest_break_on_failure')
def testWithFilterFlags(self):
@@ -169,7 +199,7 @@ class GTestListTestsUnitTest(gtest_test_utils.TestCase):
--gtest_filter flag."""
self.RunAndVerify(flag_value='1',
- expected_output=EXPECTED_OUTPUT_FILTER_FOO,
+ expected_output_re=EXPECTED_OUTPUT_FILTER_FOO_RE,
other_flag='--gtest_filter=Foo*')
diff --git a/test/gtest_list_tests_unittest_.cc b/test/gtest_list_tests_unittest_.cc
index 2b1d078..907c176 100644
--- a/test/gtest_list_tests_unittest_.cc
+++ b/test/gtest_list_tests_unittest_.cc
@@ -40,8 +40,6 @@
#include "gtest/gtest.h"
-namespace {
-
// Several different test cases and tests that will be listed.
TEST(Foo, Bar1) {
}
@@ -76,7 +74,81 @@ TEST_F(FooTest, Test3) {
TEST(FooDeathTest, Test1) {
}
-} // namespace
+// A group of value-parameterized tests.
+
+class MyType {
+ public:
+ explicit MyType(const std::string& a_value) : value_(a_value) {}
+
+ const std::string& value() const { return value_; }
+
+ private:
+ std::string value_;
+};
+
+// Teaches Google Test how to print a MyType.
+void PrintTo(const MyType& x, std::ostream* os) {
+ *os << x.value();
+}
+
+class ValueParamTest : public testing::TestWithParam<MyType> {
+};
+
+TEST_P(ValueParamTest, TestA) {
+}
+
+TEST_P(ValueParamTest, TestB) {
+}
+
+INSTANTIATE_TEST_CASE_P(
+ MyInstantiation, ValueParamTest,
+ testing::Values(MyType("one line"),
+ MyType("two\nlines"),
+ MyType("a very\nloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong line"))); // NOLINT
+
+// A group of typed tests.
+
+// A deliberately long type name for testing the line-truncating
+// behavior when printing a type parameter.
+class VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName { // NOLINT
+};
+
+template <typename T>
+class TypedTest : public testing::Test {
+};
+
+template <typename T, int kSize>
+class MyArray {
+};
+
+typedef testing::Types<VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName, // NOLINT
+ int*, MyArray<bool, 42> > MyTypes;
+
+TYPED_TEST_CASE(TypedTest, MyTypes);
+
+TYPED_TEST(TypedTest, TestA) {
+}
+
+TYPED_TEST(TypedTest, TestB) {
+}
+
+// A group of type-parameterized tests.
+
+template <typename T>
+class TypeParamTest : public testing::Test {
+};
+
+TYPED_TEST_CASE_P(TypeParamTest);
+
+TYPED_TEST_P(TypeParamTest, TestA) {
+}
+
+TYPED_TEST_P(TypeParamTest, TestB) {
+}
+
+REGISTER_TYPED_TEST_CASE_P(TypeParamTest, TestA, TestB);
+
+INSTANTIATE_TYPED_TEST_CASE_P(My, TypeParamTest, MyTypes);
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
diff --git a/test/gtest_output_test_golden_lin.txt b/test/gtest_output_test_golden_lin.txt
index 0e26d63..960eedc 100644
--- a/test/gtest_output_test_golden_lin.txt
+++ b/test/gtest_output_test_golden_lin.txt
@@ -699,8 +699,6 @@ Expected: (3) >= (a[i]), actual: 3 vs 6
[ FAILED ] LoggingTest.InterleavingLoggingAndAssertions
4 FAILED TESTS
- YOU HAVE 1 DISABLED TEST
-
Note: Google Test filter = *DISABLED_*
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
@@ -720,6 +718,3 @@ Note: This is test shard 2 of 2.
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran.
[ PASSED ] 1 test.
-
- YOU HAVE 1 DISABLED TEST
-
diff --git a/test/gtest_premature_exit_test.cc b/test/gtest_premature_exit_test.cc
new file mode 100644
index 0000000..fcfc623
--- /dev/null
+++ b/test/gtest_premature_exit_test.cc
@@ -0,0 +1,143 @@
+// Copyright 2013, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+//
+// Tests that Google Test manipulates the premature-exit-detection
+// file correctly.
+
+#include <stdio.h>
+
+#include "gtest/gtest.h"
+
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::internal::posix::GetEnv;
+using ::testing::internal::posix::Stat;
+using ::testing::internal::posix::StatStruct;
+
+namespace {
+
+// Is the TEST_PREMATURE_EXIT_FILE environment variable expected to be
+// set?
+const bool kTestPrematureExitFileEnvVarShouldBeSet = false;
+
+class PrematureExitTest : public Test {
+ public:
+ // Returns true iff the given file exists.
+ static bool FileExists(const char* filepath) {
+ StatStruct stat;
+ return Stat(filepath, &stat) == 0;
+ }
+
+ protected:
+ PrematureExitTest() {
+ premature_exit_file_path_ = GetEnv("TEST_PREMATURE_EXIT_FILE");
+
+ // Normalize NULL to "" for ease of handling.
+ if (premature_exit_file_path_ == NULL) {
+ premature_exit_file_path_ = "";
+ }
+ }
+
+ // Returns true iff the premature-exit file exists.
+ bool PrematureExitFileExists() const {
+ return FileExists(premature_exit_file_path_);
+ }
+
+ const char* premature_exit_file_path_;
+};
+
+typedef PrematureExitTest PrematureExitDeathTest;
+
+// Tests that:
+// - the premature-exit file exists during the execution of a
+// death test (EXPECT_DEATH*), and
+// - a death test doesn't interfere with the main test process's
+// handling of the premature-exit file.
+TEST_F(PrematureExitDeathTest, FileExistsDuringExecutionOfDeathTest) {
+ if (*premature_exit_file_path_ == '\0') {
+ return;
+ }
+
+ EXPECT_DEATH_IF_SUPPORTED({
+ // If the file exists, crash the process such that the main test
+ // process will catch the (expected) crash and report a success;
+ // otherwise don't crash, which will cause the main test process
+ // to report that the death test has failed.
+ if (PrematureExitFileExists()) {
+ exit(1);
+ }
+ }, "");
+}
+
+// Tests that TEST_PREMATURE_EXIT_FILE is set where it's expected to
+// be set.
+TEST_F(PrematureExitTest, TestPrematureExitFileEnvVarIsSet) {
+ GTEST_INTENTIONAL_CONST_COND_PUSH_
+ if (kTestPrematureExitFileEnvVarShouldBeSet) {
+ GTEST_INTENTIONAL_CONST_COND_POP_
+ const char* const filepath = GetEnv("TEST_PREMATURE_EXIT_FILE");
+ ASSERT_TRUE(filepath != NULL);
+ ASSERT_NE(*filepath, '\0');
+ }
+}
+
+// Tests that the premature-exit file exists during the execution of a
+// normal (non-death) test.
+TEST_F(PrematureExitTest, PrematureExitFileExistsDuringTestExecution) {
+ if (*premature_exit_file_path_ == '\0') {
+ return;
+ }
+
+ EXPECT_TRUE(PrematureExitFileExists())
+ << " file " << premature_exit_file_path_
+ << " should exist during test execution, but doesn't.";
+}
+
+} // namespace
+
+int main(int argc, char **argv) {
+ InitGoogleTest(&argc, argv);
+ const int exit_code = RUN_ALL_TESTS();
+
+ // Test that the premature-exit file is deleted upon return from
+ // RUN_ALL_TESTS().
+ const char* const filepath = GetEnv("TEST_PREMATURE_EXIT_FILE");
+ if (filepath != NULL && *filepath != '\0') {
+ if (PrematureExitTest::FileExists(filepath)) {
+ printf(
+ "File %s shouldn't exist after the test program finishes, but does.",
+ filepath);
+ return 1;
+ }
+ }
+
+ return exit_code;
+}
diff --git a/test/gtest_test_utils.py b/test/gtest_test_utils.py
index 6dd8db4..7e3cbca 100755
--- a/test/gtest_test_utils.py
+++ b/test/gtest_test_utils.py
@@ -56,6 +56,21 @@ GTEST_OUTPUT_VAR_NAME = 'GTEST_OUTPUT'
IS_WINDOWS = os.name == 'nt'
IS_CYGWIN = os.name == 'posix' and 'CYGWIN' in os.uname()[0]
+# The environment variable for specifying the path to the premature-exit file.
+PREMATURE_EXIT_FILE_ENV_VAR = 'TEST_PREMATURE_EXIT_FILE'
+
+environ = os.environ.copy()
+
+
+def SetEnvVar(env_var, value):
+ """Sets/unsets an environment variable to a given value."""
+
+ if value is not None:
+ environ[env_var] = value
+ elif env_var in environ:
+ del environ[env_var]
+
+
# Here we expose a class from a particular module, depending on the
# environment. The comment suppresses the 'Invalid variable name' lint
# complaint.
@@ -160,9 +175,9 @@ def GetTestExecutablePath(executable_name, build_dir=None):
if not os.path.exists(path):
message = (
- 'Unable to find the test binary. Please make sure to provide path\n'
- 'to the binary via the --build_dir flag or the BUILD_DIR\n'
- 'environment variable.')
+ 'Unable to find the test binary "%s". Please make sure to provide\n'
+ 'a path to the binary via the --build_dir flag or the BUILD_DIR\n'
+ 'environment variable.' % path)
print >> sys.stderr, message
sys.exit(1)
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc
index f594a44..0cab07d 100644
--- a/test/gtest_unittest.cc
+++ b/test/gtest_unittest.cc
@@ -180,6 +180,18 @@ class TestEventListenersAccessor {
}
};
+class UnitTestRecordPropertyTestHelper : public Test {
+ protected:
+ UnitTestRecordPropertyTestHelper() {}
+
+ // Forwards to UnitTest::RecordProperty() to bypass access controls.
+ void UnitTestRecordProperty(const char* key, const std::string& value) {
+ unit_test_.RecordProperty(key, value);
+ }
+
+ UnitTest unit_test_;
+};
+
} // namespace internal
} // namespace testing
@@ -188,6 +200,7 @@ using testing::AssertionResult;
using testing::AssertionSuccess;
using testing::DoubleLE;
using testing::EmptyTestEventListener;
+using testing::Environment;
using testing::FloatLE;
using testing::GTEST_FLAG(also_run_disabled_tests);
using testing::GTEST_FLAG(break_on_failure);
@@ -213,6 +226,7 @@ using testing::StaticAssertTypeEq;
using testing::Test;
using testing::TestCase;
using testing::TestEventListeners;
+using testing::TestInfo;
using testing::TestPartResult;
using testing::TestPartResultArray;
using testing::TestProperty;
@@ -498,15 +512,6 @@ TEST(NullLiteralTest, IsTrueForNullLiterals) {
EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0));
EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0U));
EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0L));
-
-# ifndef __BORLANDC__
-
- // Some compilers may fail to detect some null pointer literals;
- // as long as users of the framework don't use such literals, this
- // is harmless.
- EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(1 - 1));
-
-# endif
}
// Tests that GTEST_IS_NULL_LITERAL_(x) is false when x is not a null
@@ -1447,7 +1452,7 @@ TEST(TestResultPropertyTest, NoPropertiesFoundWhenNoneAreAdded) {
TEST(TestResultPropertyTest, OnePropertyFoundWhenAdded) {
TestResult test_result;
TestProperty property("key_1", "1");
- TestResultAccessor::RecordProperty(&test_result, property);
+ TestResultAccessor::RecordProperty(&test_result, "testcase", property);
ASSERT_EQ(1, test_result.test_property_count());
const TestProperty& actual_property = test_result.GetTestProperty(0);
EXPECT_STREQ("key_1", actual_property.key());
@@ -1459,8 +1464,8 @@ TEST(TestResultPropertyTest, MultiplePropertiesFoundWhenAdded) {
TestResult test_result;
TestProperty property_1("key_1", "1");
TestProperty property_2("key_2", "2");
- TestResultAccessor::RecordProperty(&test_result, property_1);
- TestResultAccessor::RecordProperty(&test_result, property_2);
+ TestResultAccessor::RecordProperty(&test_result, "testcase", property_1);
+ TestResultAccessor::RecordProperty(&test_result, "testcase", property_2);
ASSERT_EQ(2, test_result.test_property_count());
const TestProperty& actual_property_1 = test_result.GetTestProperty(0);
EXPECT_STREQ("key_1", actual_property_1.key());
@@ -1478,10 +1483,10 @@ TEST(TestResultPropertyTest, OverridesValuesForDuplicateKeys) {
TestProperty property_2_1("key_2", "2");
TestProperty property_1_2("key_1", "12");
TestProperty property_2_2("key_2", "22");
- TestResultAccessor::RecordProperty(&test_result, property_1_1);
- TestResultAccessor::RecordProperty(&test_result, property_2_1);
- TestResultAccessor::RecordProperty(&test_result, property_1_2);
- TestResultAccessor::RecordProperty(&test_result, property_2_2);
+ TestResultAccessor::RecordProperty(&test_result, "testcase", property_1_1);
+ TestResultAccessor::RecordProperty(&test_result, "testcase", property_2_1);
+ TestResultAccessor::RecordProperty(&test_result, "testcase", property_1_2);
+ TestResultAccessor::RecordProperty(&test_result, "testcase", property_2_2);
ASSERT_EQ(2, test_result.test_property_count());
const TestProperty& actual_property_1 = test_result.GetTestProperty(0);
@@ -1494,14 +1499,14 @@ TEST(TestResultPropertyTest, OverridesValuesForDuplicateKeys) {
}
// Tests TestResult::GetTestProperty().
-TEST(TestResultPropertyDeathTest, GetTestProperty) {
+TEST(TestResultPropertyTest, GetTestProperty) {
TestResult test_result;
TestProperty property_1("key_1", "1");
TestProperty property_2("key_2", "2");
TestProperty property_3("key_3", "3");
- TestResultAccessor::RecordProperty(&test_result, property_1);
- TestResultAccessor::RecordProperty(&test_result, property_2);
- TestResultAccessor::RecordProperty(&test_result, property_3);
+ TestResultAccessor::RecordProperty(&test_result, "testcase", property_1);
+ TestResultAccessor::RecordProperty(&test_result, "testcase", property_2);
+ TestResultAccessor::RecordProperty(&test_result, "testcase", property_3);
const TestProperty& fetched_property_1 = test_result.GetTestProperty(0);
const TestProperty& fetched_property_2 = test_result.GetTestProperty(1);
@@ -1520,42 +1525,6 @@ TEST(TestResultPropertyDeathTest, GetTestProperty) {
EXPECT_DEATH_IF_SUPPORTED(test_result.GetTestProperty(-1), "");
}
-// When a property using a reserved key is supplied to this function, it tests
-// that a non-fatal failure is added, a fatal failure is not added, and that the
-// property is not recorded.
-void ExpectNonFatalFailureRecordingPropertyWithReservedKey(const char* key) {
- TestResult test_result;
- TestProperty property(key, "1");
- EXPECT_NONFATAL_FAILURE(
- TestResultAccessor::RecordProperty(&test_result, property),
- "Reserved key");
- ASSERT_EQ(0, test_result.test_property_count()) << "Not recorded";
-}
-
-// Attempting to recording a property with the Reserved literal "name"
-// should add a non-fatal failure and the property should not be recorded.
-TEST(TestResultPropertyTest, AddFailureWhenUsingReservedKeyCalledName) {
- ExpectNonFatalFailureRecordingPropertyWithReservedKey("name");
-}
-
-// Attempting to recording a property with the Reserved literal "status"
-// should add a non-fatal failure and the property should not be recorded.
-TEST(TestResultPropertyTest, AddFailureWhenUsingReservedKeyCalledStatus) {
- ExpectNonFatalFailureRecordingPropertyWithReservedKey("status");
-}
-
-// Attempting to recording a property with the Reserved literal "time"
-// should add a non-fatal failure and the property should not be recorded.
-TEST(TestResultPropertyTest, AddFailureWhenUsingReservedKeyCalledTime) {
- ExpectNonFatalFailureRecordingPropertyWithReservedKey("time");
-}
-
-// Attempting to recording a property with the Reserved literal "classname"
-// should add a non-fatal failure and the property should not be recorded.
-TEST(TestResultPropertyTest, AddFailureWhenUsingReservedKeyCalledClassname) {
- ExpectNonFatalFailureRecordingPropertyWithReservedKey("classname");
-}
-
// Tests that GTestFlagSaver works on Windows and Mac.
class GTestFlagSaverTest : public Test {
@@ -1961,6 +1930,168 @@ TEST(UnitTestTest, ReturnsPlausibleTimestamp) {
EXPECT_LE(UnitTest::GetInstance()->start_timestamp(), GetTimeInMillis());
}
+// When a property using a reserved key is supplied to this function, it
+// tests that a non-fatal failure is added, a fatal failure is not added,
+// and that the property is not recorded.
+void ExpectNonFatalFailureRecordingPropertyWithReservedKey(
+ const TestResult& test_result, const char* key) {
+ EXPECT_NONFATAL_FAILURE(Test::RecordProperty(key, "1"), "Reserved key");
+ ASSERT_EQ(0, test_result.test_property_count()) << "Property for key '" << key
+ << "' recorded unexpectedly.";
+}
+
+void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
+ const char* key) {
+ const TestInfo* test_info = UnitTest::GetInstance()->current_test_info();
+ ASSERT_TRUE(test_info != NULL);
+ ExpectNonFatalFailureRecordingPropertyWithReservedKey(*test_info->result(),
+ key);
+}
+
+void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
+ const char* key) {
+ const TestCase* test_case = UnitTest::GetInstance()->current_test_case();
+ ASSERT_TRUE(test_case != NULL);
+ ExpectNonFatalFailureRecordingPropertyWithReservedKey(
+ test_case->ad_hoc_test_result(), key);
+}
+
+void ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
+ const char* key) {
+ ExpectNonFatalFailureRecordingPropertyWithReservedKey(
+ UnitTest::GetInstance()->ad_hoc_test_result(), key);
+}
+
+// Tests that property recording functions in UnitTest outside of tests
+// functions correcly. Creating a separate instance of UnitTest ensures it
+// is in a state similar to the UnitTest's singleton's between tests.
+class UnitTestRecordPropertyTest :
+ public testing::internal::UnitTestRecordPropertyTestHelper {
+ public:
+ static void SetUpTestCase() {
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
+ "disabled");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
+ "errors");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
+ "failures");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
+ "name");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
+ "tests");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
+ "time");
+
+ Test::RecordProperty("test_case_key_1", "1");
+ const TestCase* test_case = UnitTest::GetInstance()->current_test_case();
+ ASSERT_TRUE(test_case != NULL);
+
+ ASSERT_EQ(1, test_case->ad_hoc_test_result().test_property_count());
+ EXPECT_STREQ("test_case_key_1",
+ test_case->ad_hoc_test_result().GetTestProperty(0).key());
+ EXPECT_STREQ("1",
+ test_case->ad_hoc_test_result().GetTestProperty(0).value());
+ }
+};
+
+// Tests TestResult has the expected property when added.
+TEST_F(UnitTestRecordPropertyTest, OnePropertyFoundWhenAdded) {
+ UnitTestRecordProperty("key_1", "1");
+
+ ASSERT_EQ(1, unit_test_.ad_hoc_test_result().test_property_count());
+
+ EXPECT_STREQ("key_1",
+ unit_test_.ad_hoc_test_result().GetTestProperty(0).key());
+ EXPECT_STREQ("1",
+ unit_test_.ad_hoc_test_result().GetTestProperty(0).value());
+}
+
+// Tests TestResult has multiple properties when added.
+TEST_F(UnitTestRecordPropertyTest, MultiplePropertiesFoundWhenAdded) {
+ UnitTestRecordProperty("key_1", "1");
+ UnitTestRecordProperty("key_2", "2");
+
+ ASSERT_EQ(2, unit_test_.ad_hoc_test_result().test_property_count());
+
+ EXPECT_STREQ("key_1",
+ unit_test_.ad_hoc_test_result().GetTestProperty(0).key());
+ EXPECT_STREQ("1", unit_test_.ad_hoc_test_result().GetTestProperty(0).value());
+
+ EXPECT_STREQ("key_2",
+ unit_test_.ad_hoc_test_result().GetTestProperty(1).key());
+ EXPECT_STREQ("2", unit_test_.ad_hoc_test_result().GetTestProperty(1).value());
+}
+
+// Tests TestResult::RecordProperty() overrides values for duplicate keys.
+TEST_F(UnitTestRecordPropertyTest, OverridesValuesForDuplicateKeys) {
+ UnitTestRecordProperty("key_1", "1");
+ UnitTestRecordProperty("key_2", "2");
+ UnitTestRecordProperty("key_1", "12");
+ UnitTestRecordProperty("key_2", "22");
+
+ ASSERT_EQ(2, unit_test_.ad_hoc_test_result().test_property_count());
+
+ EXPECT_STREQ("key_1",
+ unit_test_.ad_hoc_test_result().GetTestProperty(0).key());
+ EXPECT_STREQ("12",
+ unit_test_.ad_hoc_test_result().GetTestProperty(0).value());
+
+ EXPECT_STREQ("key_2",
+ unit_test_.ad_hoc_test_result().GetTestProperty(1).key());
+ EXPECT_STREQ("22",
+ unit_test_.ad_hoc_test_result().GetTestProperty(1).value());
+}
+
+TEST_F(UnitTestRecordPropertyTest,
+ AddFailureInsideTestsWhenUsingTestCaseReservedKeys) {
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
+ "name");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
+ "value_param");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
+ "type_param");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
+ "status");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
+ "time");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
+ "classname");
+}
+
+TEST_F(UnitTestRecordPropertyTest,
+ AddRecordWithReservedKeysGeneratesCorrectPropertyList) {
+ EXPECT_NONFATAL_FAILURE(
+ Test::RecordProperty("name", "1"),
+ "'classname', 'name', 'status', 'time', 'type_param', and 'value_param'"
+ " are reserved");
+}
+
+class UnitTestRecordPropertyTestEnvironment : public Environment {
+ public:
+ virtual void TearDown() {
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
+ "tests");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
+ "failures");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
+ "disabled");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
+ "errors");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
+ "name");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
+ "timestamp");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
+ "time");
+ ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
+ "random_seed");
+ }
+};
+
+// This will test property recording outside of any test or test case.
+static Environment* record_property_env =
+ AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment);
+
// This group of tests is for predicate assertions (ASSERT_PRED*, etc)
// of various arities. They do not attempt to be exhaustive. Rather,
// view them as smoke tests that can be easily reviewed and verified.
@@ -4518,7 +4649,7 @@ TEST(EqAssertionTest, StdString) {
// Compares a const char* to an std::string that has different
// content
EXPECT_NONFATAL_FAILURE(EXPECT_EQ("Test", ::std::string("test")),
- "::std::string(\"test\")");
+ "\"test\"");
// Compares an std::string to a char* that has different content.
char* const p1 = const_cast<char*>("foo");
@@ -6429,6 +6560,9 @@ TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {
SetEnv("TERM", "screen"); // TERM supports colors.
EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
+ SetEnv("TERM", "screen-256color"); // TERM supports colors.
+ EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
+
SetEnv("TERM", "linux"); // TERM supports colors.
EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
diff --git a/test/gtest_xml_output_unittest.py b/test/gtest_xml_output_unittest.py
index 1bcd418..f605d4e 100755
--- a/test/gtest_xml_output_unittest.py
+++ b/test/gtest_xml_output_unittest.py
@@ -44,6 +44,7 @@ import gtest_test_utils
import gtest_xml_test_utils
+GTEST_FILTER_FLAG = '--gtest_filter'
GTEST_LIST_TESTS_FLAG = '--gtest_list_tests'
GTEST_OUTPUT_FLAG = "--gtest_output"
GTEST_DEFAULT_OUTPUT_FILE = "test_detail.xml"
@@ -57,7 +58,7 @@ else:
STACK_TRACE_TEMPLATE = ''
EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?>
-<testsuites tests="23" failures="4" disabled="2" errors="0" time="*" timestamp="*" name="AllTests">
+<testsuites tests="23" failures="4" disabled="2" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42">
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/>
</testsuite>
@@ -97,7 +98,7 @@ Invalid characters in brackets []%(stack)s]]></failure>
<testsuite name="DisabledTest" tests="1" failures="0" disabled="1" errors="0" time="*">
<testcase name="DISABLED_test_not_run" status="notrun" time="*" classname="DisabledTest"/>
</testsuite>
- <testsuite name="PropertyRecordingTest" tests="4" failures="0" disabled="0" errors="0" time="*">
+ <testsuite name="PropertyRecordingTest" tests="4" failures="0" disabled="0" errors="0" time="*" SetUpTestCase="yes" TearDownTestCase="aye">
<testcase name="OneProperty" status="run" time="*" classname="PropertyRecordingTest" key_1="1"/>
<testcase name="IntValuedProperty" status="run" time="*" classname="PropertyRecordingTest" key_int="1"/>
<testcase name="ThreeProperties" status="run" time="*" classname="PropertyRecordingTest" key_1="1" key_2="2" key_3="3"/>
@@ -128,9 +129,18 @@ Invalid characters in brackets []%(stack)s]]></failure>
</testsuite>
</testsuites>""" % {'stack': STACK_TRACE_TEMPLATE}
+EXPECTED_FILTERED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
+<testsuites tests="1" failures="0" disabled="0" errors="0" time="*"
+ timestamp="*" name="AllTests" ad_hoc_property="42">
+ <testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0"
+ errors="0" time="*">
+ <testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/>
+ </testsuite>
+</testsuites>"""
EXPECTED_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?>
-<testsuites tests="0" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
+<testsuites tests="0" failures="0" disabled="0" errors="0" time="*"
+ timestamp="*" name="AllTests">
</testsuites>"""
GTEST_PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath(GTEST_PROGRAM_NAME)
@@ -169,7 +179,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
Runs a test program that generates an empty XML output, and checks if
the timestamp attribute in the testsuites tag is valid.
"""
- actual = self._GetXmlOutput('gtest_no_test_unittest', 0)
+ actual = self._GetXmlOutput('gtest_no_test_unittest', [], 0)
date_time_str = actual.documentElement.getAttributeNode('timestamp').value
# datetime.strptime() is only available in Python 2.5+ so we have to
# parse the expected datetime manually.
@@ -239,7 +249,17 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
self.assert_(not os.path.isfile(xml_path))
- def _GetXmlOutput(self, gtest_prog_name, expected_exit_code):
+ def testFilteredTestXmlOutput(self):
+ """Verifies XML output when a filter is applied.
+
+ Runs a test program that executes only some tests and verifies that
+ non-selected tests do not show up in the XML output.
+ """
+
+ self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED_TEST_XML, 0,
+ extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG])
+
+ def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code):
"""
Returns the xml output generated by running the program gtest_prog_name.
Furthermore, the program's exit code must be expected_exit_code.
@@ -248,7 +268,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
gtest_prog_name + 'out.xml')
gtest_prog_path = gtest_test_utils.GetTestExecutablePath(gtest_prog_name)
- command = [gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)]
+ command = ([gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)] +
+ extra_args)
p = gtest_test_utils.Subprocess(command)
if p.terminated_by_signal:
self.assert_(False,
@@ -262,7 +283,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
actual = minidom.parse(xml_path)
return actual
- def _TestXmlOutput(self, gtest_prog_name, expected_xml, expected_exit_code):
+ def _TestXmlOutput(self, gtest_prog_name, expected_xml,
+ expected_exit_code, extra_args=None):
"""
Asserts that the XML document generated by running the program
gtest_prog_name matches expected_xml, a string containing another
@@ -270,7 +292,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
expected_exit_code.
"""
- actual = self._GetXmlOutput(gtest_prog_name, expected_exit_code)
+ actual = self._GetXmlOutput(gtest_prog_name, extra_args or [],
+ expected_exit_code)
expected = minidom.parseString(expected_xml)
self.NormalizeXml(actual.documentElement)
self.AssertEquivalentNodes(expected.documentElement,
diff --git a/test/gtest_xml_output_unittest_.cc b/test/gtest_xml_output_unittest_.cc
index bf0c871..48b8771 100644
--- a/test/gtest_xml_output_unittest_.cc
+++ b/test/gtest_xml_output_unittest_.cc
@@ -95,6 +95,9 @@ TEST(InvalidCharactersTest, InvalidCharactersInMessage) {
}
class PropertyRecordingTest : public Test {
+ public:
+ static void SetUpTestCase() { RecordProperty("SetUpTestCase", "yes"); }
+ static void TearDownTestCase() { RecordProperty("TearDownTestCase", "aye"); }
};
TEST_F(PropertyRecordingTest, OneProperty) {
@@ -120,12 +123,12 @@ TEST(NoFixtureTest, RecordProperty) {
RecordProperty("key", "1");
}
-void ExternalUtilityThatCallsRecordProperty(const char* key, int value) {
+void ExternalUtilityThatCallsRecordProperty(const std::string& key, int value) {
testing::Test::RecordProperty(key, value);
}
-void ExternalUtilityThatCallsRecordProperty(const char* key,
- const char* value) {
+void ExternalUtilityThatCallsRecordProperty(const std::string& key,
+ const std::string& value) {
testing::Test::RecordProperty(key, value);
}
@@ -173,5 +176,6 @@ int main(int argc, char** argv) {
TestEventListeners& listeners = UnitTest::GetInstance()->listeners();
delete listeners.Release(listeners.default_xml_generator());
}
+ testing::Test::RecordProperty("ad_hoc_property", "42");
return RUN_ALL_TESTS();
}
diff --git a/test/gtest_xml_test_utils.py b/test/gtest_xml_test_utils.py
index 0e5a108..3d0c3b2 100755
--- a/test/gtest_xml_test_utils.py
+++ b/test/gtest_xml_test_utils.py
@@ -80,7 +80,9 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
actual_attributes = actual_node .attributes
self.assertEquals(
expected_attributes.length, actual_attributes.length,
- 'attribute numbers differ in element ' + actual_node.tagName)
+ 'attribute numbers differ in element %s:\nExpected: %r\nActual: %r' % (
+ actual_node.tagName, expected_attributes.keys(),
+ actual_attributes.keys()))
for i in range(expected_attributes.length):
expected_attr = expected_attributes.item(i)
actual_attr = actual_attributes.get(expected_attr.name)
@@ -88,9 +90,11 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
actual_attr is not None,
'expected attribute %s not found in element %s' %
(expected_attr.name, actual_node.tagName))
- self.assertEquals(expected_attr.value, actual_attr.value,
- ' values of attribute %s in element %s differ' %
- (expected_attr.name, actual_node.tagName))
+ self.assertEquals(
+ expected_attr.value, actual_attr.value,
+ ' values of attribute %s in element %s differ: %s vs %s' %
+ (expected_attr.name, actual_node.tagName,
+ expected_attr.value, actual_attr.value))
expected_children = self._GetChildren(expected_node)
actual_children = self._GetChildren(actual_node)
diff --git a/xcode/gtest.xcodeproj/project.pbxproj b/xcode/gtest.xcodeproj/project.pbxproj
index da6455b..0452a63 100644
--- a/xcode/gtest.xcodeproj/project.pbxproj
+++ b/xcode/gtest.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 42;
+ objectVersion = 46;
objects = {
/* Begin PBXAggregateTarget section */
@@ -580,8 +580,12 @@
/* Begin PBXProject section */
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0460;
+ };
buildConfigurationList = 4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject "gtest" */;
- compatibilityVersion = "Xcode 2.4";
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
@@ -789,20 +793,25 @@
3B238F600E828B5400846E11 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
PRODUCT_NAME = Check;
+ SDKROOT = macosx;
};
name = Debug;
};
3B238F610E828B5400846E11 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
PRODUCT_NAME = Check;
+ SDKROOT = macosx;
ZERO_LINK = NO;
};
name = Release;
@@ -810,37 +819,49 @@
40899F450FFA7185000B29AE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = ../;
PRODUCT_NAME = "gtest_unittest-framework";
+ SDKROOT = macosx;
};
name = Debug;
};
40899F460FFA7185000B29AE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = ../;
PRODUCT_NAME = "gtest_unittest-framework";
+ SDKROOT = macosx;
};
name = Release;
};
4089A0150FFACEFD000B29AE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
PRODUCT_NAME = "sample1_unittest-framework";
+ SDKROOT = macosx;
};
name = Debug;
};
4089A0160FFACEFD000B29AE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
PRODUCT_NAME = "sample1_unittest-framework";
+ SDKROOT = macosx;
};
name = Release;
};
40C44ADF0E3798F4008FCC51 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = gtest;
+ SDKROOT = macosx;
TARGET_NAME = gtest;
};
name = Debug;
@@ -848,7 +869,11 @@
40C44AE00E3798F4008FCC51 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = gtest;
+ SDKROOT = macosx;
TARGET_NAME = gtest;
};
name = Release;
@@ -857,13 +882,16 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
../,
../include/,
);
PRODUCT_NAME = gtest;
+ SDKROOT = macosx;
};
name = Debug;
};
@@ -871,13 +899,16 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
../,
../include/,
);
PRODUCT_NAME = gtest;
+ SDKROOT = macosx;
};
name = Release;
};
@@ -885,11 +916,14 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
../,
../include/,
);
PRODUCT_NAME = gtest_main;
+ SDKROOT = macosx;
};
name = Debug;
};
@@ -897,41 +931,52 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
../,
../include/,
);
PRODUCT_NAME = gtest_main;
+ SDKROOT = macosx;
};
name = Release;
};
40C84985101A36850083642A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = ../;
PRODUCT_NAME = gtest_unittest;
+ SDKROOT = macosx;
};
name = Debug;
};
40C84986101A36850083642A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = ../;
PRODUCT_NAME = gtest_unittest;
+ SDKROOT = macosx;
};
name = Release;
};
40C84995101A36A60083642A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
PRODUCT_NAME = "sample1_unittest-static";
+ SDKROOT = macosx;
};
name = Debug;
};
40C84996101A36A60083642A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
PRODUCT_NAME = "sample1_unittest-static";
+ SDKROOT = macosx;
};
name = Release;
};
@@ -939,8 +984,10 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 40D4CDF20E30E07400294801 /* FrameworkTarget.xcconfig */;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
../,
../include/,
@@ -949,6 +996,7 @@
INFOPLIST_PREFIX_HEADER = "$(PROJECT_TEMP_DIR)/Version.h";
INFOPLIST_PREPROCESS = YES;
PRODUCT_NAME = gtest;
+ SDKROOT = macosx;
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
@@ -957,8 +1005,10 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 40D4CDF20E30E07400294801 /* FrameworkTarget.xcconfig */;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
../,
../include/,
@@ -967,6 +1017,7 @@
INFOPLIST_PREFIX_HEADER = "$(PROJECT_TEMP_DIR)/Version.h";
INFOPLIST_PREPROCESS = YES;
PRODUCT_NAME = gtest;
+ SDKROOT = macosx;
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;