Upstream cl 103120214
This commit is contained in:
parent
1d757db65c
commit
6914ae2394
|
@ -2110,9 +2110,14 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
|||
// of the dummy variable name, thus allowing multiple SCOPED_TRACE()s
|
||||
// to appear in the same block - as long as they are on different
|
||||
// lines.
|
||||
//
|
||||
// Assuming that each thread maintains its own stack of traces.
|
||||
// Therefore, a SCOPED_TRACE() would (correctly) only affect the
|
||||
// assertions in its own thread.
|
||||
#define SCOPED_TRACE(message) \
|
||||
::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
|
||||
__FILE__, __LINE__, ::testing::Message() << (message))
|
||||
__FILE__, __LINE__, (message))
|
||||
|
||||
|
||||
// Compile-time assertion for type equality.
|
||||
// StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
|
||||
//
|
||||
// The Google C++ Testing Framework (Google Test)
|
||||
//
|
||||
|
@ -61,8 +60,8 @@
|
|||
#include <vector>
|
||||
|
||||
#include "gtest/gtest-message.h"
|
||||
#include "gtest/internal/gtest-string.h"
|
||||
#include "gtest/internal/gtest-filepath.h"
|
||||
#include "gtest/internal/gtest-string.h"
|
||||
#include "gtest/internal/gtest-type-util.h"
|
||||
|
||||
// Due to C++ preprocessor weirdness, we need double indirection to
|
||||
|
@ -157,7 +156,28 @@ class GTEST_API_ ScopedTrace {
|
|||
public:
|
||||
// The c'tor pushes the given source file location and message onto
|
||||
// a trace stack maintained by Google Test.
|
||||
ScopedTrace(const char* file, int line, const Message& message);
|
||||
|
||||
// Template version. Uses Message() to convert the values into strings.
|
||||
// Slow, but flexible.
|
||||
template <typename T>
|
||||
ScopedTrace(const char* file, int line, const T& message) {
|
||||
PushTrace(file, line, (Message() << message).GetString());
|
||||
}
|
||||
|
||||
// Optimize for some known types.
|
||||
ScopedTrace(const char* file, int line, const char* message) {
|
||||
PushTrace(file, line, message ? message : "(null)");
|
||||
}
|
||||
|
||||
#if GTEST_HAS_GLOBAL_STRING
|
||||
ScopedTrace(const char* file, int line, const ::string& message) {
|
||||
PushTrace(file, line, message);
|
||||
}
|
||||
#endif
|
||||
|
||||
ScopedTrace(const char* file, int line, const std::string& message) {
|
||||
PushTrace(file, line, message);
|
||||
}
|
||||
|
||||
// The d'tor pops the info pushed by the c'tor.
|
||||
//
|
||||
|
@ -166,6 +186,8 @@ class GTEST_API_ ScopedTrace {
|
|||
~ScopedTrace();
|
||||
|
||||
private:
|
||||
void PushTrace(const char* file, int line, std::string message);
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
|
||||
} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its
|
||||
// c'tor and d'tor. Therefore it doesn't
|
||||
|
|
|
@ -3839,12 +3839,11 @@ void StreamingListener::SocketWriter::MakeConnection() {
|
|||
|
||||
// Pushes the given source file location and message onto a per-thread
|
||||
// trace stack maintained by Google Test.
|
||||
ScopedTrace::ScopedTrace(const char* file, int line, const Message& message)
|
||||
GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {
|
||||
void ScopedTrace::PushTrace(const char* file, int line, std::string message) {
|
||||
TraceInfo trace;
|
||||
trace.file = file;
|
||||
trace.line = line;
|
||||
trace.message = message.GetString();
|
||||
trace.message.swap(message);
|
||||
|
||||
UnitTest::GetInstance()->PushGTestTrace(trace);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user