Merge branch 'master' into master

This commit is contained in:
tisi1988 2018-07-23 10:10:26 +02:00 committed by GitHub
commit 1ae4fdb790
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 2213 additions and 2209 deletions

3
.gitignore vendored
View File

@ -38,3 +38,6 @@ googletest/m4/lt~obsolete.m4
# Ignore generated directories. # Ignore generated directories.
googlemock/fused-src/ googlemock/fused-src/
googletest/fused-src/ googletest/fused-src/
# macOS files
.DS_Store

View File

@ -38,7 +38,7 @@ licenses(["notice"])
config_setting( config_setting(
name = "windows", name = "windows",
values = { "cpu": "x64_windows" }, values = {"cpu": "x64_windows"},
) )
config_setting( config_setting(
@ -51,7 +51,6 @@ config_setting(
values = {"define": "absl=1"}, values = {"define": "absl=1"},
) )
# Google Test including Google Mock # Google Test including Google Mock
cc_library( cc_library(
name = "gtest", name = "gtest",
@ -70,7 +69,7 @@ cc_library(
"googlemock/src/gmock_main.cc", "googlemock/src/gmock_main.cc",
], ],
), ),
hdrs =glob([ hdrs = glob([
"googletest/include/gtest/*.h", "googletest/include/gtest/*.h",
"googlemock/include/gmock/*.h", "googlemock/include/gmock/*.h",
]), ]),
@ -81,6 +80,14 @@ cc_library(
"//conditions:default": ["-pthread"], "//conditions:default": ["-pthread"],
}, },
), ),
defines = select(
{
":has_absl": [
"GTEST_HAS_ABSL=1",
],
"//conditions:default": [],
},
),
includes = [ includes = [
"googlemock", "googlemock",
"googlemock/include", "googlemock/include",
@ -94,21 +101,19 @@ cc_library(
"-pthread", "-pthread",
], ],
}), }),
defines = select ({ deps = select(
":has_absl": [ {
"GTEST_HAS_ABSL=1",
],
"//conditions:default": [],
}
),
deps = select ({
":has_absl": [ ":has_absl": [
"@com_google_absl//absl/debugging:failure_signal_handler",
"@com_google_absl//absl/debugging:stacktrace",
"@com_google_absl//absl/debugging:symbolize",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:optional",
"@com_google_absl//absl/strings" "@com_google_absl//absl/types:variant",
], ],
"//conditions:default": [], "//conditions:default": [],
} },
) ),
) )
cc_library( cc_library(

View File

@ -2247,7 +2247,7 @@ enum class AccessLevel { kInternal, kPublic };
class Buzz { class Buzz {
public: public:
explicit Buzz(AccessLevel access) { } explicit Buzz(AccessLevel access) { ... }
... ...
}; };
@ -2320,7 +2320,7 @@ Note that `ByMove()` is essential here - if you drop it, the code wont compil
Quiz time! What do you think will happen if a `Return(ByMove(...))` action is Quiz time! What do you think will happen if a `Return(ByMove(...))` action is
performed more than once (e.g. you write performed more than once (e.g. you write
`.WillRepeatedly(Return(ByMove(...)));`)? Come think of it, after the first `.WillRepeatedly(Return(ByMove(...)));`)? Come think of it, after the first
time the action runs, the source value will be consumed (since its a move-only time the action runs, the source value will be consumed (since its a move-only
value), so the next time around, theres no value to move from -- youll get a value), so the next time around, theres no value to move from -- youll get a
run-time error that `Return(ByMove(...))` can only be run once. run-time error that `Return(ByMove(...))` can only be run once.

View File

@ -352,7 +352,7 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
// //
// class MockClass { // class MockClass {
// // Overload 1 // // Overload 1
// MockSpec<string&()> gmock_GetName() { } // MockSpec<string&()> gmock_GetName() { ... }
// // Overload 2. Declared const so that the compiler will generate an // // Overload 2. Declared const so that the compiler will generate an
// // error when trying to resolve between this and overload 4 in // // error when trying to resolve between this and overload 4 in
// // 'gmock_GetName(WithoutMatchers(), nullptr)'. // // 'gmock_GetName(WithoutMatchers(), nullptr)'.
@ -363,7 +363,7 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
// } // }
// //
// // Overload 3 // // Overload 3
// const string& gmock_GetName() const { } // const string& gmock_GetName() const { ... }
// // Overload 4 // // Overload 4
// MockSpec<const string&()> gmock_GetName( // MockSpec<const string&()> gmock_GetName(
// const WithoutMatchers&, const Function<const string&()>*) const { // const WithoutMatchers&, const Function<const string&()>*) const {

View File

@ -114,7 +114,7 @@ class FunctionMocker<R($As)> : public
// //
// class MockClass { // class MockClass {
// // Overload 1 // // Overload 1
// MockSpec<string&()> gmock_GetName() { } // MockSpec<string&()> gmock_GetName() { ... }
// // Overload 2. Declared const so that the compiler will generate an // // Overload 2. Declared const so that the compiler will generate an
// // error when trying to resolve between this and overload 4 in // // error when trying to resolve between this and overload 4 in
// // 'gmock_GetName(WithoutMatchers(), nullptr)'. // // 'gmock_GetName(WithoutMatchers(), nullptr)'.
@ -125,7 +125,7 @@ class FunctionMocker<R($As)> : public
// } // }
// //
// // Overload 3 // // Overload 3
// const string& gmock_GetName() const { } // const string& gmock_GetName() const { ... }
// // Overload 4 // // Overload 4
// MockSpec<const string&()> gmock_GetName( // MockSpec<const string&()> gmock_GetName(
// const WithoutMatchers&, const Function<const string&()>*) const { // const WithoutMatchers&, const Function<const string&()>*) const {

View File

@ -4529,6 +4529,20 @@ Property(PropertyType (Class::*property)() const &,
property, property,
MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher))); MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
} }
// Three-argument form for reference-qualified member functions.
template <typename Class, typename PropertyType, typename PropertyMatcher>
inline PolymorphicMatcher<internal::PropertyMatcher<
Class, PropertyType, PropertyType (Class::*)() const &> >
Property(const std::string& property_name,
PropertyType (Class::*property)() const &,
const PropertyMatcher& matcher) {
return MakePolymorphicMatcher(
internal::PropertyMatcher<Class, PropertyType,
PropertyType (Class::*)() const &>(
property_name, property,
MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
}
#endif #endif
// Creates a matcher that matches an object iff the result of applying // Creates a matcher that matches an object iff the result of applying
@ -5165,13 +5179,17 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
// Define variadic matcher versions. They are overloaded in // Define variadic matcher versions. They are overloaded in
// gmock-generated-matchers.h for the cases supported by pre C++11 compilers. // gmock-generated-matchers.h for the cases supported by pre C++11 compilers.
template <typename... Args> template <typename... Args>
internal::AllOfMatcher<Args...> AllOf(const Args&... matchers) { internal::AllOfMatcher<typename std::decay<const Args&>::type...> AllOf(
return internal::AllOfMatcher<Args...>(matchers...); const Args&... matchers) {
return internal::AllOfMatcher<typename std::decay<const Args&>::type...>(
matchers...);
} }
template <typename... Args> template <typename... Args>
internal::AnyOfMatcher<Args...> AnyOf(const Args&... matchers) { internal::AnyOfMatcher<typename std::decay<const Args&>::type...> AnyOf(
return internal::AnyOfMatcher<Args...>(matchers...); const Args&... matchers) {
return internal::AnyOfMatcher<typename std::decay<const Args&>::type...>(
matchers...);
} }
template <typename... Args> template <typename... Args>

View File

@ -1854,22 +1854,22 @@ inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
// parameter. This technique may only be used for non-overloaded methods. // parameter. This technique may only be used for non-overloaded methods.
// //
// // These are the same: // // These are the same:
// ON_CALL(mock, NoArgsMethod()).WillByDefault(); // ON_CALL(mock, NoArgsMethod()).WillByDefault(...);
// ON_CALL(mock, NoArgsMethod).WillByDefault(); // ON_CALL(mock, NoArgsMethod).WillByDefault(...);
// //
// // As are these: // // As are these:
// ON_CALL(mock, TwoArgsMethod(_, _)).WillByDefault(); // ON_CALL(mock, TwoArgsMethod(_, _)).WillByDefault(...);
// ON_CALL(mock, TwoArgsMethod).WillByDefault(); // ON_CALL(mock, TwoArgsMethod).WillByDefault(...);
// //
// // Can also specify args if you want, of course: // // Can also specify args if you want, of course:
// ON_CALL(mock, TwoArgsMethod(_, 45)).WillByDefault(); // ON_CALL(mock, TwoArgsMethod(_, 45)).WillByDefault(...);
// //
// // Overloads work as long as you specify parameters: // // Overloads work as long as you specify parameters:
// ON_CALL(mock, OverloadedMethod(_)).WillByDefault(); // ON_CALL(mock, OverloadedMethod(_)).WillByDefault(...);
// ON_CALL(mock, OverloadedMethod(_, _)).WillByDefault(); // ON_CALL(mock, OverloadedMethod(_, _)).WillByDefault(...);
// //
// // Oops! Which overload did you want? // // Oops! Which overload did you want?
// ON_CALL(mock, OverloadedMethod).WillByDefault(); // ON_CALL(mock, OverloadedMethod).WillByDefault(...);
// => ERROR: call to member function 'gmock_OverloadedMethod' is ambiguous // => ERROR: call to member function 'gmock_OverloadedMethod' is ambiguous
// //
// How this works: The mock class uses two overloads of the gmock_Method // How this works: The mock class uses two overloads of the gmock_Method
@ -1877,28 +1877,28 @@ inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
// In the matcher list form, the macro expands to: // In the matcher list form, the macro expands to:
// //
// // This statement: // // This statement:
// ON_CALL(mock, TwoArgsMethod(_, 45)) // ON_CALL(mock, TwoArgsMethod(_, 45))...
// //
// // expands to: // // ...expands to:
// mock.gmock_TwoArgsMethod(_, 45)(WithoutMatchers(), nullptr) // mock.gmock_TwoArgsMethod(_, 45)(WithoutMatchers(), nullptr)...
// |-------------v---------------||------------v-------------| // |-------------v---------------||------------v-------------|
// invokes first overload swallowed by operator() // invokes first overload swallowed by operator()
// //
// // which is essentially: // // ...which is essentially:
// mock.gmock_TwoArgsMethod(_, 45) // mock.gmock_TwoArgsMethod(_, 45)...
// //
// Whereas the form without a matcher list: // Whereas the form without a matcher list:
// //
// // This statement: // // This statement:
// ON_CALL(mock, TwoArgsMethod) // ON_CALL(mock, TwoArgsMethod)...
// //
// // expands to: // // ...expands to:
// mock.gmock_TwoArgsMethod(WithoutMatchers(), nullptr) // mock.gmock_TwoArgsMethod(WithoutMatchers(), nullptr)...
// |-----------------------v--------------------------| // |-----------------------v--------------------------|
// invokes second overload // invokes second overload
// //
// // which is essentially: // // ...which is essentially:
// mock.gmock_TwoArgsMethod(_, _) // mock.gmock_TwoArgsMethod(_, _)...
// //
// The WithoutMatchers() argument is used to disambiguate overloads and to // The WithoutMatchers() argument is used to disambiguate overloads and to
// block the caller from accidentally invoking the second overload directly. The // block the caller from accidentally invoking the second overload directly. The

View File

@ -32,7 +32,7 @@
// ============================================================ // ============================================================
// //
// Adds google3 callback support to CallableTraits. // Adds google3 callback support to CallableTraits.
//
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_ #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_ #define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_ #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_

View File

@ -348,7 +348,7 @@ GTEST_API_ void Log(LogSeverity severity, const std::string& message,
// correct overload. This must not be instantiable, to prevent client code from // correct overload. This must not be instantiable, to prevent client code from
// accidentally resolving to the overload; for example: // accidentally resolving to the overload; for example:
// //
// ON_CALL(mock, Method({}, nullptr)) // ON_CALL(mock, Method({}, nullptr))...
// //
class WithoutMatchers { class WithoutMatchers {
private: private:

View File

@ -88,10 +88,6 @@ using testing::tuple_element;
using testing::SetErrnoAndReturn; using testing::SetErrnoAndReturn;
#endif #endif
#if GTEST_HAS_PROTOBUF_
using testing::internal::TestMessage;
#endif // GTEST_HAS_PROTOBUF_
// Tests that BuiltInDefaultValue<T*>::Get() returns NULL. // Tests that BuiltInDefaultValue<T*>::Get() returns NULL.
TEST(BuiltInDefaultValueTest, IsNullForPointerTypes) { TEST(BuiltInDefaultValueTest, IsNullForPointerTypes) {
EXPECT_TRUE(BuiltInDefaultValue<int*>::Get() == NULL); EXPECT_TRUE(BuiltInDefaultValue<int*>::Get() == NULL);
@ -895,105 +891,6 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
# endif # endif
} }
#if GTEST_HAS_PROTOBUF_
// Tests that SetArgPointee<N>(proto_buffer) sets the v1 protobuf
// variable pointed to by the N-th (0-based) argument to proto_buffer.
TEST(SetArgPointeeTest, SetsTheNthPointeeOfProtoBufferType) {
TestMessage* const msg = new TestMessage;
msg->set_member("yes");
TestMessage orig_msg;
orig_msg.CopyFrom(*msg);
Action<void(bool, TestMessage*)> a = SetArgPointee<1>(*msg);
// SetArgPointee<N>(proto_buffer) makes a copy of proto_buffer
// s.t. the action works even when the original proto_buffer has
// died. We ensure this behavior by deleting msg before using the
// action.
delete msg;
TestMessage dest;
EXPECT_FALSE(orig_msg.Equals(dest));
a.Perform(make_tuple(true, &dest));
EXPECT_TRUE(orig_msg.Equals(dest));
}
// Tests that SetArgPointee<N>(proto_buffer) sets the
// ::ProtocolMessage variable pointed to by the N-th (0-based)
// argument to proto_buffer.
TEST(SetArgPointeeTest, SetsTheNthPointeeOfProtoBufferBaseType) {
TestMessage* const msg = new TestMessage;
msg->set_member("yes");
TestMessage orig_msg;
orig_msg.CopyFrom(*msg);
Action<void(bool, ::ProtocolMessage*)> a = SetArgPointee<1>(*msg);
// SetArgPointee<N>(proto_buffer) makes a copy of proto_buffer
// s.t. the action works even when the original proto_buffer has
// died. We ensure this behavior by deleting msg before using the
// action.
delete msg;
TestMessage dest;
::ProtocolMessage* const dest_base = &dest;
EXPECT_FALSE(orig_msg.Equals(dest));
a.Perform(make_tuple(true, dest_base));
EXPECT_TRUE(orig_msg.Equals(dest));
}
// Tests that SetArgPointee<N>(proto2_buffer) sets the v2
// protobuf variable pointed to by the N-th (0-based) argument to
// proto2_buffer.
TEST(SetArgPointeeTest, SetsTheNthPointeeOfProto2BufferType) {
using testing::internal::FooMessage;
FooMessage* const msg = new FooMessage;
msg->set_int_field(2);
msg->set_string_field("hi");
FooMessage orig_msg;
orig_msg.CopyFrom(*msg);
Action<void(bool, FooMessage*)> a = SetArgPointee<1>(*msg);
// SetArgPointee<N>(proto2_buffer) makes a copy of
// proto2_buffer s.t. the action works even when the original
// proto2_buffer has died. We ensure this behavior by deleting msg
// before using the action.
delete msg;
FooMessage dest;
dest.set_int_field(0);
a.Perform(make_tuple(true, &dest));
EXPECT_EQ(2, dest.int_field());
EXPECT_EQ("hi", dest.string_field());
}
// Tests that SetArgPointee<N>(proto2_buffer) sets the
// proto2::Message variable pointed to by the N-th (0-based) argument
// to proto2_buffer.
TEST(SetArgPointeeTest, SetsTheNthPointeeOfProto2BufferBaseType) {
using testing::internal::FooMessage;
FooMessage* const msg = new FooMessage;
msg->set_int_field(2);
msg->set_string_field("hi");
FooMessage orig_msg;
orig_msg.CopyFrom(*msg);
Action<void(bool, ::proto2::Message*)> a = SetArgPointee<1>(*msg);
// SetArgPointee<N>(proto2_buffer) makes a copy of
// proto2_buffer s.t. the action works even when the original
// proto2_buffer has died. We ensure this behavior by deleting msg
// before using the action.
delete msg;
FooMessage dest;
dest.set_int_field(0);
::proto2::Message* const dest_base = &dest;
a.Perform(make_tuple(true, dest_base));
EXPECT_EQ(2, dest.int_field());
EXPECT_EQ("hi", dest.string_field());
}
#endif // GTEST_HAS_PROTOBUF_
// Tests that SetArgumentPointee<N>(v) sets the variable pointed to by // Tests that SetArgumentPointee<N>(v) sets the variable pointed to by
// the N-th (0-based) argument to v. // the N-th (0-based) argument to v.
TEST(SetArgumentPointeeTest, SetsTheNthPointee) { TEST(SetArgumentPointeeTest, SetsTheNthPointee) {
@ -1014,105 +911,6 @@ TEST(SetArgumentPointeeTest, SetsTheNthPointee) {
EXPECT_EQ('a', ch); EXPECT_EQ('a', ch);
} }
#if GTEST_HAS_PROTOBUF_
// Tests that SetArgumentPointee<N>(proto_buffer) sets the v1 protobuf
// variable pointed to by the N-th (0-based) argument to proto_buffer.
TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProtoBufferType) {
TestMessage* const msg = new TestMessage;
msg->set_member("yes");
TestMessage orig_msg;
orig_msg.CopyFrom(*msg);
Action<void(bool, TestMessage*)> a = SetArgumentPointee<1>(*msg);
// SetArgumentPointee<N>(proto_buffer) makes a copy of proto_buffer
// s.t. the action works even when the original proto_buffer has
// died. We ensure this behavior by deleting msg before using the
// action.
delete msg;
TestMessage dest;
EXPECT_FALSE(orig_msg.Equals(dest));
a.Perform(make_tuple(true, &dest));
EXPECT_TRUE(orig_msg.Equals(dest));
}
// Tests that SetArgumentPointee<N>(proto_buffer) sets the
// ::ProtocolMessage variable pointed to by the N-th (0-based)
// argument to proto_buffer.
TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProtoBufferBaseType) {
TestMessage* const msg = new TestMessage;
msg->set_member("yes");
TestMessage orig_msg;
orig_msg.CopyFrom(*msg);
Action<void(bool, ::ProtocolMessage*)> a = SetArgumentPointee<1>(*msg);
// SetArgumentPointee<N>(proto_buffer) makes a copy of proto_buffer
// s.t. the action works even when the original proto_buffer has
// died. We ensure this behavior by deleting msg before using the
// action.
delete msg;
TestMessage dest;
::ProtocolMessage* const dest_base = &dest;
EXPECT_FALSE(orig_msg.Equals(dest));
a.Perform(make_tuple(true, dest_base));
EXPECT_TRUE(orig_msg.Equals(dest));
}
// Tests that SetArgumentPointee<N>(proto2_buffer) sets the v2
// protobuf variable pointed to by the N-th (0-based) argument to
// proto2_buffer.
TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProto2BufferType) {
using testing::internal::FooMessage;
FooMessage* const msg = new FooMessage;
msg->set_int_field(2);
msg->set_string_field("hi");
FooMessage orig_msg;
orig_msg.CopyFrom(*msg);
Action<void(bool, FooMessage*)> a = SetArgumentPointee<1>(*msg);
// SetArgumentPointee<N>(proto2_buffer) makes a copy of
// proto2_buffer s.t. the action works even when the original
// proto2_buffer has died. We ensure this behavior by deleting msg
// before using the action.
delete msg;
FooMessage dest;
dest.set_int_field(0);
a.Perform(make_tuple(true, &dest));
EXPECT_EQ(2, dest.int_field());
EXPECT_EQ("hi", dest.string_field());
}
// Tests that SetArgumentPointee<N>(proto2_buffer) sets the
// proto2::Message variable pointed to by the N-th (0-based) argument
// to proto2_buffer.
TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProto2BufferBaseType) {
using testing::internal::FooMessage;
FooMessage* const msg = new FooMessage;
msg->set_int_field(2);
msg->set_string_field("hi");
FooMessage orig_msg;
orig_msg.CopyFrom(*msg);
Action<void(bool, ::proto2::Message*)> a = SetArgumentPointee<1>(*msg);
// SetArgumentPointee<N>(proto2_buffer) makes a copy of
// proto2_buffer s.t. the action works even when the original
// proto2_buffer has died. We ensure this behavior by deleting msg
// before using the action.
delete msg;
FooMessage dest;
dest.set_int_field(0);
::proto2::Message* const dest_base = &dest;
a.Perform(make_tuple(true, dest_base));
EXPECT_EQ(2, dest.int_field());
EXPECT_EQ("hi", dest.string_field());
}
#endif // GTEST_HAS_PROTOBUF_
// Sample functions and functors for testing Invoke() and etc. // Sample functions and functors for testing Invoke() and etc.
int Nullary() { return 1; } int Nullary() { return 1; }

View File

@ -2680,7 +2680,7 @@ TEST(AllOfTest, ExplainsResult) {
} }
// Helper to allow easy testing of AnyOf matchers with num parameters. // Helper to allow easy testing of AnyOf matchers with num parameters.
void AnyOfMatches(int num, const Matcher<int>& m) { static void AnyOfMatches(int num, const Matcher<int>& m) {
SCOPED_TRACE(Describe(m)); SCOPED_TRACE(Describe(m));
EXPECT_FALSE(m.Matches(0)); EXPECT_FALSE(m.Matches(0));
for (int i = 1; i <= num; ++i) { for (int i = 1; i <= num; ++i) {
@ -2689,6 +2689,18 @@ void AnyOfMatches(int num, const Matcher<int>& m) {
EXPECT_FALSE(m.Matches(num + 1)); EXPECT_FALSE(m.Matches(num + 1));
} }
#if GTEST_LANG_CXX11
static void AnyOfStringMatches(int num, const Matcher<std::string>& m) {
SCOPED_TRACE(Describe(m));
EXPECT_FALSE(m.Matches(std::to_string(0)));
for (int i = 1; i <= num; ++i) {
EXPECT_TRUE(m.Matches(std::to_string(i)));
}
EXPECT_FALSE(m.Matches(std::to_string(num + 1)));
}
#endif
// Tests that AnyOf(m1, ..., mn) matches any value that matches at // Tests that AnyOf(m1, ..., mn) matches any value that matches at
// least one of the given matchers. // least one of the given matchers.
TEST(AnyOfTest, MatchesWhenAnyMatches) { TEST(AnyOfTest, MatchesWhenAnyMatches) {
@ -2746,6 +2758,12 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50)); 41, 42, 43, 44, 45, 46, 47, 48, 49, 50));
AnyOfStringMatches(
50, AnyOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
"13", "14", "15", "16", "17", "18", "19", "20", "21", "22",
"23", "24", "25", "26", "27", "28", "29", "30", "31", "32",
"33", "34", "35", "36", "37", "38", "39", "40", "41", "42",
"43", "44", "45", "46", "47", "48", "49", "50"));
} }
// Tests the variadic version of the ElementsAreMatcher // Tests the variadic version of the ElementsAreMatcher
@ -4220,13 +4238,17 @@ TEST(PropertyTest, WorksForReferenceToConstProperty) {
// ref-qualified. // ref-qualified.
TEST(PropertyTest, WorksForRefQualifiedProperty) { TEST(PropertyTest, WorksForRefQualifiedProperty) {
Matcher<const AClass&> m = Property(&AClass::s_ref, StartsWith("hi")); Matcher<const AClass&> m = Property(&AClass::s_ref, StartsWith("hi"));
Matcher<const AClass&> m_with_name =
Property("s", &AClass::s_ref, StartsWith("hi"));
AClass a; AClass a;
a.set_s("hill"); a.set_s("hill");
EXPECT_TRUE(m.Matches(a)); EXPECT_TRUE(m.Matches(a));
EXPECT_TRUE(m_with_name.Matches(a));
a.set_s("hole"); a.set_s("hole");
EXPECT_FALSE(m.Matches(a)); EXPECT_FALSE(m.Matches(a));
EXPECT_FALSE(m_with_name.Matches(a));
} }
#endif #endif
@ -4570,7 +4592,7 @@ TEST(ResultOfTest, WorksForFunctors) {
} }
// Tests that ResultOf(f, ...) compiles and works as expected when f is a // Tests that ResultOf(f, ...) compiles and works as expected when f is a
// functor with more then one operator() defined. ResultOf() must work // functor with more than one operator() defined. ResultOf() must work
// for each defined operator(). // for each defined operator().
struct PolymorphicFunctor { struct PolymorphicFunctor {
typedef int result_type; typedef int result_type;
@ -6764,4 +6786,3 @@ TEST(NotTest, WorksOnMoveOnlyType) {
} // namespace gmock_matchers_test } // namespace gmock_matchers_test
} // namespace testing } // namespace testing

View File

@ -34,9 +34,11 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#if GTEST_HAS_EXCEPTIONS
namespace { namespace {
using testing::HasSubstr; using testing::HasSubstr;
using testing::internal::GoogleTestFailureException; using testing::internal::GoogleTestFailureException;
// A type that cannot be default constructed. // A type that cannot be default constructed.
@ -52,8 +54,6 @@ class MockFoo {
MOCK_METHOD0(GetNonDefaultConstructible, NonDefaultConstructible()); MOCK_METHOD0(GetNonDefaultConstructible, NonDefaultConstructible());
}; };
#if GTEST_HAS_EXCEPTIONS
TEST(DefaultValueTest, ThrowsRuntimeErrorWhenNoDefaultValue) { TEST(DefaultValueTest, ThrowsRuntimeErrorWhenNoDefaultValue) {
MockFoo mock; MockFoo mock;
try { try {
@ -76,6 +76,6 @@ TEST(DefaultValueTest, ThrowsRuntimeErrorWhenNoDefaultValue) {
} }
} }
#endif
} // unnamed namespace } // unnamed namespace
#endif

View File

@ -284,7 +284,7 @@ if (gtest_build_tests)
py_test(gtest_list_tests_unittest) py_test(gtest_list_tests_unittest)
cxx_executable(gtest_output_test_ test gtest) cxx_executable(gtest_output_test_ test gtest)
py_test(gtest_output_test) py_test(gtest_output_test --no_stacktrace_support)
cxx_executable(gtest_shuffle_test_ test gtest) cxx_executable(gtest_shuffle_test_ test gtest)
py_test(gtest_shuffle_test) py_test(gtest_shuffle_test)
@ -307,6 +307,6 @@ if (gtest_build_tests)
py_test(gtest_json_outfiles_test) py_test(gtest_json_outfiles_test)
cxx_executable(gtest_xml_output_unittest_ test gtest) cxx_executable(gtest_xml_output_unittest_ test gtest)
py_test(gtest_xml_output_unittest) py_test(gtest_xml_output_unittest --no_stacktrace_support)
py_test(gtest_json_output_unittest) py_test(gtest_json_output_unittest)
endif() endif()

View File

@ -257,14 +257,14 @@ function(py_test name)
add_test( add_test(
NAME ${name} NAME ${name}
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>) --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG> ${ARGN})
else (CMAKE_CONFIGURATION_TYPES) else (CMAKE_CONFIGURATION_TYPES)
# Single-configuration build generators like Makefile generators # Single-configuration build generators like Makefile generators
# don't have subdirs below CMAKE_CURRENT_BINARY_DIR. # don't have subdirs below CMAKE_CURRENT_BINARY_DIR.
add_test( add_test(
NAME ${name} NAME ${name}
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
--build_dir=${CMAKE_CURRENT_BINARY_DIR}) --build_dir=${CMAKE_CURRENT_BINARY_DIR} ${ARGN})
endif (CMAKE_CONFIGURATION_TYPES) endif (CMAKE_CONFIGURATION_TYPES)
else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
# ${CMAKE_CURRENT_BINARY_DIR} is known at configuration time, so we can # ${CMAKE_CURRENT_BINARY_DIR} is known at configuration time, so we can
@ -274,7 +274,7 @@ function(py_test name)
add_test( add_test(
${name} ${name}
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE}) --build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE} ${ARGN})
endif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) endif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
endif(PYTHONINTERP_FOUND) endif(PYTHONINTERP_FOUND)
endfunction() endfunction()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
# Googletest Primer # Googletest Primer
## Introduction: Why googletest? ## Introduction: Why googletest?
*googletest* helps you write better C++ tests. *googletest* helps you write better C++ tests.
@ -197,7 +198,7 @@ objects, you should use `ASSERT_EQ`.
When doing pointer comparisons use `*_EQ(ptr, nullptr)` and `*_NE(ptr, nullptr)` When doing pointer comparisons use `*_EQ(ptr, nullptr)` and `*_NE(ptr, nullptr)`
instead of `*_EQ(ptr, NULL)` and `*_NE(ptr, NULL)`. This is because `nullptr` is instead of `*_EQ(ptr, NULL)` and `*_NE(ptr, NULL)`. This is because `nullptr` is
typed while `NULL` is not. See [FAQ](faq#Why_does_googletest_support_EXPECT_EQ) typed while `NULL` is not. See [FAQ](faq.md#why-does-google-test-support-expect_eqnull-ptr-and-assert_eqnull-ptr-but-not-expect_nenull-ptr-and-assert_nenull-ptr)
for more details. for more details.
If you're working with floating point numbers, you may want to use the floating If you're working with floating point numbers, you may want to use the floating
@ -322,7 +323,7 @@ To create a fixture:
1. If necessary, write a destructor or `TearDown()` function to release any 1. If necessary, write a destructor or `TearDown()` function to release any
resources you allocated in `SetUp()` . To learn when you should use the resources you allocated in `SetUp()` . To learn when you should use the
constructor/destructor and when you should use `SetUp()/TearDown()`, read constructor/destructor and when you should use `SetUp()/TearDown()`, read
this [FAQ](faq#CtorVsSetUp) entry. this [FAQ](faq.md#should-i-use-the-constructordestructor-of-the-test-fixture-or-the-set-uptear-down-function) entry.
1. If needed, define subroutines for your tests to share. 1. If needed, define subroutines for your tests to share.
When using a fixture, use `TEST_F()` instead of `TEST()` as it allows you to When using a fixture, use `TEST_F()` instead of `TEST()` as it allows you to
@ -436,6 +437,7 @@ When these tests run, the following happens:
**Availability**: Linux, Windows, Mac. **Availability**: Linux, Windows, Mac.
## Invoking the Tests ## Invoking the Tests
`TEST()` and `TEST_F()` implicitly register their tests with googletest. So, `TEST()` and `TEST_F()` implicitly register their tests with googletest. So,
@ -544,6 +546,7 @@ int main(int argc, char **argv) {
} }
``` ```
The `::testing::InitGoogleTest()` function parses the command line for The `::testing::InitGoogleTest()` function parses the command line for
googletest flags, and removes all recognized flags. This allows the user to googletest flags, and removes all recognized flags. This allows the user to
control a test program's behavior via various flags, which we'll cover in control a test program's behavior via various flags, which we'll cover in
@ -560,6 +563,7 @@ gtest\_main library and you are good to go.
NOTE: `ParseGUnitFlags()` is deprecated in favor of `InitGoogleTest()`. NOTE: `ParseGUnitFlags()` is deprecated in favor of `InitGoogleTest()`.
## Known Limitations ## Known Limitations
* Google Test is designed to be thread-safe. The implementation is thread-safe * Google Test is designed to be thread-safe. The implementation is thread-safe

View File

@ -114,6 +114,7 @@
#if GTEST_HAS_ABSL #if GTEST_HAS_ABSL
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "absl/types/variant.h"
#endif // GTEST_HAS_ABSL #endif // GTEST_HAS_ABSL
namespace testing { namespace testing {
@ -787,6 +788,28 @@ class UniversalPrinter<::absl::optional<T>> {
} }
}; };
// Printer for absl::variant
template <typename... T>
class UniversalPrinter<::absl::variant<T...>> {
public:
static void Print(const ::absl::variant<T...>& value, ::std::ostream* os) {
*os << '(';
absl::visit(Visitor{os}, value);
*os << ')';
}
private:
struct Visitor {
template <typename U>
void operator()(const U& u) const {
*os << "'" << GetTypeName<U>() << "' with value ";
UniversalPrint(u, os);
}
::std::ostream* os;
};
};
#endif // GTEST_HAS_ABSL #endif // GTEST_HAS_ABSL
// UniversalPrintArray(begin, len, os) prints an array of 'len' // UniversalPrintArray(begin, len, os) prints an array of 'len'

View File

@ -522,11 +522,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#endif // !defined(GTEST_HAS_STD_STRING) #endif // !defined(GTEST_HAS_STD_STRING)
#ifndef GTEST_HAS_GLOBAL_STRING #ifndef GTEST_HAS_GLOBAL_STRING
// The user didn't tell us whether ::string is available, so we need
// to figure it out.
# define GTEST_HAS_GLOBAL_STRING 0 # define GTEST_HAS_GLOBAL_STRING 0
#endif // GTEST_HAS_GLOBAL_STRING #endif // GTEST_HAS_GLOBAL_STRING
#ifndef GTEST_HAS_STD_WSTRING #ifndef GTEST_HAS_STD_WSTRING
@ -1218,7 +1214,7 @@ class scoped_ptr {
// Defines RE. // Defines RE.
#if GTEST_USES_PCRE #if GTEST_USES_PCRE
using ::RE; // if used, PCRE is injected by custom/gtest-port.h
#elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE #elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE
// A simple C++ wrapper for <regex.h>. It uses the POSIX Extended // A simple C++ wrapper for <regex.h>. It uses the POSIX Extended

View File

@ -446,6 +446,16 @@ class OsStackTraceGetter : public OsStackTraceGetterInterface {
virtual void UponLeavingGTest(); virtual void UponLeavingGTest();
private: private:
#if GTEST_HAS_ABSL
Mutex mutex_; // Protects all internal state.
// We save the stack frame below the frame that calls user code.
// We do this because the address of the frame immediately below
// the user code changes between the call to UponLeavingGTest()
// and any calls to the stack trace code from within the user code.
void* caller_frame_ = nullptr;
#endif // GTEST_HAS_ABSL
GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter); GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter);
}; };

View File

@ -139,6 +139,13 @@
# define vsnprintf _vsnprintf # define vsnprintf _vsnprintf
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
#if GTEST_HAS_ABSL
#include "absl/debugging/failure_signal_handler.h"
#include "absl/debugging/stacktrace.h"
#include "absl/debugging/symbolize.h"
#include "absl/strings/str_cat.h"
#endif // GTEST_HAS_ABSL
namespace testing { namespace testing {
using internal::CountIf; using internal::CountIf;
@ -228,6 +235,13 @@ GTEST_DEFINE_string_(
"exclude). A test is run if it matches one of the positive " "exclude). A test is run if it matches one of the positive "
"patterns and does not match any of the negative patterns."); "patterns and does not match any of the negative patterns.");
GTEST_DEFINE_bool_(
install_failure_signal_handler,
internal::BoolFromGTestEnv("install_failure_signal_handler", false),
"If true and supported on the current platform, " GTEST_NAME_ " should "
"install a signal handler that dumps debugging information when fatal "
"signals are raised.");
GTEST_DEFINE_bool_(list_tests, false, GTEST_DEFINE_bool_(list_tests, false,
"List all tests without running them."); "List all tests without running them.");
@ -4243,12 +4257,67 @@ void StreamingListener::SocketWriter::MakeConnection() {
const char* const OsStackTraceGetterInterface::kElidedFramesMarker = const char* const OsStackTraceGetterInterface::kElidedFramesMarker =
"... " GTEST_NAME_ " internal frames ..."; "... " GTEST_NAME_ " internal frames ...";
std::string OsStackTraceGetter::CurrentStackTrace(int /*max_depth*/, std::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count)
int /*skip_count*/) { GTEST_LOCK_EXCLUDED_(mutex_) {
#if GTEST_HAS_ABSL
std::string result;
if (max_depth <= 0) {
return result;
}
max_depth = std::min(max_depth, kMaxStackTraceDepth);
std::vector<void*> raw_stack(max_depth);
// Skips the frames requested by the caller, plus this function.
const int raw_stack_size =
absl::GetStackTrace(&raw_stack[0], max_depth, skip_count + 1);
void* caller_frame = nullptr;
{
MutexLock lock(&mutex_);
caller_frame = caller_frame_;
}
for (int i = 0; i < raw_stack_size; ++i) {
if (raw_stack[i] == caller_frame &&
!GTEST_FLAG(show_internal_stack_frames)) {
// Add a marker to the trace and stop adding frames.
absl::StrAppend(&result, kElidedFramesMarker, "\n");
break;
}
char tmp[1024];
const char* symbol = "(unknown)";
if (absl::Symbolize(raw_stack[i], tmp, sizeof(tmp))) {
symbol = tmp;
}
char line[1024];
snprintf(line, sizeof(line), " %p: %s\n", raw_stack[i], symbol);
result += line;
}
return result;
#else // !GTEST_HAS_ABSL
static_cast<void>(max_depth);
static_cast<void>(skip_count);
return ""; return "";
#endif // GTEST_HAS_ABSL
} }
void OsStackTraceGetter::UponLeavingGTest() {} void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) {
#if GTEST_HAS_ABSL
void* caller_frame = nullptr;
if (absl::GetStackTrace(&caller_frame, 1, 3) <= 0) {
caller_frame = nullptr;
}
MutexLock lock(&mutex_);
caller_frame_ = caller_frame;
#endif // GTEST_HAS_ABSL
}
// A helper class that creates the premature-exit file in its // A helper class that creates the premature-exit file in its
// constructor and deletes the file in its destructor. // constructor and deletes the file in its destructor.
@ -4865,6 +4934,13 @@ void UnitTestImpl::PostFlagParsingInit() {
// Configures listeners for streaming test results to the specified server. // Configures listeners for streaming test results to the specified server.
ConfigureStreamingOutput(); ConfigureStreamingOutput();
#endif // GTEST_CAN_STREAM_RESULTS_ #endif // GTEST_CAN_STREAM_RESULTS_
#if GTEST_HAS_ABSL
if (GTEST_FLAG(install_failure_signal_handler)) {
absl::FailureSignalHandlerOptions options;
absl::InstallFailureSignalHandler(options);
}
#endif // GTEST_HAS_ABSL
} }
} }
@ -5769,6 +5845,10 @@ void InitGoogleTestImpl(int* argc, CharType** argv) {
g_argvs.push_back(StreamableToString(argv[i])); g_argvs.push_back(StreamableToString(argv[i]));
} }
#if GTEST_HAS_ABSL
absl::InitializeSymbolizer(g_argvs[0].c_str());
#endif // GTEST_HAS_ABSL
ParseGoogleTestFlagsOnly(argc, argv); ParseGoogleTestFlagsOnly(argc, argv);
GetUnitTestImpl()->PostFlagParsingInit(); GetUnitTestImpl()->PostFlagParsingInit();
} }

View File

@ -34,7 +34,20 @@
licenses(["notice"]) licenses(["notice"])
""" gtest own tests """ config_setting(
name = "windows",
values = {"cpu": "x64_windows"},
)
config_setting(
name = "windows_msvc",
values = {"cpu": "x64_windows_msvc"},
)
config_setting(
name = "has_absl",
values = {"define": "absl=1"},
)
#on windows exclude gtest-tuple.h and gtest-tuple_test.cc #on windows exclude gtest-tuple.h and gtest-tuple_test.cc
cc_test( cc_test(
@ -135,7 +148,6 @@ py_library(
name = "gtest_test_utils", name = "gtest_test_utils",
testonly = 1, testonly = 1,
srcs = ["gtest_test_utils.py"], srcs = ["gtest_test_utils.py"],
) )
cc_binary( cc_binary(
@ -144,6 +156,7 @@ cc_binary(
srcs = ["gtest_help_test_.cc"], srcs = ["gtest_help_test_.cc"],
deps = ["//:gtest_main"], deps = ["//:gtest_main"],
) )
py_test( py_test(
name = "gtest_help_test", name = "gtest_help_test",
size = "small", size = "small",
@ -163,6 +176,10 @@ py_test(
name = "gtest_output_test", name = "gtest_output_test",
size = "small", size = "small",
srcs = ["gtest_output_test.py"], srcs = ["gtest_output_test.py"],
args = select({
":has_absl": [],
"//conditions:default": ["--no_stacktrace_support"],
}),
data = [ data = [
"gtest_output_test_golden_lin.txt", "gtest_output_test_golden_lin.txt",
":gtest_output_test_", ":gtest_output_test_",
@ -176,6 +193,7 @@ cc_binary(
srcs = ["gtest_color_test_.cc"], srcs = ["gtest_color_test_.cc"],
deps = ["//:gtest"], deps = ["//:gtest"],
) )
py_test( py_test(
name = "gtest_color_test", name = "gtest_color_test",
size = "small", size = "small",
@ -327,6 +345,10 @@ py_test(
"gtest_xml_output_unittest.py", "gtest_xml_output_unittest.py",
"gtest_xml_test_utils.py", "gtest_xml_test_utils.py",
], ],
args = select({
":has_absl": [],
"//conditions:default": ["--no_stacktrace_support"],
}),
data = [ data = [
# We invoke gtest_no_test_unittest to verify the XML output # We invoke gtest_no_test_unittest to verify the XML output
# when the test program contains no test definition. # when the test program contains no test definition.

View File

@ -52,6 +52,9 @@ import gtest_test_utils
GENGOLDEN_FLAG = '--gengolden' GENGOLDEN_FLAG = '--gengolden'
CATCH_EXCEPTIONS_ENV_VAR_NAME = 'GTEST_CATCH_EXCEPTIONS' CATCH_EXCEPTIONS_ENV_VAR_NAME = 'GTEST_CATCH_EXCEPTIONS'
# The flag indicating stacktraces are not supported
NO_STACKTRACE_SUPPORT_FLAG = '--no_stacktrace_support'
IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux' IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
IS_WINDOWS = os.name == 'nt' IS_WINDOWS = os.name == 'nt'
@ -252,13 +255,12 @@ test_list = GetShellCommandOutput(COMMAND_LIST_TESTS)
SUPPORTS_DEATH_TESTS = 'DeathTest' in test_list SUPPORTS_DEATH_TESTS = 'DeathTest' in test_list
SUPPORTS_TYPED_TESTS = 'TypedTest' in test_list SUPPORTS_TYPED_TESTS = 'TypedTest' in test_list
SUPPORTS_THREADS = 'ExpectFailureWithThreadsTest' in test_list SUPPORTS_THREADS = 'ExpectFailureWithThreadsTest' in test_list
SUPPORTS_STACK_TRACES = IS_LINUX SUPPORTS_STACK_TRACES = NO_STACKTRACE_SUPPORT_FLAG not in sys.argv
CAN_GENERATE_GOLDEN_FILE = (SUPPORTS_DEATH_TESTS and CAN_GENERATE_GOLDEN_FILE = (SUPPORTS_DEATH_TESTS and
SUPPORTS_TYPED_TESTS and SUPPORTS_TYPED_TESTS and
SUPPORTS_THREADS and SUPPORTS_THREADS and
SUPPORTS_STACK_TRACES and SUPPORTS_STACK_TRACES)
not IS_WINDOWS)
class GTestOutputTest(gtest_test_utils.TestCase): class GTestOutputTest(gtest_test_utils.TestCase):
def RemoveUnsupportedTests(self, test_output): def RemoveUnsupportedTests(self, test_output):
@ -325,7 +327,11 @@ class GTestOutputTest(gtest_test_utils.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
if sys.argv[1:] == [GENGOLDEN_FLAG]: if NO_STACKTRACE_SUPPORT_FLAG in sys.argv:
# unittest.main() can't handle unknown flags
sys.argv.remove(NO_STACKTRACE_SUPPORT_FLAG)
if GENGOLDEN_FLAG in sys.argv:
if CAN_GENERATE_GOLDEN_FILE: if CAN_GENERATE_GOLDEN_FILE:
output = GetOutputOfAllCommands() output = GetOutputOfAllCommands()
golden_file = open(GOLDEN_PATH, 'wb') golden_file = open(GOLDEN_PATH, 'wb')

View File

@ -4,10 +4,14 @@ gtest_output_test_.cc:#: Failure
Value of: false Value of: false
Actual: false Actual: false
Expected: true Expected: true
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected equality of these values: Expected equality of these values:
2 2
3 3
Stack trace: (omitted)
[==========] Running 68 tests from 30 test cases. [==========] Running 68 tests from 30 test cases.
[----------] Global test environment set-up. [----------] Global test environment set-up.
FooEnvironment::SetUp() called. FooEnvironment::SetUp() called.
@ -40,12 +44,16 @@ Expected equality of these values:
Which is: "\"Line" Which is: "\"Line"
actual actual
Which is: "actual \"string\"" Which is: "actual \"string\""
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected equality of these values: Expected equality of these values:
golden golden
Which is: "\"Line" Which is: "\"Line"
actual actual
Which is: "actual \"string\"" Which is: "actual \"string\""
Stack trace: (omitted)
[ FAILED ] NonfatalFailureTest.EscapesStringOperands [ FAILED ] NonfatalFailureTest.EscapesStringOperands
[ RUN ] NonfatalFailureTest.DiffForLongStrings [ RUN ] NonfatalFailureTest.DiffForLongStrings
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
@ -58,6 +66,8 @@ With diff:
-\"Line\0 1\" -\"Line\0 1\"
Line 2 Line 2
Stack trace: (omitted)
[ FAILED ] NonfatalFailureTest.DiffForLongStrings [ FAILED ] NonfatalFailureTest.DiffForLongStrings
[----------] 3 tests from FatalFailureTest [----------] 3 tests from FatalFailureTest
[ RUN ] FatalFailureTest.FatalFailureInSubroutine [ RUN ] FatalFailureTest.FatalFailureInSubroutine
@ -67,6 +77,8 @@ Expected equality of these values:
1 1
x x
Which is: 2 Which is: 2
Stack trace: (omitted)
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine [ FAILED ] FatalFailureTest.FatalFailureInSubroutine
[ RUN ] FatalFailureTest.FatalFailureInNestedSubroutine [ RUN ] FatalFailureTest.FatalFailureInNestedSubroutine
(expecting a failure that x should be 1) (expecting a failure that x should be 1)
@ -75,6 +87,8 @@ Expected equality of these values:
1 1
x x
Which is: 2 Which is: 2
Stack trace: (omitted)
[ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine [ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine
[ RUN ] FatalFailureTest.NonfatalFailureInSubroutine [ RUN ] FatalFailureTest.NonfatalFailureInSubroutine
(expecting a failure on false) (expecting a failure on false)
@ -82,6 +96,8 @@ gtest_output_test_.cc:#: Failure
Value of: false Value of: false
Actual: false Actual: false
Expected: true Expected: true
Stack trace: (omitted)
[ FAILED ] FatalFailureTest.NonfatalFailureInSubroutine [ FAILED ] FatalFailureTest.NonfatalFailureInSubroutine
[----------] 1 test from LoggingTest [----------] 1 test from LoggingTest
[ RUN ] LoggingTest.InterleavingLoggingAndAssertions [ RUN ] LoggingTest.InterleavingLoggingAndAssertions
@ -90,10 +106,14 @@ i == 0
i == 1 i == 1
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: (3) >= (a[i]), actual: 3 vs 9 Expected: (3) >= (a[i]), actual: 3 vs 9
Stack trace: (omitted)
i == 2 i == 2
i == 3 i == 3
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: (3) >= (a[i]), actual: 3 vs 6 Expected: (3) >= (a[i]), actual: 3 vs 6
Stack trace: (omitted)
[ FAILED ] LoggingTest.InterleavingLoggingAndAssertions [ FAILED ] LoggingTest.InterleavingLoggingAndAssertions
[----------] 7 tests from SCOPED_TRACETest [----------] 7 tests from SCOPED_TRACETest
[ RUN ] SCOPED_TRACETest.AcceptedValues [ RUN ] SCOPED_TRACETest.AcceptedValues
@ -105,20 +125,28 @@ gtest_output_test_.cc:#: (null)
gtest_output_test_.cc:#: 1337 gtest_output_test_.cc:#: 1337
gtest_output_test_.cc:#: std::string gtest_output_test_.cc:#: std::string
gtest_output_test_.cc:#: literal string gtest_output_test_.cc:#: literal string
Stack trace: (omitted)
[ FAILED ] SCOPED_TRACETest.AcceptedValues [ FAILED ] SCOPED_TRACETest.AcceptedValues
[ RUN ] SCOPED_TRACETest.ObeysScopes [ RUN ] SCOPED_TRACETest.ObeysScopes
(expected to fail) (expected to fail)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
This failure is expected, and shouldn't have a trace. This failure is expected, and shouldn't have a trace.
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
This failure is expected, and should have a trace. This failure is expected, and should have a trace.
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: Expected trace gtest_output_test_.cc:#: Expected trace
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
This failure is expected, and shouldn't have a trace. This failure is expected, and shouldn't have a trace.
Stack trace: (omitted)
[ FAILED ] SCOPED_TRACETest.ObeysScopes [ FAILED ] SCOPED_TRACETest.ObeysScopes
[ RUN ] SCOPED_TRACETest.WorksInLoop [ RUN ] SCOPED_TRACETest.WorksInLoop
(expected to fail) (expected to fail)
@ -129,6 +157,8 @@ Expected equality of these values:
Which is: 1 Which is: 1
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: i = 1 gtest_output_test_.cc:#: i = 1
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected equality of these values: Expected equality of these values:
1 1
@ -136,6 +166,8 @@ Expected equality of these values:
Which is: 2 Which is: 2
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: i = 2 gtest_output_test_.cc:#: i = 2
Stack trace: (omitted)
[ FAILED ] SCOPED_TRACETest.WorksInLoop [ FAILED ] SCOPED_TRACETest.WorksInLoop
[ RUN ] SCOPED_TRACETest.WorksInSubroutine [ RUN ] SCOPED_TRACETest.WorksInSubroutine
(expected to fail) (expected to fail)
@ -146,6 +178,8 @@ Expected equality of these values:
Which is: 1 Which is: 1
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: n = 1 gtest_output_test_.cc:#: n = 1
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected equality of these values: Expected equality of these values:
1 1
@ -153,6 +187,8 @@ Expected equality of these values:
Which is: 2 Which is: 2
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: n = 2 gtest_output_test_.cc:#: n = 2
Stack trace: (omitted)
[ FAILED ] SCOPED_TRACETest.WorksInSubroutine [ FAILED ] SCOPED_TRACETest.WorksInSubroutine
[ RUN ] SCOPED_TRACETest.CanBeNested [ RUN ] SCOPED_TRACETest.CanBeNested
(expected to fail) (expected to fail)
@ -164,6 +200,8 @@ Expected equality of these values:
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: n = 2 gtest_output_test_.cc:#: n = 2
gtest_output_test_.cc:#: gtest_output_test_.cc:#:
Stack trace: (omitted)
[ FAILED ] SCOPED_TRACETest.CanBeNested [ FAILED ] SCOPED_TRACETest.CanBeNested
[ RUN ] SCOPED_TRACETest.CanBeRepeated [ RUN ] SCOPED_TRACETest.CanBeRepeated
(expected to fail) (expected to fail)
@ -172,12 +210,16 @@ Failed
This failure is expected, and should contain trace point A. This failure is expected, and should contain trace point A.
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: A gtest_output_test_.cc:#: A
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
This failure is expected, and should contain trace point A and B. This failure is expected, and should contain trace point A and B.
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: B gtest_output_test_.cc:#: B
gtest_output_test_.cc:#: A gtest_output_test_.cc:#: A
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
This failure is expected, and should contain trace point A, B, and C. This failure is expected, and should contain trace point A, B, and C.
@ -185,6 +227,8 @@ Google Test trace:
gtest_output_test_.cc:#: C gtest_output_test_.cc:#: C
gtest_output_test_.cc:#: B gtest_output_test_.cc:#: B
gtest_output_test_.cc:#: A gtest_output_test_.cc:#: A
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
This failure is expected, and should contain trace point A, B, and D. This failure is expected, and should contain trace point A, B, and D.
@ -192,6 +236,8 @@ Google Test trace:
gtest_output_test_.cc:#: D gtest_output_test_.cc:#: D
gtest_output_test_.cc:#: B gtest_output_test_.cc:#: B
gtest_output_test_.cc:#: A gtest_output_test_.cc:#: A
Stack trace: (omitted)
[ FAILED ] SCOPED_TRACETest.CanBeRepeated [ FAILED ] SCOPED_TRACETest.CanBeRepeated
[ RUN ] SCOPED_TRACETest.WorksConcurrently [ RUN ] SCOPED_TRACETest.WorksConcurrently
(expecting 6 failures) (expecting 6 failures)
@ -200,27 +246,39 @@ Failed
Expected failure #1 (in thread B, only trace B alive). Expected failure #1 (in thread B, only trace B alive).
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: Trace B gtest_output_test_.cc:#: Trace B
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #2 (in thread A, trace A & B both alive). Expected failure #2 (in thread A, trace A & B both alive).
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: Trace A gtest_output_test_.cc:#: Trace A
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #3 (in thread B, trace A & B both alive). Expected failure #3 (in thread B, trace A & B both alive).
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: Trace B gtest_output_test_.cc:#: Trace B
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #4 (in thread B, only trace A alive). Expected failure #4 (in thread B, only trace A alive).
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #5 (in thread A, only trace A alive). Expected failure #5 (in thread A, only trace A alive).
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: Trace A gtest_output_test_.cc:#: Trace A
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #6 (in thread A, no trace alive). Expected failure #6 (in thread A, no trace alive).
Stack trace: (omitted)
[ FAILED ] SCOPED_TRACETest.WorksConcurrently [ FAILED ] SCOPED_TRACETest.WorksConcurrently
[----------] 1 test from ScopedTraceTest [----------] 1 test from ScopedTraceTest
[ RUN ] ScopedTraceTest.WithExplicitFileAndLine [ RUN ] ScopedTraceTest.WithExplicitFileAndLine
@ -229,6 +287,8 @@ Failed
Check that the trace is attached to a particular location. Check that the trace is attached to a particular location.
Google Test trace: Google Test trace:
explicit_file.cc:123: expected trace message explicit_file.cc:123: expected trace message
Stack trace: (omitted)
[ FAILED ] ScopedTraceTest.WithExplicitFileAndLine [ FAILED ] ScopedTraceTest.WithExplicitFileAndLine
[----------] 1 test from NonFatalFailureInFixtureConstructorTest [----------] 1 test from NonFatalFailureInFixtureConstructorTest
[ RUN ] NonFatalFailureInFixtureConstructorTest.FailureInConstructor [ RUN ] NonFatalFailureInFixtureConstructorTest.FailureInConstructor
@ -236,18 +296,28 @@ explicit_file.cc:123: expected trace message
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #1, in the test fixture c'tor. Expected failure #1, in the test fixture c'tor.
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #2, in SetUp(). Expected failure #2, in SetUp().
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #3, in the test body. Expected failure #3, in the test body.
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #4, in TearDown. Expected failure #4, in TearDown.
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #5, in the test fixture d'tor. Expected failure #5, in the test fixture d'tor.
Stack trace: (omitted)
[ FAILED ] NonFatalFailureInFixtureConstructorTest.FailureInConstructor [ FAILED ] NonFatalFailureInFixtureConstructorTest.FailureInConstructor
[----------] 1 test from FatalFailureInFixtureConstructorTest [----------] 1 test from FatalFailureInFixtureConstructorTest
[ RUN ] FatalFailureInFixtureConstructorTest.FailureInConstructor [ RUN ] FatalFailureInFixtureConstructorTest.FailureInConstructor
@ -255,9 +325,13 @@ Expected failure #5, in the test fixture d'tor.
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #1, in the test fixture c'tor. Expected failure #1, in the test fixture c'tor.
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #2, in the test fixture d'tor. Expected failure #2, in the test fixture d'tor.
Stack trace: (omitted)
[ FAILED ] FatalFailureInFixtureConstructorTest.FailureInConstructor [ FAILED ] FatalFailureInFixtureConstructorTest.FailureInConstructor
[----------] 1 test from NonFatalFailureInSetUpTest [----------] 1 test from NonFatalFailureInSetUpTest
[ RUN ] NonFatalFailureInSetUpTest.FailureInSetUp [ RUN ] NonFatalFailureInSetUpTest.FailureInSetUp
@ -265,15 +339,23 @@ Expected failure #2, in the test fixture d'tor.
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #1, in SetUp(). Expected failure #1, in SetUp().
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #2, in the test function. Expected failure #2, in the test function.
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #3, in TearDown(). Expected failure #3, in TearDown().
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #4, in the test fixture d'tor. Expected failure #4, in the test fixture d'tor.
Stack trace: (omitted)
[ FAILED ] NonFatalFailureInSetUpTest.FailureInSetUp [ FAILED ] NonFatalFailureInSetUpTest.FailureInSetUp
[----------] 1 test from FatalFailureInSetUpTest [----------] 1 test from FatalFailureInSetUpTest
[ RUN ] FatalFailureInSetUpTest.FailureInSetUp [ RUN ] FatalFailureInSetUpTest.FailureInSetUp
@ -281,18 +363,26 @@ Expected failure #4, in the test fixture d'tor.
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #1, in SetUp(). Expected failure #1, in SetUp().
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #2, in TearDown(). Expected failure #2, in TearDown().
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected failure #3, in the test fixture d'tor. Expected failure #3, in the test fixture d'tor.
Stack trace: (omitted)
[ FAILED ] FatalFailureInSetUpTest.FailureInSetUp [ FAILED ] FatalFailureInSetUpTest.FailureInSetUp
[----------] 1 test from AddFailureAtTest [----------] 1 test from AddFailureAtTest
[ RUN ] AddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber [ RUN ] AddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
foo.cc:42: Failure foo.cc:42: Failure
Failed Failed
Expected failure in foo.cc Expected failure in foo.cc
Stack trace: (omitted)
[ FAILED ] AddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber [ FAILED ] AddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
[----------] 4 tests from MixedUpTestCaseTest [----------] 4 tests from MixedUpTestCaseTest
[ RUN ] MixedUpTestCaseTest.FirstTestFromNamespaceFoo [ RUN ] MixedUpTestCaseTest.FirstTestFromNamespaceFoo
@ -309,6 +399,8 @@ using two different test fixture classes. This can happen if
the two classes are from different namespaces or translation the two classes are from different namespaces or translation
units and have the same name. You should probably rename one units and have the same name. You should probably rename one
of the classes to put the tests into different test cases. of the classes to put the tests into different test cases.
Stack trace: (omitted)
[ FAILED ] MixedUpTestCaseTest.ThisShouldFail [ FAILED ] MixedUpTestCaseTest.ThisShouldFail
[ RUN ] MixedUpTestCaseTest.ThisShouldFailToo [ RUN ] MixedUpTestCaseTest.ThisShouldFailToo
gtest.cc:#: Failure gtest.cc:#: Failure
@ -320,6 +412,8 @@ using two different test fixture classes. This can happen if
the two classes are from different namespaces or translation the two classes are from different namespaces or translation
units and have the same name. You should probably rename one units and have the same name. You should probably rename one
of the classes to put the tests into different test cases. of the classes to put the tests into different test cases.
Stack trace: (omitted)
[ FAILED ] MixedUpTestCaseTest.ThisShouldFailToo [ FAILED ] MixedUpTestCaseTest.ThisShouldFailToo
[----------] 2 tests from MixedUpTestCaseWithSameTestNameTest [----------] 2 tests from MixedUpTestCaseWithSameTestNameTest
[ RUN ] MixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail [ RUN ] MixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
@ -334,6 +428,8 @@ using two different test fixture classes. This can happen if
the two classes are from different namespaces or translation the two classes are from different namespaces or translation
units and have the same name. You should probably rename one units and have the same name. You should probably rename one
of the classes to put the tests into different test cases. of the classes to put the tests into different test cases.
Stack trace: (omitted)
[ FAILED ] MixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail [ FAILED ] MixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
[----------] 2 tests from TEST_F_before_TEST_in_same_test_case [----------] 2 tests from TEST_F_before_TEST_in_same_test_case
[ RUN ] TEST_F_before_TEST_in_same_test_case.DefinedUsingTEST_F [ RUN ] TEST_F_before_TEST_in_same_test_case.DefinedUsingTEST_F
@ -348,6 +444,8 @@ test DefinedUsingTEST_F is defined using TEST_F but
test DefinedUsingTESTAndShouldFail is defined using TEST. You probably test DefinedUsingTESTAndShouldFail is defined using TEST. You probably
want to change the TEST to TEST_F or move it to another test want to change the TEST to TEST_F or move it to another test
case. case.
Stack trace: (omitted)
[ FAILED ] TEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail [ FAILED ] TEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail
[----------] 2 tests from TEST_before_TEST_F_in_same_test_case [----------] 2 tests from TEST_before_TEST_F_in_same_test_case
[ RUN ] TEST_before_TEST_F_in_same_test_case.DefinedUsingTEST [ RUN ] TEST_before_TEST_F_in_same_test_case.DefinedUsingTEST
@ -362,6 +460,8 @@ test DefinedUsingTEST_FAndShouldFail is defined using TEST_F but
test DefinedUsingTEST is defined using TEST. You probably test DefinedUsingTEST is defined using TEST. You probably
want to change the TEST to TEST_F or move it to another test want to change the TEST to TEST_F or move it to another test
case. case.
Stack trace: (omitted)
[ FAILED ] TEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail [ FAILED ] TEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail
[----------] 8 tests from ExpectNonfatalFailureTest [----------] 8 tests from ExpectNonfatalFailureTest
[ RUN ] ExpectNonfatalFailureTest.CanReferenceGlobalVariables [ RUN ] ExpectNonfatalFailureTest.CanReferenceGlobalVariables
@ -375,6 +475,8 @@ case.
gtest.cc:#: Failure gtest.cc:#: Failure
Expected: 1 non-fatal failure Expected: 1 non-fatal failure
Actual: 0 failures Actual: 0 failures
Stack trace: (omitted)
[ FAILED ] ExpectNonfatalFailureTest.FailsWhenThereIsNoNonfatalFailure [ FAILED ] ExpectNonfatalFailureTest.FailsWhenThereIsNoNonfatalFailure
[ RUN ] ExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures [ RUN ] ExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures
(expecting a failure) (expecting a failure)
@ -384,10 +486,16 @@ Expected: 1 non-fatal failure
gtest_output_test_.cc:#: Non-fatal failure: gtest_output_test_.cc:#: Non-fatal failure:
Failed Failed
Expected non-fatal failure 1. Expected non-fatal failure 1.
Stack trace: (omitted)
gtest_output_test_.cc:#: Non-fatal failure: gtest_output_test_.cc:#: Non-fatal failure:
Failed Failed
Expected non-fatal failure 2. Expected non-fatal failure 2.
Stack trace: (omitted)
Stack trace: (omitted)
[ FAILED ] ExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures [ FAILED ] ExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures
[ RUN ] ExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure [ RUN ] ExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure
@ -398,6 +506,10 @@ Expected: 1 non-fatal failure
gtest_output_test_.cc:#: Fatal failure: gtest_output_test_.cc:#: Fatal failure:
Failed Failed
Expected fatal failure. Expected fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[ FAILED ] ExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure [ FAILED ] ExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure
[ RUN ] ExpectNonfatalFailureTest.FailsWhenStatementReturns [ RUN ] ExpectNonfatalFailureTest.FailsWhenStatementReturns
@ -405,12 +517,16 @@ Expected fatal failure.
gtest.cc:#: Failure gtest.cc:#: Failure
Expected: 1 non-fatal failure Expected: 1 non-fatal failure
Actual: 0 failures Actual: 0 failures
Stack trace: (omitted)
[ FAILED ] ExpectNonfatalFailureTest.FailsWhenStatementReturns [ FAILED ] ExpectNonfatalFailureTest.FailsWhenStatementReturns
[ RUN ] ExpectNonfatalFailureTest.FailsWhenStatementThrows [ RUN ] ExpectNonfatalFailureTest.FailsWhenStatementThrows
(expecting a failure) (expecting a failure)
gtest.cc:#: Failure gtest.cc:#: Failure
Expected: 1 non-fatal failure Expected: 1 non-fatal failure
Actual: 0 failures Actual: 0 failures
Stack trace: (omitted)
[ FAILED ] ExpectNonfatalFailureTest.FailsWhenStatementThrows [ FAILED ] ExpectNonfatalFailureTest.FailsWhenStatementThrows
[----------] 8 tests from ExpectFatalFailureTest [----------] 8 tests from ExpectFatalFailureTest
[ RUN ] ExpectFatalFailureTest.CanReferenceGlobalVariables [ RUN ] ExpectFatalFailureTest.CanReferenceGlobalVariables
@ -424,6 +540,8 @@ Expected: 1 non-fatal failure
gtest.cc:#: Failure gtest.cc:#: Failure
Expected: 1 fatal failure Expected: 1 fatal failure
Actual: 0 failures Actual: 0 failures
Stack trace: (omitted)
[ FAILED ] ExpectFatalFailureTest.FailsWhenThereIsNoFatalFailure [ FAILED ] ExpectFatalFailureTest.FailsWhenThereIsNoFatalFailure
[ RUN ] ExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures [ RUN ] ExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures
(expecting a failure) (expecting a failure)
@ -433,10 +551,16 @@ Expected: 1 fatal failure
gtest_output_test_.cc:#: Fatal failure: gtest_output_test_.cc:#: Fatal failure:
Failed Failed
Expected fatal failure. Expected fatal failure.
Stack trace: (omitted)
gtest_output_test_.cc:#: Fatal failure: gtest_output_test_.cc:#: Fatal failure:
Failed Failed
Expected fatal failure. Expected fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[ FAILED ] ExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures [ FAILED ] ExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures
[ RUN ] ExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure [ RUN ] ExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure
@ -447,6 +571,10 @@ Expected: 1 fatal failure
gtest_output_test_.cc:#: Non-fatal failure: gtest_output_test_.cc:#: Non-fatal failure:
Failed Failed
Expected non-fatal failure. Expected non-fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[ FAILED ] ExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure [ FAILED ] ExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure
[ RUN ] ExpectFatalFailureTest.FailsWhenStatementReturns [ RUN ] ExpectFatalFailureTest.FailsWhenStatementReturns
@ -454,12 +582,16 @@ Expected non-fatal failure.
gtest.cc:#: Failure gtest.cc:#: Failure
Expected: 1 fatal failure Expected: 1 fatal failure
Actual: 0 failures Actual: 0 failures
Stack trace: (omitted)
[ FAILED ] ExpectFatalFailureTest.FailsWhenStatementReturns [ FAILED ] ExpectFatalFailureTest.FailsWhenStatementReturns
[ RUN ] ExpectFatalFailureTest.FailsWhenStatementThrows [ RUN ] ExpectFatalFailureTest.FailsWhenStatementThrows
(expecting a failure) (expecting a failure)
gtest.cc:#: Failure gtest.cc:#: Failure
Expected: 1 fatal failure Expected: 1 fatal failure
Actual: 0 failures Actual: 0 failures
Stack trace: (omitted)
[ FAILED ] ExpectFatalFailureTest.FailsWhenStatementThrows [ FAILED ] ExpectFatalFailureTest.FailsWhenStatementThrows
[----------] 2 tests from TypedTest/0, where TypeParam = int [----------] 2 tests from TypedTest/0, where TypeParam = int
[ RUN ] TypedTest/0.Success [ RUN ] TypedTest/0.Success
@ -471,6 +603,8 @@ Expected equality of these values:
TypeParam() TypeParam()
Which is: 0 Which is: 0
Expected failure Expected failure
Stack trace: (omitted)
[ FAILED ] TypedTest/0.Failure, where TypeParam = int [ FAILED ] TypedTest/0.Failure, where TypeParam = int
[----------] 2 tests from Unsigned/TypedTestP/0, where TypeParam = unsigned char [----------] 2 tests from Unsigned/TypedTestP/0, where TypeParam = unsigned char
[ RUN ] Unsigned/TypedTestP/0.Success [ RUN ] Unsigned/TypedTestP/0.Success
@ -483,8 +617,10 @@ Expected equality of these values:
TypeParam() TypeParam()
Which is: '\0' Which is: '\0'
Expected failure Expected failure
Stack trace: (omitted)
[ FAILED ] Unsigned/TypedTestP/0.Failure, where TypeParam = unsigned char [ FAILED ] Unsigned/TypedTestP/0.Failure, where TypeParam = unsigned char
[----------] 2 tests from Unsigned/TypedTestP/1, where TypeParam = unsigned [----------] 2 tests from Unsigned/TypedTestP/1, where TypeParam = unsigned int
[ RUN ] Unsigned/TypedTestP/1.Success [ RUN ] Unsigned/TypedTestP/1.Success
[ OK ] Unsigned/TypedTestP/1.Success [ OK ] Unsigned/TypedTestP/1.Success
[ RUN ] Unsigned/TypedTestP/1.Failure [ RUN ] Unsigned/TypedTestP/1.Failure
@ -495,7 +631,9 @@ Expected equality of these values:
TypeParam() TypeParam()
Which is: 0 Which is: 0
Expected failure Expected failure
[ FAILED ] Unsigned/TypedTestP/1.Failure, where TypeParam = unsigned Stack trace: (omitted)
[ FAILED ] Unsigned/TypedTestP/1.Failure, where TypeParam = unsigned int
[----------] 4 tests from ExpectFailureTest [----------] 4 tests from ExpectFailureTest
[ RUN ] ExpectFailureTest.ExpectFatalFailure [ RUN ] ExpectFailureTest.ExpectFatalFailure
(expecting 1 failure) (expecting 1 failure)
@ -504,6 +642,10 @@ Expected: 1 fatal failure
Actual: Actual:
gtest_output_test_.cc:#: Success: gtest_output_test_.cc:#: Success:
Succeeded Succeeded
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure) (expecting 1 failure)
gtest.cc:#: Failure gtest.cc:#: Failure
@ -512,6 +654,10 @@ Expected: 1 fatal failure
gtest_output_test_.cc:#: Non-fatal failure: gtest_output_test_.cc:#: Non-fatal failure:
Failed Failed
Expected non-fatal failure. Expected non-fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure) (expecting 1 failure)
gtest.cc:#: Failure gtest.cc:#: Failure
@ -520,6 +666,10 @@ Expected: 1 fatal failure containing "Some other fatal failure expected."
gtest_output_test_.cc:#: Fatal failure: gtest_output_test_.cc:#: Fatal failure:
Failed Failed
Expected fatal failure. Expected fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[ FAILED ] ExpectFailureTest.ExpectFatalFailure [ FAILED ] ExpectFailureTest.ExpectFatalFailure
[ RUN ] ExpectFailureTest.ExpectNonFatalFailure [ RUN ] ExpectFailureTest.ExpectNonFatalFailure
@ -529,6 +679,10 @@ Expected: 1 non-fatal failure
Actual: Actual:
gtest_output_test_.cc:#: Success: gtest_output_test_.cc:#: Success:
Succeeded Succeeded
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure) (expecting 1 failure)
gtest.cc:#: Failure gtest.cc:#: Failure
@ -537,6 +691,10 @@ Expected: 1 non-fatal failure
gtest_output_test_.cc:#: Fatal failure: gtest_output_test_.cc:#: Fatal failure:
Failed Failed
Expected fatal failure. Expected fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure) (expecting 1 failure)
gtest.cc:#: Failure gtest.cc:#: Failure
@ -545,6 +703,10 @@ Expected: 1 non-fatal failure containing "Some other non-fatal failure."
gtest_output_test_.cc:#: Non-fatal failure: gtest_output_test_.cc:#: Non-fatal failure:
Failed Failed
Expected non-fatal failure. Expected non-fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[ FAILED ] ExpectFailureTest.ExpectNonFatalFailure [ FAILED ] ExpectFailureTest.ExpectNonFatalFailure
[ RUN ] ExpectFailureTest.ExpectFatalFailureOnAllThreads [ RUN ] ExpectFailureTest.ExpectFatalFailureOnAllThreads
@ -554,6 +716,10 @@ Expected: 1 fatal failure
Actual: Actual:
gtest_output_test_.cc:#: Success: gtest_output_test_.cc:#: Success:
Succeeded Succeeded
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure) (expecting 1 failure)
gtest.cc:#: Failure gtest.cc:#: Failure
@ -562,6 +728,10 @@ Expected: 1 fatal failure
gtest_output_test_.cc:#: Non-fatal failure: gtest_output_test_.cc:#: Non-fatal failure:
Failed Failed
Expected non-fatal failure. Expected non-fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure) (expecting 1 failure)
gtest.cc:#: Failure gtest.cc:#: Failure
@ -570,6 +740,10 @@ Expected: 1 fatal failure containing "Some other fatal failure expected."
gtest_output_test_.cc:#: Fatal failure: gtest_output_test_.cc:#: Fatal failure:
Failed Failed
Expected fatal failure. Expected fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[ FAILED ] ExpectFailureTest.ExpectFatalFailureOnAllThreads [ FAILED ] ExpectFailureTest.ExpectFatalFailureOnAllThreads
[ RUN ] ExpectFailureTest.ExpectNonFatalFailureOnAllThreads [ RUN ] ExpectFailureTest.ExpectNonFatalFailureOnAllThreads
@ -579,6 +753,10 @@ Expected: 1 non-fatal failure
Actual: Actual:
gtest_output_test_.cc:#: Success: gtest_output_test_.cc:#: Success:
Succeeded Succeeded
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure) (expecting 1 failure)
gtest.cc:#: Failure gtest.cc:#: Failure
@ -587,6 +765,10 @@ Expected: 1 non-fatal failure
gtest_output_test_.cc:#: Fatal failure: gtest_output_test_.cc:#: Fatal failure:
Failed Failed
Expected fatal failure. Expected fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure) (expecting 1 failure)
gtest.cc:#: Failure gtest.cc:#: Failure
@ -595,6 +777,10 @@ Expected: 1 non-fatal failure containing "Some other non-fatal failure."
gtest_output_test_.cc:#: Non-fatal failure: gtest_output_test_.cc:#: Non-fatal failure:
Failed Failed
Expected non-fatal failure. Expected non-fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[ FAILED ] ExpectFailureTest.ExpectNonFatalFailureOnAllThreads [ FAILED ] ExpectFailureTest.ExpectNonFatalFailureOnAllThreads
[----------] 2 tests from ExpectFailureWithThreadsTest [----------] 2 tests from ExpectFailureWithThreadsTest
@ -603,18 +789,26 @@ Expected non-fatal failure.
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected fatal failure. Expected fatal failure.
Stack trace: (omitted)
gtest.cc:#: Failure gtest.cc:#: Failure
Expected: 1 fatal failure Expected: 1 fatal failure
Actual: 0 failures Actual: 0 failures
Stack trace: (omitted)
[ FAILED ] ExpectFailureWithThreadsTest.ExpectFatalFailure [ FAILED ] ExpectFailureWithThreadsTest.ExpectFatalFailure
[ RUN ] ExpectFailureWithThreadsTest.ExpectNonFatalFailure [ RUN ] ExpectFailureWithThreadsTest.ExpectNonFatalFailure
(expecting 2 failures) (expecting 2 failures)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected non-fatal failure. Expected non-fatal failure.
Stack trace: (omitted)
gtest.cc:#: Failure gtest.cc:#: Failure
Expected: 1 non-fatal failure Expected: 1 non-fatal failure
Actual: 0 failures Actual: 0 failures
Stack trace: (omitted)
[ FAILED ] ExpectFailureWithThreadsTest.ExpectNonFatalFailure [ FAILED ] ExpectFailureWithThreadsTest.ExpectNonFatalFailure
[----------] 1 test from ScopedFakeTestPartResultReporterTest [----------] 1 test from ScopedFakeTestPartResultReporterTest
[ RUN ] ScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread [ RUN ] ScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread
@ -622,9 +816,13 @@ Expected: 1 non-fatal failure
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected fatal failure. Expected fatal failure.
Stack trace: (omitted)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected non-fatal failure. Expected non-fatal failure.
Stack trace: (omitted)
[ FAILED ] ScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread [ FAILED ] ScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread
[----------] 1 test from PrintingFailingParams/FailingParamTest [----------] 1 test from PrintingFailingParams/FailingParamTest
[ RUN ] PrintingFailingParams/FailingParamTest.Fails/0 [ RUN ] PrintingFailingParams/FailingParamTest.Fails/0
@ -633,6 +831,8 @@ Expected equality of these values:
1 1
GetParam() GetParam()
Which is: 2 Which is: 2
Stack trace: (omitted)
[ FAILED ] PrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2 [ FAILED ] PrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2
[----------] 2 tests from PrintingStrings/ParamTest [----------] 2 tests from PrintingStrings/ParamTest
[ RUN ] PrintingStrings/ParamTest.Success/a [ RUN ] PrintingStrings/ParamTest.Success/a
@ -644,16 +844,22 @@ Expected equality of these values:
GetParam() GetParam()
Which is: "a" Which is: "a"
Expected failure Expected failure
Stack trace: (omitted)
[ FAILED ] PrintingStrings/ParamTest.Failure/a, where GetParam() = "a" [ FAILED ] PrintingStrings/ParamTest.Failure/a, where GetParam() = "a"
[----------] Global test environment tear-down [----------] Global test environment tear-down
BarEnvironment::TearDown() called. BarEnvironment::TearDown() called.
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected non-fatal failure. Expected non-fatal failure.
Stack trace: (omitted)
FooEnvironment::TearDown() called. FooEnvironment::TearDown() called.
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
Expected fatal failure. Expected fatal failure.
Stack trace: (omitted)
[==========] 68 tests from 30 test cases ran. [==========] 68 tests from 30 test cases ran.
[ PASSED ] 22 tests. [ PASSED ] 22 tests.
[ FAILED ] 46 tests, listed below: [ FAILED ] 46 tests, listed below:
@ -693,7 +899,7 @@ Expected fatal failure.
[ FAILED ] ExpectFatalFailureTest.FailsWhenStatementThrows [ FAILED ] ExpectFatalFailureTest.FailsWhenStatementThrows
[ FAILED ] TypedTest/0.Failure, where TypeParam = int [ FAILED ] TypedTest/0.Failure, where TypeParam = int
[ FAILED ] Unsigned/TypedTestP/0.Failure, where TypeParam = unsigned char [ FAILED ] Unsigned/TypedTestP/0.Failure, where TypeParam = unsigned char
[ FAILED ] Unsigned/TypedTestP/1.Failure, where TypeParam = unsigned [ FAILED ] Unsigned/TypedTestP/1.Failure, where TypeParam = unsigned int
[ FAILED ] ExpectFailureTest.ExpectFatalFailure [ FAILED ] ExpectFailureTest.ExpectFatalFailure
[ FAILED ] ExpectFailureTest.ExpectNonFatalFailure [ FAILED ] ExpectFailureTest.ExpectNonFatalFailure
[ FAILED ] ExpectFailureTest.ExpectFatalFailureOnAllThreads [ FAILED ] ExpectFailureTest.ExpectFatalFailureOnAllThreads
@ -718,6 +924,8 @@ Expected equality of these values:
1 1
x x
Which is: 2 Which is: 2
Stack trace: (omitted)
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine (? ms) [ FAILED ] FatalFailureTest.FatalFailureInSubroutine (? ms)
[ RUN ] FatalFailureTest.FatalFailureInNestedSubroutine [ RUN ] FatalFailureTest.FatalFailureInNestedSubroutine
(expecting a failure that x should be 1) (expecting a failure that x should be 1)
@ -726,6 +934,8 @@ Expected equality of these values:
1 1
x x
Which is: 2 Which is: 2
Stack trace: (omitted)
[ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine (? ms) [ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine (? ms)
[ RUN ] FatalFailureTest.NonfatalFailureInSubroutine [ RUN ] FatalFailureTest.NonfatalFailureInSubroutine
(expecting a failure on false) (expecting a failure on false)
@ -733,6 +943,8 @@ gtest_output_test_.cc:#: Failure
Value of: false Value of: false
Actual: false Actual: false
Expected: true Expected: true
Stack trace: (omitted)
[ FAILED ] FatalFailureTest.NonfatalFailureInSubroutine (? ms) [ FAILED ] FatalFailureTest.NonfatalFailureInSubroutine (? ms)
[----------] 3 tests from FatalFailureTest (? ms total) [----------] 3 tests from FatalFailureTest (? ms total)
@ -743,10 +955,14 @@ i == 0
i == 1 i == 1
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: (3) >= (a[i]), actual: 3 vs 9 Expected: (3) >= (a[i]), actual: 3 vs 9
Stack trace: (omitted)
i == 2 i == 2
i == 3 i == 3
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: (3) >= (a[i]), actual: 3 vs 6 Expected: (3) >= (a[i]), actual: 3 vs 6
Stack trace: (omitted)
[ FAILED ] LoggingTest.InterleavingLoggingAndAssertions (? ms) [ FAILED ] LoggingTest.InterleavingLoggingAndAssertions (? ms)
[----------] 1 test from LoggingTest (? ms total) [----------] 1 test from LoggingTest (? ms total)

View File

@ -47,17 +47,22 @@ GTEST_OUTPUT_FLAG = '--gtest_output'
GTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml' GTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml'
GTEST_PROGRAM_NAME = 'gtest_xml_output_unittest_' GTEST_PROGRAM_NAME = 'gtest_xml_output_unittest_'
# The flag indicating stacktraces are not supported
NO_STACKTRACE_SUPPORT_FLAG = '--no_stacktrace_support'
# The environment variables for test sharding. # The environment variables for test sharding.
TOTAL_SHARDS_ENV_VAR = 'GTEST_TOTAL_SHARDS' TOTAL_SHARDS_ENV_VAR = 'GTEST_TOTAL_SHARDS'
SHARD_INDEX_ENV_VAR = 'GTEST_SHARD_INDEX' SHARD_INDEX_ENV_VAR = 'GTEST_SHARD_INDEX'
SHARD_STATUS_FILE_ENV_VAR = 'GTEST_SHARD_STATUS_FILE' SHARD_STATUS_FILE_ENV_VAR = 'GTEST_SHARD_STATUS_FILE'
SUPPORTS_STACK_TRACES = False SUPPORTS_STACK_TRACES = NO_STACKTRACE_SUPPORT_FLAG not in sys.argv
if SUPPORTS_STACK_TRACES: if SUPPORTS_STACK_TRACES:
STACK_TRACE_TEMPLATE = '\nStack trace:\n*' STACK_TRACE_TEMPLATE = '\nStack trace:\n*'
else: else:
STACK_TRACE_TEMPLATE = '' STACK_TRACE_TEMPLATE = ''
# unittest.main() can't handle unknown flags
sys.argv.remove(NO_STACKTRACE_SUPPORT_FLAG)
EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?> EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="23" failures="4" disabled="2" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42"> <testsuites tests="23" failures="4" disabled="2" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42">