Commit 96f7ba83 authored by Gennadiy Civil's avatar Gennadiy Civil Committed by GitHub
Browse files

Merge branch 'master' into wrong-version-reported

parents b74070cf 675686a1
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include "prime_tables.h" #include "prime_tables.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace {
#if GTEST_HAS_COMBINE #if GTEST_HAS_COMBINE
// Suppose we want to introduce a new, improved implementation of PrimeTable // Suppose we want to introduce a new, improved implementation of PrimeTable
...@@ -171,3 +171,4 @@ INSTANTIATE_TEST_CASE_P(MeaningfulTestParameters, ...@@ -171,3 +171,4 @@ INSTANTIATE_TEST_CASE_P(MeaningfulTestParameters,
TEST(DummyTest, CombineIsNotSupportedOnThisPlatform) {} TEST(DummyTest, CombineIsNotSupportedOnThisPlatform) {}
#endif // GTEST_HAS_COMBINE #endif // GTEST_HAS_COMBINE
} // namespace
...@@ -44,9 +44,7 @@ using ::testing::TestEventListeners; ...@@ -44,9 +44,7 @@ using ::testing::TestEventListeners;
using ::testing::TestInfo; using ::testing::TestInfo;
using ::testing::TestPartResult; using ::testing::TestPartResult;
using ::testing::UnitTest; using ::testing::UnitTest;
namespace { namespace {
// Provides alternative output mode which produces minimal amount of // Provides alternative output mode which produces minimal amount of
// information about tests. // information about tests.
class TersePrinter : public EmptyTestEventListener { class TersePrinter : public EmptyTestEventListener {
...@@ -102,7 +100,6 @@ TEST(CustomOutputTest, Fails) { ...@@ -102,7 +100,6 @@ TEST(CustomOutputTest, Fails) {
EXPECT_EQ(1, 2) EXPECT_EQ(1, 2)
<< "This test fails in order to demonstrate alternative failure messages"; << "This test fails in order to demonstrate alternative failure messages";
} }
} // namespace } // namespace
int main(int argc, char **argv) { int main(int argc, char **argv) {
......
...@@ -732,7 +732,7 @@ class SubversionVCS(VersionControlSystem): ...@@ -732,7 +732,7 @@ class SubversionVCS(VersionControlSystem):
else: else:
self.rev_start = self.rev_end = None self.rev_start = self.rev_end = None
# Cache output from "svn list -r REVNO dirname". # Cache output from "svn list -r REVNO dirname".
# Keys: dirname, Values: 2-tuple (ouput for start rev and end rev). # Keys: dirname, Values: 2-tuple (output for start rev and end rev).
self.svnls_cache = {} self.svnls_cache = {}
# SVN base URL is required to fetch files deleted in an older revision. # SVN base URL is required to fetch files deleted in an older revision.
# Result is cached to not guess it over and over again in GetBaseFile(). # Result is cached to not guess it over and over again in GetBaseFile().
......
...@@ -883,11 +883,10 @@ class ExecDeathTest : public ForkingDeathTest { ...@@ -883,11 +883,10 @@ class ExecDeathTest : public ForkingDeathTest {
ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { } ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { }
virtual TestRole AssumeRole(); virtual TestRole AssumeRole();
private: private:
static ::std::vector<testing::internal::string> static ::std::vector<std::string> GetArgvsForDeathTestChildProcess() {
GetArgvsForDeathTestChildProcess() { ::std::vector<std::string> args = GetInjectableArgvs();
::std::vector<testing::internal::string> args = GetInjectableArgvs();
# if defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_) # if defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_)
::std::vector<testing::internal::string> extra_args = ::std::vector<std::string> extra_args =
GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_(); GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_();
args.insert(args.end(), extra_args.begin(), extra_args.end()); args.insert(args.end(), extra_args.begin(), extra_args.end());
# endif // defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_) # endif // defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_)
...@@ -1243,7 +1242,7 @@ int GetStatusFileDescriptor(unsigned int parent_process_id, ...@@ -1243,7 +1242,7 @@ int GetStatusFileDescriptor(unsigned int parent_process_id,
reinterpret_cast<HANDLE>(write_handle_as_size_t); reinterpret_cast<HANDLE>(write_handle_as_size_t);
HANDLE dup_write_handle; HANDLE dup_write_handle;
// The newly initialized handle is accessible only in in the parent // The newly initialized handle is accessible only in the parent
// process. To obtain one accessible within the child, we need to use // process. To obtain one accessible within the child, we need to use
// DuplicateHandle. // DuplicateHandle.
if (!::DuplicateHandle(parent_process_handle.Get(), write_handle, if (!::DuplicateHandle(parent_process_handle.Get(), write_handle,
......
...@@ -426,7 +426,7 @@ class OsStackTraceGetterInterface { ...@@ -426,7 +426,7 @@ class OsStackTraceGetterInterface {
// in the trace. // in the trace.
// skip_count - the number of top frames to be skipped; doesn't count // skip_count - the number of top frames to be skipped; doesn't count
// against max_depth. // against max_depth.
virtual string CurrentStackTrace(int max_depth, int skip_count) = 0; virtual std::string CurrentStackTrace(int max_depth, int skip_count) = 0;
// UponLeavingGTest() should be called immediately before Google Test calls // UponLeavingGTest() should be called immediately before Google Test calls
// user code. It saves some information about the current stack that // user code. It saves some information about the current stack that
...@@ -446,7 +446,7 @@ class OsStackTraceGetter : public OsStackTraceGetterInterface { ...@@ -446,7 +446,7 @@ class OsStackTraceGetter : public OsStackTraceGetterInterface {
public: public:
OsStackTraceGetter() {} OsStackTraceGetter() {}
virtual string CurrentStackTrace(int max_depth, int skip_count); virtual std::string CurrentStackTrace(int max_depth, int skip_count);
virtual void UponLeavingGTest(); virtual void UponLeavingGTest();
private: private:
...@@ -1040,21 +1040,19 @@ class GTEST_API_ StreamingListener : public EmptyTestEventListener { ...@@ -1040,21 +1040,19 @@ class GTEST_API_ StreamingListener : public EmptyTestEventListener {
virtual ~AbstractSocketWriter() {} virtual ~AbstractSocketWriter() {}
// Sends a string to the socket. // Sends a string to the socket.
virtual void Send(const string& message) = 0; virtual void Send(const std::string& message) = 0;
// Closes the socket. // Closes the socket.
virtual void CloseConnection() {} virtual void CloseConnection() {}
// Sends a string and a newline to the socket. // Sends a string and a newline to the socket.
void SendLn(const string& message) { void SendLn(const std::string& message) { Send(message + "\n"); }
Send(message + "\n");
}
}; };
// Concrete class for actually writing strings to a socket. // Concrete class for actually writing strings to a socket.
class SocketWriter : public AbstractSocketWriter { class SocketWriter : public AbstractSocketWriter {
public: public:
SocketWriter(const string& host, const string& port) SocketWriter(const std::string& host, const std::string& port)
: sockfd_(-1), host_name_(host), port_num_(port) { : sockfd_(-1), host_name_(host), port_num_(port) {
MakeConnection(); MakeConnection();
} }
...@@ -1065,7 +1063,7 @@ class GTEST_API_ StreamingListener : public EmptyTestEventListener { ...@@ -1065,7 +1063,7 @@ class GTEST_API_ StreamingListener : public EmptyTestEventListener {
} }
// Sends a string to the socket. // Sends a string to the socket.
virtual void Send(const string& message) { virtual void Send(const std::string& message) {
GTEST_CHECK_(sockfd_ != -1) GTEST_CHECK_(sockfd_ != -1)
<< "Send() can be called only when there is a connection."; << "Send() can be called only when there is a connection.";
...@@ -1091,17 +1089,19 @@ class GTEST_API_ StreamingListener : public EmptyTestEventListener { ...@@ -1091,17 +1089,19 @@ class GTEST_API_ StreamingListener : public EmptyTestEventListener {
} }
int sockfd_; // socket file descriptor int sockfd_; // socket file descriptor
const string host_name_; const std::string host_name_;
const string port_num_; const std::string port_num_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter); GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter);
}; // class SocketWriter }; // class SocketWriter
// Escapes '=', '&', '%', and '\n' characters in str as "%xx". // Escapes '=', '&', '%', and '\n' characters in str as "%xx".
static string UrlEncode(const char* str); static std::string UrlEncode(const char* str);
StreamingListener(const string& host, const string& port) StreamingListener(const std::string& host, const std::string& port)
: socket_writer_(new SocketWriter(host, port)) { Start(); } : socket_writer_(new SocketWriter(host, port)) {
Start();
}
explicit StreamingListener(AbstractSocketWriter* socket_writer) explicit StreamingListener(AbstractSocketWriter* socket_writer)
: socket_writer_(socket_writer) { Start(); } : socket_writer_(socket_writer) { Start(); }
...@@ -1162,13 +1162,13 @@ class GTEST_API_ StreamingListener : public EmptyTestEventListener { ...@@ -1162,13 +1162,13 @@ class GTEST_API_ StreamingListener : public EmptyTestEventListener {
private: private:
// Sends the given message and a newline to the socket. // Sends the given message and a newline to the socket.
void SendLn(const string& message) { socket_writer_->SendLn(message); } void SendLn(const std::string& message) { socket_writer_->SendLn(message); }
// Called at the start of streaming to notify the receiver what // Called at the start of streaming to notify the receiver what
// protocol we are using. // protocol we are using.
void Start() { SendLn("gtest_streaming_protocol_version=1.0"); } void Start() { SendLn("gtest_streaming_protocol_version=1.0"); }
string FormatBool(bool value) { return value ? "1" : "0"; } std::string FormatBool(bool value) { return value ? "1" : "0"; }
const scoped_ptr<AbstractSocketWriter> socket_writer_; const scoped_ptr<AbstractSocketWriter> socket_writer_;
......
...@@ -93,7 +93,7 @@ const int kStdErrFileno = STDERR_FILENO; ...@@ -93,7 +93,7 @@ const int kStdErrFileno = STDERR_FILENO;
namespace { namespace {
template <typename T> template <typename T>
T ReadProcFileField(const string& filename, int field) { T ReadProcFileField(const std::string& filename, int field) {
std::string dummy; std::string dummy;
std::ifstream file(filename.c_str()); std::ifstream file(filename.c_str());
while (field-- > 0) { while (field-- > 0) {
...@@ -107,7 +107,7 @@ T ReadProcFileField(const string& filename, int field) { ...@@ -107,7 +107,7 @@ T ReadProcFileField(const string& filename, int field) {
// Returns the number of active threads, or 0 when there is an error. // Returns the number of active threads, or 0 when there is an error.
size_t GetThreadCount() { size_t GetThreadCount() {
const string filename = const std::string filename =
(Message() << "/proc/" << getpid() << "/stat").GetString(); (Message() << "/proc/" << getpid() << "/stat").GetString();
return ReadProcFileField<int>(filename, 19); return ReadProcFileField<int>(filename, 19);
} }
...@@ -496,7 +496,7 @@ class ThreadLocalRegistryImpl { ...@@ -496,7 +496,7 @@ class ThreadLocalRegistryImpl {
FALSE, FALSE,
thread_id); thread_id);
GTEST_CHECK_(thread != NULL); GTEST_CHECK_(thread != NULL);
// We need to to pass a valid thread ID pointer into CreateThread for it // We need to pass a valid thread ID pointer into CreateThread for it
// to work correctly under Win98. // to work correctly under Win98.
DWORD watcher_thread_id; DWORD watcher_thread_id;
HANDLE watcher_thread = ::CreateThread( HANDLE watcher_thread = ::CreateThread(
...@@ -1055,24 +1055,6 @@ std::string GetCapturedStderr() { ...@@ -1055,24 +1055,6 @@ std::string GetCapturedStderr() {
#endif // GTEST_HAS_STREAM_REDIRECTION #endif // GTEST_HAS_STREAM_REDIRECTION
std::string TempDir() {
#if GTEST_OS_WINDOWS_MOBILE
return "\\temp\\";
#elif GTEST_OS_WINDOWS
const char* temp_dir = posix::GetEnv("TEMP");
if (temp_dir == NULL || temp_dir[0] == '\0')
return "\\temp\\";
else if (temp_dir[strlen(temp_dir) - 1] == '\\')
return temp_dir;
else
return std::string(temp_dir) + "\\";
#elif GTEST_OS_LINUX_ANDROID
return "/sdcard/";
#else
return "/tmp/";
#endif // GTEST_OS_WINDOWS_MOBILE
}
size_t GetFileSize(FILE* file) { size_t GetFileSize(FILE* file) {
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
return static_cast<size_t>(ftell(file)); return static_cast<size_t>(ftell(file));
......
...@@ -310,7 +310,8 @@ namespace internal { ...@@ -310,7 +310,8 @@ namespace internal {
// than kMaxRange. // than kMaxRange.
UInt32 Random::Generate(UInt32 range) { UInt32 Random::Generate(UInt32 range) {
// These constants are the same as are used in glibc's rand(3). // These constants are the same as are used in glibc's rand(3).
state_ = (1103515245U*state_ + 12345U) % kMaxRange; // Use wider types than necessary to prevent unsigned overflow diagnostics.
state_ = static_cast<UInt32>(1103515245ULL*state_ + 12345U) % kMaxRange;
GTEST_CHECK_(range > 0) GTEST_CHECK_(range > 0)
<< "Cannot generate a number in the range [0, 0)."; << "Cannot generate a number in the range [0, 0).";
...@@ -633,7 +634,7 @@ AssertionResult HasOneFailure(const char* /* results_expr */, ...@@ -633,7 +634,7 @@ AssertionResult HasOneFailure(const char* /* results_expr */,
const char* /* substr_expr */, const char* /* substr_expr */,
const TestPartResultArray& results, const TestPartResultArray& results,
TestPartResult::Type type, TestPartResult::Type type,
const string& substr) { const std::string& substr) {
const std::string expected(type == TestPartResult::kFatalFailure ? const std::string expected(type == TestPartResult::kFatalFailure ?
"1 fatal failure" : "1 fatal failure" :
"1 non-fatal failure"); "1 non-fatal failure");
...@@ -667,13 +668,10 @@ AssertionResult HasOneFailure(const char* /* results_expr */, ...@@ -667,13 +668,10 @@ AssertionResult HasOneFailure(const char* /* results_expr */,
// The constructor of SingleFailureChecker remembers where to look up // The constructor of SingleFailureChecker remembers where to look up
// test part results, what type of failure we expect, and what // test part results, what type of failure we expect, and what
// substring the failure message should contain. // substring the failure message should contain.
SingleFailureChecker:: SingleFailureChecker( SingleFailureChecker::SingleFailureChecker(const TestPartResultArray* results,
const TestPartResultArray* results, TestPartResult::Type type,
TestPartResult::Type type, const std::string& substr)
const string& substr) : results_(results), type_(type), substr_(substr) {}
: results_(results),
type_(type),
substr_(substr) {}
// The destructor of SingleFailureChecker verifies that the given // The destructor of SingleFailureChecker verifies that the given
// TestPartResultArray contains exactly one failure that has the given // TestPartResultArray contains exactly one failure that has the given
...@@ -1171,7 +1169,7 @@ class Hunk { ...@@ -1171,7 +1169,7 @@ class Hunk {
// Print a unified diff header for one hunk. // Print a unified diff header for one hunk.
// The format is // The format is
// "@@ -<left_start>,<left_length> +<right_start>,<right_length> @@" // "@@ -<left_start>,<left_length> +<right_start>,<right_length> @@"
// where the left/right parts are ommitted if unnecessary. // where the left/right parts are omitted if unnecessary.
void PrintHeader(std::ostream* ss) const { void PrintHeader(std::ostream* ss) const {
*ss << "@@ "; *ss << "@@ ";
if (removes_) { if (removes_) {
...@@ -1784,7 +1782,7 @@ std::string CodePointToUtf8(UInt32 code_point) { ...@@ -1784,7 +1782,7 @@ std::string CodePointToUtf8(UInt32 code_point) {
return str; return str;
} }
// The following two functions only make sense if the the system // The following two functions only make sense if the system
// uses UTF-16 for wide string encoding. All supported systems // uses UTF-16 for wide string encoding. All supported systems
// with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16. // with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16.
...@@ -2897,6 +2895,33 @@ WORD GetColorAttribute(GTestColor color) { ...@@ -2897,6 +2895,33 @@ WORD GetColorAttribute(GTestColor color) {
} }
} }
int GetBitOffset(WORD color_mask) {
if (color_mask == 0) return 0;
int bitOffset = 0;
while((color_mask & 1) == 0) {
color_mask >>= 1;
++bitOffset;
}
return bitOffset;
}
WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
// Let's reuse the BG
static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
static const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
const WORD existing_bg = old_color_attrs & background_mask;
WORD new_color = GetColorAttribute(color) | existing_bg | FOREGROUND_INTENSITY;
static const int bg_bitOffset = GetBitOffset(background_mask);
static const int fg_bitOffset = GetBitOffset(foreground_mask);
if (((new_color & background_mask) >> bg_bitOffset) == ((new_color & foreground_mask) >> fg_bitOffset)) {
new_color ^= FOREGROUND_INTENSITY; //invert intensity
}
return new_color;
}
#else #else
// Returns the ANSI color code for the given color. COLOR_DEFAULT is // Returns the ANSI color code for the given color. COLOR_DEFAULT is
...@@ -2953,6 +2978,7 @@ bool ShouldUseColor(bool stdout_is_tty) { ...@@ -2953,6 +2978,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
// cannot simply emit special characters and have the terminal change colors. // cannot simply emit special characters and have the terminal change colors.
// This routine must actually emit the characters rather than return a string // This routine must actually emit the characters rather than return a string
// that would be colored when printed, as can be done on Linux. // that would be colored when printed, as can be done on Linux.
GTEST_ATTRIBUTE_PRINTF_(2, 3)
void ColoredPrintf(GTestColor color, const char* fmt, ...) { void ColoredPrintf(GTestColor color, const char* fmt, ...) {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
...@@ -2981,13 +3007,14 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) { ...@@ -2981,13 +3007,14 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
CONSOLE_SCREEN_BUFFER_INFO buffer_info; CONSOLE_SCREEN_BUFFER_INFO buffer_info;
GetConsoleScreenBufferInfo(stdout_handle, &buffer_info); GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);
const WORD old_color_attrs = buffer_info.wAttributes; const WORD old_color_attrs = buffer_info.wAttributes;
const WORD new_color = GetNewColor(color, old_color_attrs);
// We need to flush the stream buffers into the console before each // We need to flush the stream buffers into the console before each
// SetConsoleTextAttribute call lest it affect the text that is already // SetConsoleTextAttribute call lest it affect the text that is already
// printed but has not yet reached the console. // printed but has not yet reached the console.
fflush(stdout); fflush(stdout);
SetConsoleTextAttribute(stdout_handle, SetConsoleTextAttribute(stdout_handle, new_color);
GetColorAttribute(color) | FOREGROUND_INTENSITY);
vprintf(fmt, args); vprintf(fmt, args);
fflush(stdout); fflush(stdout);
...@@ -3653,13 +3680,14 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream, ...@@ -3653,13 +3680,14 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
if (++failures == 1) { if (++failures == 1) {
*stream << ">\n"; *stream << ">\n";
} }
const string location = internal::FormatCompilerIndependentFileLocation( const std::string location =
part.file_name(), part.line_number()); internal::FormatCompilerIndependentFileLocation(part.file_name(),
const string summary = location + "\n" + part.summary(); part.line_number());
const std::string summary = location + "\n" + part.summary();
*stream << " <failure message=\"" *stream << " <failure message=\""
<< EscapeXmlAttribute(summary.c_str()) << EscapeXmlAttribute(summary.c_str())
<< "\" type=\"\">"; << "\" type=\"\">";
const string detail = location + "\n" + part.message(); const std::string detail = location + "\n" + part.message();
OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str()); OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
*stream << "</failure>\n"; *stream << "</failure>\n";
} }
...@@ -3758,8 +3786,8 @@ std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes( ...@@ -3758,8 +3786,8 @@ std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
// example, replaces "=" with "%3D". This algorithm is O(strlen(str)) // example, replaces "=" with "%3D". This algorithm is O(strlen(str))
// in both time and space -- important as the input str may contain an // in both time and space -- important as the input str may contain an
// arbitrarily long test failure message and stack trace. // arbitrarily long test failure message and stack trace.
string StreamingListener::UrlEncode(const char* str) { std::string StreamingListener::UrlEncode(const char* str) {
string result; std::string result;
result.reserve(strlen(str) + 1); result.reserve(strlen(str) + 1);
for (char ch = *str; ch != '\0'; ch = *++str) { for (char ch = *str; ch != '\0'; ch = *++str) {
switch (ch) { switch (ch) {
...@@ -3847,8 +3875,8 @@ ScopedTrace::~ScopedTrace() ...@@ -3847,8 +3875,8 @@ ScopedTrace::~ScopedTrace()
const char* const OsStackTraceGetterInterface::kElidedFramesMarker = const char* const OsStackTraceGetterInterface::kElidedFramesMarker =
"... " GTEST_NAME_ " internal frames ..."; "... " GTEST_NAME_ " internal frames ...";
string OsStackTraceGetter::CurrentStackTrace(int /*max_depth*/, std::string OsStackTraceGetter::CurrentStackTrace(int /*max_depth*/,
int /*skip_count*/) { int /*skip_count*/) {
return ""; return "";
} }
...@@ -4729,7 +4757,7 @@ bool ShouldShard(const char* total_shards_env, ...@@ -4729,7 +4757,7 @@ bool ShouldShard(const char* total_shards_env,
<< "Invalid environment variables: you have " << "Invalid environment variables: you have "
<< kTestShardIndex << " = " << shard_index << kTestShardIndex << " = " << shard_index
<< ", but have left " << kTestTotalShards << " unset.\n"; << ", but have left " << kTestTotalShards << " unset.\n";
ColoredPrintf(COLOR_RED, msg.GetString().c_str()); ColoredPrintf(COLOR_RED, "%s", msg.GetString().c_str());
fflush(stdout); fflush(stdout);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else if (total_shards != -1 && shard_index == -1) { } else if (total_shards != -1 && shard_index == -1) {
...@@ -4737,7 +4765,7 @@ bool ShouldShard(const char* total_shards_env, ...@@ -4737,7 +4765,7 @@ bool ShouldShard(const char* total_shards_env,
<< "Invalid environment variables: you have " << "Invalid environment variables: you have "
<< kTestTotalShards << " = " << total_shards << kTestTotalShards << " = " << total_shards
<< ", but have left " << kTestShardIndex << " unset.\n"; << ", but have left " << kTestShardIndex << " unset.\n";
ColoredPrintf(COLOR_RED, msg.GetString().c_str()); ColoredPrintf(COLOR_RED, "%s", msg.GetString().c_str());
fflush(stdout); fflush(stdout);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else if (shard_index < 0 || shard_index >= total_shards) { } else if (shard_index < 0 || shard_index >= total_shards) {
...@@ -4746,7 +4774,7 @@ bool ShouldShard(const char* total_shards_env, ...@@ -4746,7 +4774,7 @@ bool ShouldShard(const char* total_shards_env,
<< kTestShardIndex << " < " << kTestTotalShards << kTestShardIndex << " < " << kTestTotalShards
<< ", but you have " << kTestShardIndex << "=" << shard_index << ", but you have " << kTestShardIndex << "=" << shard_index
<< ", " << kTestTotalShards << "=" << total_shards << ".\n"; << ", " << kTestTotalShards << "=" << total_shards << ".\n";
ColoredPrintf(COLOR_RED, msg.GetString().c_str()); ColoredPrintf(COLOR_RED, "%s", msg.GetString().c_str());
fflush(stdout); fflush(stdout);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -5184,12 +5212,12 @@ static const char kColorEncodedHelpMessage[] = ...@@ -5184,12 +5212,12 @@ static const char kColorEncodedHelpMessage[] =
"Test Output:\n" "Test Output:\n"
" @G--" GTEST_FLAG_PREFIX_ "color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\n" " @G--" GTEST_FLAG_PREFIX_ "color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\n"
" Enable/disable colored output. The default is @Gauto@D.\n" " Enable/disable colored output. The default is @Gauto@D.\n"
" -@G-" GTEST_FLAG_PREFIX_ "print_time=0@D\n" " @G--" GTEST_FLAG_PREFIX_ "print_time=0@D\n"
" Don't print the elapsed time of each test.\n" " Don't print the elapsed time of each test.\n"
" @G--" GTEST_FLAG_PREFIX_ "output=xml@Y[@G:@YDIRECTORY_PATH@G" " @G--" GTEST_FLAG_PREFIX_ "output=xml@Y[@G:@YDIRECTORY_PATH@G"
GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n" GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n"
" Generate an XML report in the given directory or with the given file\n" " Generate an XML report in the given directory or with the given file\n"
" name. @YFILE_PATH@D defaults to @Gtest_details.xml@D.\n" " name. @YFILE_PATH@D defaults to @Gtest_detail.xml@D.\n"
#if GTEST_CAN_STREAM_RESULTS_ #if GTEST_CAN_STREAM_RESULTS_
" @G--" GTEST_FLAG_PREFIX_ "stream_result_to=@YHOST@G:@YPORT@D\n" " @G--" GTEST_FLAG_PREFIX_ "stream_result_to=@YHOST@G:@YPORT@D\n"
" Stream test results to the given server.\n" " Stream test results to the given server.\n"
...@@ -5385,4 +5413,25 @@ void InitGoogleTest(int* argc, wchar_t** argv) { ...@@ -5385,4 +5413,25 @@ void InitGoogleTest(int* argc, wchar_t** argv) {
#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) #endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
} }
std::string TempDir() {
#if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_)
return GTEST_CUSTOM_TEMPDIR_FUNCTION_();
#endif
#if GTEST_OS_WINDOWS_MOBILE
return "\\temp\\";
#elif GTEST_OS_WINDOWS
const char* temp_dir = internal::posix::GetEnv("TEMP");
if (temp_dir == NULL || temp_dir[0] == '\0')
return "\\temp\\";
else if (temp_dir[strlen(temp_dir) - 1] == '\\')
return temp_dir;
else
return std::string(temp_dir) + "\\";
#elif GTEST_OS_LINUX_ANDROID
return "/sdcard/";
#else
return "/tmp/";
#endif // GTEST_OS_WINDOWS_MOBILE
}
} // namespace testing } // namespace testing
# Copyright 2017 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: misterg@google.com (Gennadiy Civil)
#
# Bazel BUILD for The Google C++ Testing Framework (Google Test)
licenses(["notice"])
""" gtest own tests """
#on windows exclude gtest-tuple.h and gtest-tuple_test.cc
cc_test(
name = "gtest_all_test",
size = "small",
srcs = glob(
include = [
"gtest-*.cc",
"*.h",
"googletest/include/gtest/**/*.h",
],
exclude = [
"gtest-unittest-api_test.cc",
"gtest-tuple_test.cc",
"googletest/src/gtest-all.cc",
"gtest_all_test.cc",
"gtest-death-test_ex_test.cc",
"gtest-listener_test.cc",
"gtest-unittest-api_test.cc",
"gtest-param-test_test.cc",
],
) + select({
"//:win": [],
"//conditions:default": [
"gtest-tuple_test.cc",
],
}),
copts = select({
"//:win": ["-DGTEST_USE_OWN_TR1_TUPLE=0"],
"//conditions:default": ["-DGTEST_USE_OWN_TR1_TUPLE=1"],
}),
includes = [
"googletest",
"googletest/include",
"googletest/include/internal",
"googletest/test",
],
linkopts = select({
"//:win": [],
"//conditions:default": [
"-pthread",
],
}),
deps = ["//:gtest_main"],
)
#These googletest tests have their own main()
cc_test(
name = "gtest-listener_test",
size = "small",
srcs = [
"gtest-listener_test.cc",
],
deps = [
"//:gtest",
],
)
cc_test(
name = "gtest-unittest-api_test",
size = "small",
srcs = [
"gtest-unittest-api_test.cc",
],
deps = [
"//:gtest",
],
)
cc_test(
name = "gtest-param-test_test",
size = "small",
srcs = [
"gtest-param-test2_test.cc",
"gtest-param-test_test.cc",
"gtest-param-test_test.h",
],
deps = [
"//:gtest",
],
)
...@@ -505,7 +505,7 @@ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) { ...@@ -505,7 +505,7 @@ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {
# if GTEST_HAS_GLOBAL_STRING # if GTEST_HAS_GLOBAL_STRING
const string regex_str(regex_c_str); const ::string regex_str(regex_c_str);
EXPECT_DEATH(GlobalFunction(), regex_str); EXPECT_DEATH(GlobalFunction(), regex_str);
# endif // GTEST_HAS_GLOBAL_STRING # endif // GTEST_HAS_GLOBAL_STRING
......
...@@ -1209,7 +1209,7 @@ class DestructorTracker { ...@@ -1209,7 +1209,7 @@ class DestructorTracker {
: index_(GetNewIndex()) {} : index_(GetNewIndex()) {}
~DestructorTracker() { ~DestructorTracker() {
// We never access DestructorCall::List() concurrently, so we don't need // We never access DestructorCall::List() concurrently, so we don't need
// to protect this acccess with a mutex. // to protect this access with a mutex.
DestructorCall::List()[index_]->ReportDestroyed(); DestructorCall::List()[index_]->ReportDestroyed();
} }
......
...@@ -216,6 +216,7 @@ using ::testing::internal::UniversalTersePrintTupleFieldsToStrings; ...@@ -216,6 +216,7 @@ using ::testing::internal::UniversalTersePrintTupleFieldsToStrings;
#endif #endif
using ::testing::internal::string; using ::testing::internal::string;
#if GTEST_HAS_HASH_MAP_
// The hash_* classes are not part of the C++ standard. STLport // 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 namespace std. MSVC defines them in ::stdext. GCC
// defines them in ::. // defines them in ::.
...@@ -230,11 +231,12 @@ using ::stdext::hash_set; ...@@ -230,11 +231,12 @@ using ::stdext::hash_set;
using ::stdext::hash_multimap; using ::stdext::hash_multimap;
using ::stdext::hash_multiset; using ::stdext::hash_multiset;
#endif #endif
#endif
// Prints a value to a string using the universal value printer. This // Prints a value to a string using the universal value printer. This
// is a helper for testing UniversalPrinter<T>::Print() for various types. // is a helper for testing UniversalPrinter<T>::Print() for various types.
template <typename T> template <typename T>
string Print(const T& value) { std::string Print(const T& value) {
::std::stringstream ss; ::std::stringstream ss;
UniversalPrinter<T>::Print(value, &ss); UniversalPrinter<T>::Print(value, &ss);
return ss.str(); return ss.str();
...@@ -244,7 +246,7 @@ string Print(const T& value) { ...@@ -244,7 +246,7 @@ string Print(const T& value) {
// value printer. This is a helper for testing // value printer. This is a helper for testing
// UniversalPrinter<T&>::Print() for various types. // UniversalPrinter<T&>::Print() for various types.
template <typename T> template <typename T>
string PrintByRef(const T& value) { std::string PrintByRef(const T& value) {
::std::stringstream ss; ::std::stringstream ss;
UniversalPrinter<T&>::Print(value, &ss); UniversalPrinter<T&>::Print(value, &ss);
return ss.str(); return ss.str();
...@@ -381,7 +383,7 @@ TEST(PrintBuiltInTypeTest, FloatingPoints) { ...@@ -381,7 +383,7 @@ TEST(PrintBuiltInTypeTest, FloatingPoints) {
// Since ::std::stringstream::operator<<(const void *) formats the pointer // Since ::std::stringstream::operator<<(const void *) formats the pointer
// output differently with different compilers, we have to create the expected // output differently with different compilers, we have to create the expected
// output first and use it as our expectation. // output first and use it as our expectation.
static string PrintPointer(const void *p) { static std::string PrintPointer(const void* p) {
::std::stringstream expected_result_stream; ::std::stringstream expected_result_stream;
expected_result_stream << p; expected_result_stream << p;
return expected_result_stream.str(); return expected_result_stream.str();
...@@ -594,7 +596,7 @@ TEST(PrintPointerTest, MemberFunctionPointer) { ...@@ -594,7 +596,7 @@ TEST(PrintPointerTest, MemberFunctionPointer) {
// The difference between this and Print() is that it ensures that the // The difference between this and Print() is that it ensures that the
// argument is a reference to an array. // argument is a reference to an array.
template <typename T, size_t N> template <typename T, size_t N>
string PrintArrayHelper(T (&a)[N]) { std::string PrintArrayHelper(T (&a)[N]) {
return Print(a); return Print(a);
} }
...@@ -647,7 +649,7 @@ TEST(PrintArrayTest, WConstCharArrayWithTerminatingNul) { ...@@ -647,7 +649,7 @@ TEST(PrintArrayTest, WConstCharArrayWithTerminatingNul) {
// Array of objects. // Array of objects.
TEST(PrintArrayTest, ObjectArray) { TEST(PrintArrayTest, ObjectArray) {
string a[3] = { "Hi", "Hello", "Ni hao" }; std::string a[3] = {"Hi", "Hello", "Ni hao"};
EXPECT_EQ("{ \"Hi\", \"Hello\", \"Ni hao\" }", PrintArrayHelper(a)); EXPECT_EQ("{ \"Hi\", \"Hello\", \"Ni hao\" }", PrintArrayHelper(a));
} }
...@@ -829,7 +831,7 @@ TEST(PrintStlContainerTest, HashMultiMap) { ...@@ -829,7 +831,7 @@ TEST(PrintStlContainerTest, HashMultiMap) {
map1.insert(make_pair(5, false)); map1.insert(make_pair(5, false));
// Elements of hash_multimap can be printed in any order. // Elements of hash_multimap can be printed in any order.
const string result = Print(map1); const std::string result = Print(map1);
EXPECT_TRUE(result == "{ (5, true), (5, false) }" || EXPECT_TRUE(result == "{ (5, true), (5, false) }" ||
result == "{ (5, false), (5, true) }") result == "{ (5, false), (5, true) }")
<< " where Print(map1) returns \"" << result << "\"."; << " where Print(map1) returns \"" << result << "\".";
...@@ -840,9 +842,9 @@ TEST(PrintStlContainerTest, HashMultiMap) { ...@@ -840,9 +842,9 @@ TEST(PrintStlContainerTest, HashMultiMap) {
#if GTEST_HAS_HASH_SET_ #if GTEST_HAS_HASH_SET_
TEST(PrintStlContainerTest, HashSet) { TEST(PrintStlContainerTest, HashSet) {
hash_set<string> set1; hash_set<int> set1;
set1.insert("hello"); set1.insert(1);
EXPECT_EQ("{ \"hello\" }", Print(set1)); EXPECT_EQ("{ 1 }", Print(set1));
} }
TEST(PrintStlContainerTest, HashMultiSet) { TEST(PrintStlContainerTest, HashMultiSet) {
...@@ -851,8 +853,8 @@ TEST(PrintStlContainerTest, HashMultiSet) { ...@@ -851,8 +853,8 @@ TEST(PrintStlContainerTest, HashMultiSet) {
hash_multiset<int> set1(a, a + kSize); hash_multiset<int> set1(a, a + kSize);
// Elements of hash_multiset can be printed in any order. // Elements of hash_multiset can be printed in any order.
const string result = Print(set1); const std::string result = Print(set1);
const string expected_pattern = "{ d, d, d, d, d }"; // d means a digit. const std::string expected_pattern = "{ d, d, d, d, d }"; // d means a digit.
// Verifies the result matches the expected pattern; also extracts // Verifies the result matches the expected pattern; also extracts
// the numbers in the result. // the numbers in the result.
...@@ -877,11 +879,8 @@ TEST(PrintStlContainerTest, HashMultiSet) { ...@@ -877,11 +879,8 @@ TEST(PrintStlContainerTest, HashMultiSet) {
#endif // GTEST_HAS_HASH_SET_ #endif // GTEST_HAS_HASH_SET_
TEST(PrintStlContainerTest, List) { TEST(PrintStlContainerTest, List) {
const string a[] = { const std::string a[] = {"hello", "world"};
"hello", const list<std::string> strings(a, a + 2);
"world"
};
const list<string> strings(a, a + 2);
EXPECT_EQ("{ \"hello\", \"world\" }", Print(strings)); EXPECT_EQ("{ \"hello\", \"world\" }", Print(strings));
} }
...@@ -1037,9 +1036,10 @@ TEST(PrintTr1TupleTest, VariousSizes) { ...@@ -1037,9 +1036,10 @@ TEST(PrintTr1TupleTest, VariousSizes) {
// VC++ 2010's implementation of tuple of C++0x is deficient, requiring // VC++ 2010's implementation of tuple of C++0x is deficient, requiring
// an explicit type cast of NULL to be used. // an explicit type cast of NULL to be used.
::std::tr1::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> testing::internal::Int64, float, double, const char*, void*,
t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str, std::string>
ImplicitCast_<void*>(NULL), "10"); 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) + EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
" pointing to \"8\", NULL, \"10\")", " pointing to \"8\", NULL, \"10\")",
Print(t10)); Print(t10));
...@@ -1096,9 +1096,10 @@ TEST(PrintStdTupleTest, VariousSizes) { ...@@ -1096,9 +1096,10 @@ TEST(PrintStdTupleTest, VariousSizes) {
// VC++ 2010's implementation of tuple of C++0x is deficient, requiring // VC++ 2010's implementation of tuple of C++0x is deficient, requiring
// an explicit type cast of NULL to be used. // an explicit type cast of NULL to be used.
::std::tuple<bool, char, short, testing::internal::Int32, // NOLINT ::std::tuple<bool, char, short, testing::internal::Int32, // NOLINT
testing::internal::Int64, float, double, const char*, void*, string> testing::internal::Int64, float, double, const char*, void*,
t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str, std::string>
ImplicitCast_<void*>(NULL), "10"); 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) + EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
" pointing to \"8\", NULL, \"10\")", " pointing to \"8\", NULL, \"10\")",
Print(t10)); Print(t10));
...@@ -1202,13 +1203,13 @@ TEST(PrintReferenceTest, PrintsAddressAndValue) { ...@@ -1202,13 +1203,13 @@ TEST(PrintReferenceTest, PrintsAddressAndValue) {
// reference. // reference.
TEST(PrintReferenceTest, HandlesFunctionPointer) { TEST(PrintReferenceTest, HandlesFunctionPointer) {
void (*fp)(int n) = &MyFunction; void (*fp)(int n) = &MyFunction;
const string fp_pointer_string = const std::string fp_pointer_string =
PrintPointer(reinterpret_cast<const void*>(&fp)); PrintPointer(reinterpret_cast<const void*>(&fp));
// We cannot directly cast &MyFunction to const void* because the // We cannot directly cast &MyFunction to const void* because the
// standard disallows casting between pointers to functions and // standard disallows casting between pointers to functions and
// pointers to objects, and some compilers (e.g. GCC 3.4) enforce // pointers to objects, and some compilers (e.g. GCC 3.4) enforce
// this limitation. // this limitation.
const string fp_string = PrintPointer(reinterpret_cast<const void*>( const std::string fp_string = PrintPointer(reinterpret_cast<const void*>(
reinterpret_cast<internal::BiggestInt>(fp))); reinterpret_cast<internal::BiggestInt>(fp)));
EXPECT_EQ("@" + fp_pointer_string + " " + fp_string, EXPECT_EQ("@" + fp_pointer_string + " " + fp_string,
PrintByRef(fp)); PrintByRef(fp));
...@@ -1540,12 +1541,12 @@ TEST(UniversalPrintTest, WorksForCString) { ...@@ -1540,12 +1541,12 @@ TEST(UniversalPrintTest, WorksForCString) {
const char* s1 = "abc"; const char* s1 = "abc";
::std::stringstream ss1; ::std::stringstream ss1;
UniversalPrint(s1, &ss1); UniversalPrint(s1, &ss1);
EXPECT_EQ(PrintPointer(s1) + " pointing to \"abc\"", string(ss1.str())); EXPECT_EQ(PrintPointer(s1) + " pointing to \"abc\"", std::string(ss1.str()));
char* s2 = const_cast<char*>(s1); char* s2 = const_cast<char*>(s1);
::std::stringstream ss2; ::std::stringstream ss2;
UniversalPrint(s2, &ss2); UniversalPrint(s2, &ss2);
EXPECT_EQ(PrintPointer(s2) + " pointing to \"abc\"", string(ss2.str())); EXPECT_EQ(PrintPointer(s2) + " pointing to \"abc\"", std::string(ss2.str()));
const char* s3 = NULL; const char* s3 = NULL;
::std::stringstream ss3; ::std::stringstream ss3;
...@@ -1634,4 +1635,3 @@ TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTersely) { ...@@ -1634,4 +1635,3 @@ TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTersely) {
} // namespace gtest_printers_test } // namespace gtest_printers_test
} // namespace testing } // namespace testing
...@@ -138,7 +138,7 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) { ...@@ -138,7 +138,7 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
} }
// Exceptions in destructors are not supported in C++11. // Exceptions in destructors are not supported in C++11.
#if !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L #if !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L && _MSC_VER < 1900
class CxxExceptionInDestructorTest : public Test { class CxxExceptionInDestructorTest : public Test {
public: public:
static void TearDownTestCase() { static void TearDownTestCase() {
......
...@@ -245,7 +245,7 @@ class Subprocess: ...@@ -245,7 +245,7 @@ class Subprocess:
p = subprocess.Popen(command, p = subprocess.Popen(command,
stdout=subprocess.PIPE, stderr=stderr, stdout=subprocess.PIPE, stderr=stderr,
cwd=working_dir, universal_newlines=True, env=env) cwd=working_dir, universal_newlines=True, env=env)
# communicate returns a tuple with the file obect for the child's # communicate returns a tuple with the file object for the child's
# output. # output.
self.output = p.communicate()[0] self.output = p.communicate()[0]
self._return_code = p.returncode self._return_code = p.returncode
......
...@@ -86,9 +86,9 @@ class StreamingListenerTest : public Test { ...@@ -86,9 +86,9 @@ class StreamingListenerTest : public Test {
class FakeSocketWriter : public StreamingListener::AbstractSocketWriter { class FakeSocketWriter : public StreamingListener::AbstractSocketWriter {
public: public:
// Sends a string to the socket. // Sends a string to the socket.
virtual void Send(const string& message) { output_ += message; } virtual void Send(const std::string& message) { output_ += message; }
string output_; std::string output_;
}; };
StreamingListenerTest() StreamingListenerTest()
...@@ -98,7 +98,7 @@ class StreamingListenerTest : public Test { ...@@ -98,7 +98,7 @@ class StreamingListenerTest : public Test {
CodeLocation(__FILE__, __LINE__), 0, NULL) {} CodeLocation(__FILE__, __LINE__), 0, NULL) {}
protected: protected:
string* output() { return &(fake_sock_writer_->output_); } std::string* output() { return &(fake_sock_writer_->output_); }
FakeSocketWriter* const fake_sock_writer_; FakeSocketWriter* const fake_sock_writer_;
StreamingListener streamer_; StreamingListener streamer_;
...@@ -1388,7 +1388,7 @@ class TestResultTest : public Test { ...@@ -1388,7 +1388,7 @@ class TestResultTest : public Test {
delete r2; delete r2;
} }
// Helper that compares two two TestPartResults. // Helper that compares two TestPartResults.
static void CompareTestPartResult(const TestPartResult& expected, static void CompareTestPartResult(const TestPartResult& expected,
const TestPartResult& actual) { const TestPartResult& actual) {
EXPECT_EQ(expected.type(), actual.type()); EXPECT_EQ(expected.type(), actual.type());
...@@ -3689,7 +3689,7 @@ TEST(AssertionTest, ASSERT_EQ) { ...@@ -3689,7 +3689,7 @@ TEST(AssertionTest, ASSERT_EQ) {
TEST(AssertionTest, ASSERT_EQ_NULL) { TEST(AssertionTest, ASSERT_EQ_NULL) {
// A success. // A success.
const char* p = NULL; const char* p = NULL;
// Some older GCC versions may issue a spurious waring in this or the next // Some older GCC versions may issue a spurious warning in this or the next
// assertion statement. This warning should not be suppressed with // assertion statement. This warning should not be suppressed with
// static_cast since the test verifies the ability to use bare NULL as the // static_cast since the test verifies the ability to use bare NULL as the
// expected parameter to the macro. // expected parameter to the macro.
...@@ -6411,7 +6411,7 @@ class FlagfileTest : public InitGoogleTestTest { ...@@ -6411,7 +6411,7 @@ class FlagfileTest : public InitGoogleTestTest {
InitGoogleTestTest::SetUp(); InitGoogleTestTest::SetUp();
testdata_path_.Set(internal::FilePath( testdata_path_.Set(internal::FilePath(
internal::TempDir() + internal::GetCurrentExecutableName().string() + testing::TempDir() + internal::GetCurrentExecutableName().string() +
"_flagfile_test")); "_flagfile_test"));
testing::internal::posix::RmDir(testdata_path_.c_str()); testing::internal::posix::RmDir(testdata_path_.c_str());
EXPECT_TRUE(testdata_path_.CreateFolder()); EXPECT_TRUE(testdata_path_.CreateFolder());
...@@ -7703,4 +7703,3 @@ TEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) { ...@@ -7703,4 +7703,3 @@ TEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) {
EXPECT_FALSE(SkipPrefix("world!", &p)); EXPECT_FALSE(SkipPrefix("world!", &p));
EXPECT_EQ(str, p); EXPECT_EQ(str, p);
} }
...@@ -105,7 +105,7 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase): ...@@ -105,7 +105,7 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase):
# TODO(wan@google.com): libtool causes the built test binary to be # TODO(wan@google.com): libtool causes the built test binary to be
# named lt-gtest_xml_outfiles_test_ instead of # named lt-gtest_xml_outfiles_test_ instead of
# gtest_xml_outfiles_test_. To account for this possibillity, we # gtest_xml_outfiles_test_. To account for this possibility, we
# allow both names in the following code. We should remove this # allow both names in the following code. We should remove this
# hack when Chandler Carruth's libtool replacement tool is ready. # hack when Chandler Carruth's libtool replacement tool is ready.
output_file_name1 = test_name + ".xml" output_file_name1 = test_name + ".xml"
......
...@@ -237,7 +237,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): ...@@ -237,7 +237,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
'--shut_down_xml'] '--shut_down_xml']
p = gtest_test_utils.Subprocess(command) p = gtest_test_utils.Subprocess(command)
if p.terminated_by_signal: if p.terminated_by_signal:
# p.signal is avalable only if p.terminated_by_signal is True. # p.signal is available only if p.terminated_by_signal is True.
self.assertFalse( self.assertFalse(
p.terminated_by_signal, p.terminated_by_signal,
'%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal)) '%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal))
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
1. The AC_INIT macro will be contained within the first 1024 characters 1. The AC_INIT macro will be contained within the first 1024 characters
of configure.ac of configure.ac
2. The version string will be 3 integers separated by periods and will be 2. The version string will be 3 integers separated by periods and will be
surrounded by squre brackets, "[" and "]" (e.g. [1.0.1]). The first surrounded by square brackets, "[" and "]" (e.g. [1.0.1]). The first
segment represents the major version, the second represents the minor segment represents the major version, the second represents the minor
version and the third represents the fix version. version and the third represents the fix version.
3. No ")" character exists between the opening "(" and closing ")" of 3. No ")" character exists between the opening "(" and closing ")" of
...@@ -68,7 +68,7 @@ config_file.close() ...@@ -68,7 +68,7 @@ config_file.close()
# Extract the version string from the AC_INIT macro # Extract the version string from the AC_INIT macro
# The following init_expression means: # The following init_expression means:
# Extract three integers separated by periods and surrounded by squre # Extract three integers separated by periods and surrounded by square
# brackets(e.g. "[1.0.1]") between "AC_INIT(" and ")". Do not be greedy # brackets(e.g. "[1.0.1]") between "AC_INIT(" and ")". Do not be greedy
# (*? is the non-greedy flag) since that would pull in everything between # (*? is the non-greedy flag) since that would pull in everything between
# the first "(" and the last ")" in the file. # the first "(" and the last ")" in the file.
...@@ -88,7 +88,7 @@ file_data = """// ...@@ -88,7 +88,7 @@ file_data = """//
// is executed in a "Run Script" build phase when creating gtest.framework. This // is executed in a "Run Script" build phase when creating gtest.framework. This
// header file is not used during compilation of C-source. Rather, it simply // header file is not used during compilation of C-source. Rather, it simply
// defines some version strings for substitution in the Info.plist. Because of // defines some version strings for substitution in the Info.plist. Because of
// this, we are not not restricted to C-syntax nor are we using include guards. // this, we are not restricted to C-syntax nor are we using include guards.
// //
#define GTEST_VERSIONINFO_SHORT %s.%s #define GTEST_VERSIONINFO_SHORT %s.%s
......
...@@ -79,6 +79,13 @@ ...@@ -79,6 +79,13 @@
4539C9390EC280E200A70F4C /* gtest-param-util-generated.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 4539C9360EC280E200A70F4C /* gtest-param-util-generated.h */; }; 4539C9390EC280E200A70F4C /* gtest-param-util-generated.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 4539C9360EC280E200A70F4C /* gtest-param-util-generated.h */; };
4539C93A0EC280E200A70F4C /* gtest-param-util.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 4539C9370EC280E200A70F4C /* gtest-param-util.h */; }; 4539C93A0EC280E200A70F4C /* gtest-param-util.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 4539C9370EC280E200A70F4C /* gtest-param-util.h */; };
4567C8181264FF71007740BE /* gtest-printers.h in Headers */ = {isa = PBXBuildFile; fileRef = 4567C8171264FF71007740BE /* gtest-printers.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4567C8181264FF71007740BE /* gtest-printers.h in Headers */ = {isa = PBXBuildFile; fileRef = 4567C8171264FF71007740BE /* gtest-printers.h */; settings = {ATTRIBUTES = (Public, ); }; };
F67D4F3E1C7F5D8B0017C729 /* gtest-port-arch.h in Headers */ = {isa = PBXBuildFile; fileRef = F67D4F3D1C7F5D8B0017C729 /* gtest-port-arch.h */; };
F67D4F3F1C7F5DA70017C729 /* gtest-port-arch.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = F67D4F3D1C7F5D8B0017C729 /* gtest-port-arch.h */; };
F67D4F441C7F5DD00017C729 /* gtest-port.h in Headers */ = {isa = PBXBuildFile; fileRef = F67D4F411C7F5DD00017C729 /* gtest-port.h */; };
F67D4F451C7F5DD00017C729 /* gtest-printers.h in Headers */ = {isa = PBXBuildFile; fileRef = F67D4F421C7F5DD00017C729 /* gtest-printers.h */; };
F67D4F461C7F5DD00017C729 /* gtest.h in Headers */ = {isa = PBXBuildFile; fileRef = F67D4F431C7F5DD00017C729 /* gtest.h */; };
F67D4F481C7F5E160017C729 /* gtest-port.h in Copy Headers Internal Custom */ = {isa = PBXBuildFile; fileRef = F67D4F411C7F5DD00017C729 /* gtest-port.h */; };
F67D4F491C7F5E260017C729 /* gtest-printers.h in Copy Headers Internal Custom */ = {isa = PBXBuildFile; fileRef = F67D4F421C7F5DD00017C729 /* gtest-printers.h */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
...@@ -182,6 +189,7 @@ ...@@ -182,6 +189,7 @@
dstPath = Headers/internal; dstPath = Headers/internal;
dstSubfolderSpec = 6; dstSubfolderSpec = 6;
files = ( files = (
F67D4F3F1C7F5DA70017C729 /* gtest-port-arch.h in Copy Headers Internal */,
404884A00E2F7BE600CF7658 /* gtest-death-test-internal.h in Copy Headers Internal */, 404884A00E2F7BE600CF7658 /* gtest-death-test-internal.h in Copy Headers Internal */,
404884A10E2F7BE600CF7658 /* gtest-filepath.h in Copy Headers Internal */, 404884A10E2F7BE600CF7658 /* gtest-filepath.h in Copy Headers Internal */,
404884A20E2F7BE600CF7658 /* gtest-internal.h in Copy Headers Internal */, 404884A20E2F7BE600CF7658 /* gtest-internal.h in Copy Headers Internal */,
...@@ -196,6 +204,18 @@ ...@@ -196,6 +204,18 @@
name = "Copy Headers Internal"; name = "Copy Headers Internal";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
F67D4F471C7F5DF60017C729 /* Copy Headers Internal Custom */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = Headers/internal/custom;
dstSubfolderSpec = 6;
files = (
F67D4F491C7F5E260017C729 /* gtest-printers.h in Copy Headers Internal Custom */,
F67D4F481C7F5E160017C729 /* gtest-port.h in Copy Headers Internal Custom */,
);
name = "Copy Headers Internal Custom";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
...@@ -244,6 +264,10 @@ ...@@ -244,6 +264,10 @@
4539C9360EC280E200A70F4C /* gtest-param-util-generated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "gtest-param-util-generated.h"; sourceTree = "<group>"; }; 4539C9360EC280E200A70F4C /* gtest-param-util-generated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "gtest-param-util-generated.h"; sourceTree = "<group>"; };
4539C9370EC280E200A70F4C /* gtest-param-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "gtest-param-util.h"; sourceTree = "<group>"; }; 4539C9370EC280E200A70F4C /* gtest-param-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "gtest-param-util.h"; sourceTree = "<group>"; };
4567C8171264FF71007740BE /* gtest-printers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "gtest-printers.h"; sourceTree = "<group>"; }; 4567C8171264FF71007740BE /* gtest-printers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "gtest-printers.h"; sourceTree = "<group>"; };
F67D4F3D1C7F5D8B0017C729 /* gtest-port-arch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "gtest-port-arch.h"; sourceTree = "<group>"; };
F67D4F411C7F5DD00017C729 /* gtest-port.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "gtest-port.h"; sourceTree = "<group>"; };
F67D4F421C7F5DD00017C729 /* gtest-printers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "gtest-printers.h"; sourceTree = "<group>"; };
F67D4F431C7F5DD00017C729 /* gtest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gtest.h; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -375,6 +399,7 @@ ...@@ -375,6 +399,7 @@
404883E10E2F799B00CF7658 /* internal */ = { 404883E10E2F799B00CF7658 /* internal */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
F67D4F401C7F5DD00017C729 /* custom */,
404883E20E2F799B00CF7658 /* gtest-death-test-internal.h */, 404883E20E2F799B00CF7658 /* gtest-death-test-internal.h */,
404883E30E2F799B00CF7658 /* gtest-filepath.h */, 404883E30E2F799B00CF7658 /* gtest-filepath.h */,
404883E40E2F799B00CF7658 /* gtest-internal.h */, 404883E40E2F799B00CF7658 /* gtest-internal.h */,
...@@ -382,6 +407,7 @@ ...@@ -382,6 +407,7 @@
4539C9360EC280E200A70F4C /* gtest-param-util-generated.h */, 4539C9360EC280E200A70F4C /* gtest-param-util-generated.h */,
4539C9370EC280E200A70F4C /* gtest-param-util.h */, 4539C9370EC280E200A70F4C /* gtest-param-util.h */,
404883E50E2F799B00CF7658 /* gtest-port.h */, 404883E50E2F799B00CF7658 /* gtest-port.h */,
F67D4F3D1C7F5D8B0017C729 /* gtest-port-arch.h */,
404883E60E2F799B00CF7658 /* gtest-string.h */, 404883E60E2F799B00CF7658 /* gtest-string.h */,
40899F4D0FFA7271000B29AE /* gtest-tuple.h */, 40899F4D0FFA7271000B29AE /* gtest-tuple.h */,
3BF6F29F0E79B5AD000F2EEE /* gtest-type-util.h */, 3BF6F29F0E79B5AD000F2EEE /* gtest-type-util.h */,
...@@ -430,6 +456,16 @@ ...@@ -430,6 +456,16 @@
path = Resources; path = Resources;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
F67D4F401C7F5DD00017C729 /* custom */ = {
isa = PBXGroup;
children = (
F67D4F411C7F5DD00017C729 /* gtest-port.h */,
F67D4F421C7F5DD00017C729 /* gtest-printers.h */,
F67D4F431C7F5DD00017C729 /* gtest.h */,
);
path = custom;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */ /* Begin PBXHeadersBuildPhase section */
...@@ -437,10 +473,14 @@ ...@@ -437,10 +473,14 @@
isa = PBXHeadersBuildPhase; isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
F67D4F451C7F5DD00017C729 /* gtest-printers.h in Headers */,
404884380E2F799B00CF7658 /* gtest-death-test.h in Headers */, 404884380E2F799B00CF7658 /* gtest-death-test.h in Headers */,
404884390E2F799B00CF7658 /* gtest-message.h in Headers */, 404884390E2F799B00CF7658 /* gtest-message.h in Headers */,
4539C9340EC280AE00A70F4C /* gtest-param-test.h in Headers */, 4539C9340EC280AE00A70F4C /* gtest-param-test.h in Headers */,
F67D4F461C7F5DD00017C729 /* gtest.h in Headers */,
F67D4F441C7F5DD00017C729 /* gtest-port.h in Headers */,
4567C8181264FF71007740BE /* gtest-printers.h in Headers */, 4567C8181264FF71007740BE /* gtest-printers.h in Headers */,
F67D4F3E1C7F5D8B0017C729 /* gtest-port-arch.h in Headers */,
3BF6F2A50E79B616000F2EEE /* gtest-typed-test.h in Headers */, 3BF6F2A50E79B616000F2EEE /* gtest-typed-test.h in Headers */,
4048843A0E2F799B00CF7658 /* gtest-spi.h in Headers */, 4048843A0E2F799B00CF7658 /* gtest-spi.h in Headers */,
4048843B0E2F799B00CF7658 /* gtest.h in Headers */, 4048843B0E2F799B00CF7658 /* gtest.h in Headers */,
...@@ -560,6 +600,7 @@ ...@@ -560,6 +600,7 @@
8D07F2C10486CC7A007CD1D0 /* Sources */, 8D07F2C10486CC7A007CD1D0 /* Sources */,
8D07F2BD0486CC7A007CD1D0 /* Headers */, 8D07F2BD0486CC7A007CD1D0 /* Headers */,
404884A50E2F7C0400CF7658 /* Copy Headers Internal */, 404884A50E2F7C0400CF7658 /* Copy Headers Internal */,
F67D4F471C7F5DF60017C729 /* Copy Headers Internal Custom */,
8D07F2BF0486CC7A007CD1D0 /* Resources */, 8D07F2BF0486CC7A007CD1D0 /* Resources */,
); );
buildRules = ( buildRules = (
...@@ -1026,6 +1067,9 @@ ...@@ -1026,6 +1067,9 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 40D4CDF10E30E07400294801 /* DebugProject.xcconfig */; baseConfigurationReference = 40D4CDF10E30E07400294801 /* DebugProject.xcconfig */;
buildSettings = { buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
MACOSX_DEPLOYMENT_TARGET = 10.7;
}; };
name = Debug; name = Debug;
}; };
...@@ -1033,6 +1077,9 @@ ...@@ -1033,6 +1077,9 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 40D4CDF40E30E07400294801 /* ReleaseProject.xcconfig */; baseConfigurationReference = 40D4CDF40E30E07400294801 /* ReleaseProject.xcconfig */;
buildSettings = { buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
MACOSX_DEPLOYMENT_TARGET = 10.7;
}; };
name = Release; name = Release;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment