Unverified Commit 7e7e3a6f authored by Gennadiy Civil's avatar Gennadiy Civil Committed by GitHub
Browse files

Merge branch 'master' into patch-1

parents b50b2f77 997d343d
...@@ -250,7 +250,7 @@ bool FilePath::DirectoryExists() const { ...@@ -250,7 +250,7 @@ bool FilePath::DirectoryExists() const {
// root directory per disk drive.) // root directory per disk drive.)
bool FilePath::IsRootDirectory() const { bool FilePath::IsRootDirectory() const {
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
// TODO(wan@google.com): on Windows a network share like // FIXME: on Windows a network share like
// \\server\share can be a root directory, although it cannot be the // \\server\share can be a root directory, although it cannot be the
// current directory. Handle this properly. // current directory. Handle this properly.
return pathname_.length() == 3 && IsAbsolutePath(); return pathname_.length() == 3 && IsAbsolutePath();
...@@ -350,7 +350,7 @@ FilePath FilePath::RemoveTrailingPathSeparator() const { ...@@ -350,7 +350,7 @@ FilePath FilePath::RemoveTrailingPathSeparator() const {
// Removes any redundant separators that might be in the pathname. // Removes any redundant separators that might be in the pathname.
// For example, "bar///foo" becomes "bar/foo". Does not eliminate other // For example, "bar///foo" becomes "bar/foo". Does not eliminate other
// redundancies that might be in a pathname involving "." or "..". // redundancies that might be in a pathname involving "." or "..".
// TODO(wan@google.com): handle Windows network shares (e.g. \\server\share). // FIXME: handle Windows network shares (e.g. \\server\share).
void FilePath::Normalize() { void FilePath::Normalize() {
if (pathname_.c_str() == NULL) { if (pathname_.c_str() == NULL) {
pathname_ = ""; pathname_ = "";
......
...@@ -27,10 +27,7 @@ ...@@ -27,10 +27,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Utility functions and classes used by the Google C++ testing framework. // Utility functions and classes used by the Google C++ testing framework.//
//
// Author: wan@google.com (Zhanyong Wan)
//
// This file contains purely Google Test's internal implementation. Please // This file contains purely Google Test's internal implementation. Please
// DO NOT #INCLUDE IT IN A USER PROGRAM. // DO NOT #INCLUDE IT IN A USER PROGRAM.
...@@ -446,6 +443,16 @@ class OsStackTraceGetter : public OsStackTraceGetterInterface { ...@@ -446,6 +443,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);
}; };
...@@ -984,7 +991,7 @@ bool ParseNaturalNumber(const ::std::string& str, Integer* number) { ...@@ -984,7 +991,7 @@ bool ParseNaturalNumber(const ::std::string& str, Integer* number) {
const bool parse_success = *end == '\0' && errno == 0; const bool parse_success = *end == '\0' && errno == 0;
// TODO(vladl@google.com): Convert this to compile time assertion when it is // FIXME: Convert this to compile time assertion when it is
// available. // available.
GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed)); GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed));
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
#include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-port.h"
...@@ -262,9 +261,9 @@ Mutex::Mutex() ...@@ -262,9 +261,9 @@ Mutex::Mutex()
Mutex::~Mutex() { Mutex::~Mutex() {
// Static mutexes are leaked intentionally. It is not thread-safe to try // Static mutexes are leaked intentionally. It is not thread-safe to try
// to clean them up. // to clean them up.
// TODO(yukawa): Switch to Slim Reader/Writer (SRW) Locks, which requires // FIXME: Switch to Slim Reader/Writer (SRW) Locks, which requires
// nothing to clean it up but is available only on Vista and later. // nothing to clean it up but is available only on Vista and later.
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa904937.aspx // https://docs.microsoft.com/en-us/windows/desktop/Sync/slim-reader-writer--srw--locks
if (type_ == kDynamic) { if (type_ == kDynamic) {
::DeleteCriticalSection(critical_section_); ::DeleteCriticalSection(critical_section_);
delete critical_section_; delete critical_section_;
...@@ -344,7 +343,7 @@ class ThreadWithParamSupport : public ThreadWithParamBase { ...@@ -344,7 +343,7 @@ class ThreadWithParamSupport : public ThreadWithParamBase {
Notification* thread_can_start) { Notification* thread_can_start) {
ThreadMainParam* param = new ThreadMainParam(runnable, thread_can_start); ThreadMainParam* param = new ThreadMainParam(runnable, thread_can_start);
DWORD thread_id; DWORD thread_id;
// TODO(yukawa): Consider to use _beginthreadex instead. // FIXME: Consider to use _beginthreadex instead.
HANDLE thread_handle = ::CreateThread( HANDLE thread_handle = ::CreateThread(
NULL, // Default security. NULL, // Default security.
0, // Default stack size. 0, // Default stack size.
...@@ -696,7 +695,7 @@ static std::string FormatRegexSyntaxError(const char* regex, int index) { ...@@ -696,7 +695,7 @@ static std::string FormatRegexSyntaxError(const char* regex, int index) {
// otherwise returns true. // otherwise returns true.
bool ValidateRegex(const char* regex) { bool ValidateRegex(const char* regex) {
if (regex == NULL) { if (regex == NULL) {
// TODO(wan@google.com): fix the source file location in the // FIXME: fix the source file location in the
// assertion failures to match where the regex is used in user // assertion failures to match where the regex is used in user
// code. // code.
ADD_FAILURE() << "NULL is not a valid simple regular expression."; ADD_FAILURE() << "NULL is not a valid simple regular expression.";
...@@ -942,7 +941,7 @@ GTestLog::~GTestLog() { ...@@ -942,7 +941,7 @@ GTestLog::~GTestLog() {
// Disable Microsoft deprecation warnings for POSIX functions called from // Disable Microsoft deprecation warnings for POSIX functions called from
// this class (creat, dup, dup2, and close) // this class (creat, dup, dup2, and close)
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
#if GTEST_HAS_STREAM_REDIRECTION #if GTEST_HAS_STREAM_REDIRECTION
...@@ -1026,7 +1025,7 @@ class CapturedStream { ...@@ -1026,7 +1025,7 @@ class CapturedStream {
GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream); GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream);
}; };
GTEST_DISABLE_MSC_WARNINGS_POP_() GTEST_DISABLE_MSC_DEPRECATED_POP_()
static CapturedStream* g_captured_stderr = NULL; static CapturedStream* g_captured_stderr = NULL;
static CapturedStream* g_captured_stdout = NULL; static CapturedStream* g_captured_stdout = NULL;
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Test - The Google C++ Testing and Mocking Framework // Google Test - The Google C++ Testing and Mocking Framework
// //
...@@ -90,7 +89,7 @@ void PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count, ...@@ -90,7 +89,7 @@ void PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count,
// If the object size is bigger than kThreshold, we'll have to omit // If the object size is bigger than kThreshold, we'll have to omit
// some details by printing only the first and the last kChunkSize // some details by printing only the first and the last kChunkSize
// bytes. // bytes.
// TODO(wan): let the user control the threshold using a flag. // FIXME: let the user control the threshold using a flag.
if (count < kThreshold) { if (count < kThreshold) {
PrintByteSegmentInObjectTo(obj_bytes, 0, count, os); PrintByteSegmentInObjectTo(obj_bytes, 0, count, os);
} else { } else {
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: mheule@google.com (Markus Heule)
// //
// The Google C++ Testing and Mocking Framework (Google Test) // The Google C++ Testing and Mocking Framework (Google Test)
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
#include "gtest/gtest-typed-test.h" #include "gtest/gtest-typed-test.h"
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// //
// The Google C++ Testing and Mocking Framework (Google Test) // The Google C++ Testing and Mocking Framework (Google Test)
...@@ -55,7 +54,7 @@ ...@@ -55,7 +54,7 @@
#if GTEST_OS_LINUX #if GTEST_OS_LINUX
// TODO(kenton@google.com): Use autoconf to detect availability of // FIXME: Use autoconf to detect availability of
// gettimeofday(). // gettimeofday().
# define GTEST_HAS_GETTIMEOFDAY_ 1 # define GTEST_HAS_GETTIMEOFDAY_ 1
...@@ -94,9 +93,9 @@ ...@@ -94,9 +93,9 @@
# if GTEST_OS_WINDOWS_MINGW # if GTEST_OS_WINDOWS_MINGW
// MinGW has gettimeofday() but not _ftime64(). // MinGW has gettimeofday() but not _ftime64().
// TODO(kenton@google.com): Use autoconf to detect availability of // FIXME: Use autoconf to detect availability of
// gettimeofday(). // gettimeofday().
// TODO(kenton@google.com): There are other ways to get the time on // FIXME: There are other ways to get the time on
// Windows, like GetTickCount() or GetSystemTimeAsFileTime(). MinGW // Windows, like GetTickCount() or GetSystemTimeAsFileTime(). MinGW
// supports these. consider using them instead. // supports these. consider using them instead.
# define GTEST_HAS_GETTIMEOFDAY_ 1 # define GTEST_HAS_GETTIMEOFDAY_ 1
...@@ -111,7 +110,7 @@ ...@@ -111,7 +110,7 @@
#else #else
// Assume other platforms have gettimeofday(). // Assume other platforms have gettimeofday().
// TODO(kenton@google.com): Use autoconf to detect availability of // FIXME: Use autoconf to detect availability of
// gettimeofday(). // gettimeofday().
# define GTEST_HAS_GETTIMEOFDAY_ 1 # define GTEST_HAS_GETTIMEOFDAY_ 1
...@@ -139,6 +138,13 @@ ...@@ -139,6 +138,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 +234,13 @@ GTEST_DEFINE_string_( ...@@ -228,6 +234,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.");
...@@ -454,7 +467,7 @@ std::string UnitTestOptions::GetAbsolutePathToOutputFile() { ...@@ -454,7 +467,7 @@ std::string UnitTestOptions::GetAbsolutePathToOutputFile() {
internal::FilePath output_name(colon + 1); internal::FilePath output_name(colon + 1);
if (!output_name.IsAbsolutePath()) if (!output_name.IsAbsolutePath())
// TODO(wan@google.com): on Windows \some\path is not an absolute // FIXME: on Windows \some\path is not an absolute
// path (as its meaning depends on the current drive), yet the // path (as its meaning depends on the current drive), yet the
// following logic for turning it into an absolute path is wrong. // following logic for turning it into an absolute path is wrong.
// Fix it. // Fix it.
...@@ -828,7 +841,7 @@ TimeInMillis GetTimeInMillis() { ...@@ -828,7 +841,7 @@ TimeInMillis GetTimeInMillis() {
SYSTEMTIME now_systime; SYSTEMTIME now_systime;
FILETIME now_filetime; FILETIME now_filetime;
ULARGE_INTEGER now_int64; ULARGE_INTEGER now_int64;
// TODO(kenton@google.com): Shouldn't this just use // FIXME: Shouldn't this just use
// GetSystemTimeAsFileTime()? // GetSystemTimeAsFileTime()?
GetSystemTime(&now_systime); GetSystemTime(&now_systime);
if (SystemTimeToFileTime(&now_systime, &now_filetime)) { if (SystemTimeToFileTime(&now_systime, &now_filetime)) {
...@@ -844,11 +857,11 @@ TimeInMillis GetTimeInMillis() { ...@@ -844,11 +857,11 @@ TimeInMillis GetTimeInMillis() {
// MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996 // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996
// (deprecated function) there. // (deprecated function) there.
// TODO(kenton@google.com): Use GetTickCount()? Or use // FIXME: Use GetTickCount()? Or use
// SystemTimeToFileTime() // SystemTimeToFileTime()
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
_ftime64(&now); _ftime64(&now);
GTEST_DISABLE_MSC_WARNINGS_POP_() GTEST_DISABLE_MSC_DEPRECATED_POP_()
return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm; return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm;
#elif GTEST_HAS_GETTIMEOFDAY_ #elif GTEST_HAS_GETTIMEOFDAY_
...@@ -1383,7 +1396,7 @@ AssertionResult DoubleNearPredFormat(const char* expr1, ...@@ -1383,7 +1396,7 @@ AssertionResult DoubleNearPredFormat(const char* expr1,
const double diff = fabs(val1 - val2); const double diff = fabs(val1 - val2);
if (diff <= abs_error) return AssertionSuccess(); if (diff <= abs_error) return AssertionSuccess();
// TODO(wan): do not print the value of an expression if it's // FIXME: do not print the value of an expression if it's
// already a literal. // already a literal.
return AssertionFailure() return AssertionFailure()
<< "The difference between " << expr1 << " and " << expr2 << "The difference between " << expr1 << " and " << expr2
...@@ -3124,6 +3137,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationStart( ...@@ -3124,6 +3137,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationStart(
"Note: Randomizing tests' orders with a seed of %d .\n", "Note: Randomizing tests' orders with a seed of %d .\n",
unit_test.random_seed()); unit_test.random_seed());
} }
ColoredPrintf(COLOR_GREEN, "[==========] "); ColoredPrintf(COLOR_GREEN, "[==========] ");
printf("Running %s from %s.\n", printf("Running %s from %s.\n",
FormatTestCount(unit_test.test_to_run_count()).c_str(), FormatTestCount(unit_test.test_to_run_count()).c_str(),
...@@ -3320,7 +3334,7 @@ void TestEventRepeater::Append(TestEventListener *listener) { ...@@ -3320,7 +3334,7 @@ void TestEventRepeater::Append(TestEventListener *listener) {
listeners_.push_back(listener); listeners_.push_back(listener);
} }
// TODO(vladl@google.com): Factor the search functionality into Vector::Find. // FIXME: Factor the search functionality into Vector::Find.
TestEventListener* TestEventRepeater::Release(TestEventListener *listener) { TestEventListener* TestEventRepeater::Release(TestEventListener *listener) {
for (size_t i = 0; i < listeners_.size(); ++i) { for (size_t i = 0; i < listeners_.size(); ++i) {
if (listeners_[i] == listener) { if (listeners_[i] == listener) {
...@@ -3485,7 +3499,7 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, ...@@ -3485,7 +3499,7 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
xmlout = posix::FOpen(output_file_.c_str(), "w"); xmlout = posix::FOpen(output_file_.c_str(), "w");
} }
if (xmlout == NULL) { if (xmlout == NULL) {
// TODO(wan): report the reason of the failure. // FIXME: report the reason of the failure.
// //
// We don't do it for now as: // We don't do it for now as:
// //
...@@ -3514,7 +3528,7 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, ...@@ -3514,7 +3528,7 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
// module will consist of ordinary English text. // module will consist of ordinary English text.
// If this module is ever modified to produce version 1.1 XML output, // If this module is ever modified to produce version 1.1 XML output,
// most invalid characters can be retained using character references. // most invalid characters can be retained using character references.
// TODO(wan): It might be nice to have a minimally invasive, human-readable // FIXME: It might be nice to have a minimally invasive, human-readable
// escaping scheme for invalid characters, rather than dropping them. // escaping scheme for invalid characters, rather than dropping them.
std::string XmlUnitTestResultPrinter::EscapeXml( std::string XmlUnitTestResultPrinter::EscapeXml(
const std::string& str, bool is_attribute) { const std::string& str, bool is_attribute) {
...@@ -3575,6 +3589,7 @@ std::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters( ...@@ -3575,6 +3589,7 @@ std::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters(
// The following routines generate an XML representation of a UnitTest // The following routines generate an XML representation of a UnitTest
// object. // object.
// GOOGLETEST_CM0009 DO NOT DELETE
// //
// This is how Google Test concepts map to the DTD: // This is how Google Test concepts map to the DTD:
// //
...@@ -3664,7 +3679,7 @@ void XmlUnitTestResultPrinter::OutputXmlAttribute( ...@@ -3664,7 +3679,7 @@ void XmlUnitTestResultPrinter::OutputXmlAttribute(
} }
// Prints an XML representation of a TestInfo object. // Prints an XML representation of a TestInfo object.
// TODO(wan): There is also value in printing properties with the plain printer. // FIXME: There is also value in printing properties with the plain printer.
void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream, void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
const char* test_case_name, const char* test_case_name,
const TestInfo& test_info) { const TestInfo& test_info) {
...@@ -3891,7 +3906,7 @@ void JsonUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, ...@@ -3891,7 +3906,7 @@ void JsonUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
jsonout = posix::FOpen(output_file_.c_str(), "w"); jsonout = posix::FOpen(output_file_.c_str(), "w");
} }
if (jsonout == NULL) { if (jsonout == NULL) {
// TODO(phosek): report the reason of the failure. // FIXME: report the reason of the failure.
// //
// We don't do it for now as: // We don't do it for now as:
// //
...@@ -4243,12 +4258,67 @@ void StreamingListener::SocketWriter::MakeConnection() { ...@@ -4243,12 +4258,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.
...@@ -4651,7 +4721,7 @@ int UnitTest::Run() { ...@@ -4651,7 +4721,7 @@ int UnitTest::Run() {
// VC++ doesn't define _set_abort_behavior() prior to the version 8.0. // VC++ doesn't define _set_abort_behavior() prior to the version 8.0.
// Users of prior VC versions shall suffer the agony and pain of // Users of prior VC versions shall suffer the agony and pain of
// clicking through the countless debug dialogs. // clicking through the countless debug dialogs.
// TODO(vladl@google.com): find a way to suppress the abort dialog() in the // FIXME: find a way to suppress the abort dialog() in the
// debug mode when compiled with VC 7.1 or lower. // debug mode when compiled with VC 7.1 or lower.
if (!GTEST_FLAG(break_on_failure)) if (!GTEST_FLAG(break_on_failure))
_set_abort_behavior( _set_abort_behavior(
...@@ -4865,6 +4935,13 @@ void UnitTestImpl::PostFlagParsingInit() { ...@@ -4865,6 +4935,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
} }
} }
...@@ -5538,7 +5615,7 @@ static bool HasGoogleTestFlagPrefix(const char* str) { ...@@ -5538,7 +5615,7 @@ static bool HasGoogleTestFlagPrefix(const char* str) {
// @Y changes the color to yellow. // @Y changes the color to yellow.
// @D changes to the default terminal text color. // @D changes to the default terminal text color.
// //
// TODO(wan@google.com): Write tests for this once we add stdout // FIXME: Write tests for this once we add stdout
// capturing to Google Test. // capturing to Google Test.
static void PrintColorEncoded(const char* str) { static void PrintColorEncoded(const char* str) {
GTestColor color = COLOR_DEFAULT; // The current color. GTestColor color = COLOR_DEFAULT; // The current color.
...@@ -5769,6 +5846,10 @@ void InitGoogleTestImpl(int* argc, CharType** argv) { ...@@ -5769,6 +5846,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();
} }
......
...@@ -26,13 +26,12 @@ ...@@ -26,13 +26,12 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#include <stdio.h> #include <stdio.h>
#include "gtest/gtest.h" #include "gtest/gtest.h"
GTEST_API_ int main(int argc, char **argv) { GTEST_API_ int main(int argc, char **argv) {
printf("Running main() from gtest_main.cc\n"); printf("Running main() from %s\n", __FILE__);
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }
...@@ -34,35 +34,65 @@ ...@@ -34,35 +34,65 @@
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"},
)
#on windows exclude gtest-tuple.h and gtest-tuple_test.cc config_setting(
name = "has_absl",
values = {"define": "absl=1"},
)
#on windows exclude gtest-tuple.h and googletest-tuple-test.cc
cc_test( cc_test(
name = "gtest_all_test", name = "gtest_all_test",
size = "small", size = "small",
srcs = glob( srcs = glob(
include = [ include = [
"gtest-*.cc", "gtest-*.cc",
"*.h", "googletest-*.cc",
"googletest/include/gtest/**/*.h", "*.h",
], "googletest/include/gtest/**/*.h",
exclude = [ ],
"gtest-unittest-api_test.cc", exclude = [
"gtest-tuple_test.cc", "gtest-unittest-api_test.cc",
"googletest/src/gtest-all.cc", "googletest-tuple-test.cc",
"gtest_all_test.cc", "googletest/src/gtest-all.cc",
"gtest-death-test_ex_test.cc", "gtest_all_test.cc",
"gtest-listener_test.cc", "gtest-death-test_ex_test.cc",
"gtest-unittest-api_test.cc", "gtest-listener_test.cc",
"gtest-param-test_test.cc", "gtest-unittest-api_test.cc",
], "googletest-param-test-test.cc",
) + select({ "googletest-catch-exceptions-test_.cc",
"googletest-color-test_.cc",
"googletest-env-var-test_.cc",
"googletest-filter-unittest_.cc",
"googletest-break-on-failure-unittest_.cc",
"googletest-listener-test.cc",
"googletest-output-test_.cc",
"googletest-list-tests-unittest_.cc",
"googletest-shuffle-test_.cc",
"googletest-uninitialized-test_.cc",
"googletest-death-test_ex_test.cc",
"googletest-param-test-test",
"googletest-throw-on-failure-test_.cc",
"googletest-param-test-invalid-name1-test_.cc",
"googletest-param-test-invalid-name2-test_.cc",
],
) + select({
"//:windows": [], "//:windows": [],
"//:windows_msvc": [], "//:windows_msvc": [],
"//conditions:default": [ "//conditions:default": [
"gtest-tuple_test.cc", "googletest-tuple-test.cc",
], ],
}), }),
copts = select({ copts = select({
"//:windows": ["-DGTEST_USE_OWN_TR1_TUPLE=0"], "//:windows": ["-DGTEST_USE_OWN_TR1_TUPLE=0"],
"//:windows_msvc": ["-DGTEST_USE_OWN_TR1_TUPLE=0"], "//:windows_msvc": ["-DGTEST_USE_OWN_TR1_TUPLE=0"],
...@@ -84,16 +114,28 @@ cc_test( ...@@ -84,16 +114,28 @@ cc_test(
deps = ["//:gtest_main"], deps = ["//:gtest_main"],
) )
# Tests death tests.
cc_test(
name = "googletest-death-test-test",
size = "medium",
srcs = ["googletest-death-test-test.cc"],
deps = ["//:gtest_main"],
)
cc_test(
name = "gtest_test_macro_stack_footprint_test",
size = "small",
srcs = ["gtest_test_macro_stack_footprint_test.cc"],
deps = ["//:gtest"],
)
#These googletest tests have their own main() #These googletest tests have their own main()
cc_test( cc_test(
name = "gtest-listener_test", name = "googletest-listener-test",
size = "small", size = "small",
srcs = [ srcs = ["googletest-listener-test.cc"],
"gtest-listener_test.cc", deps = ["//:gtest_main"],
],
deps = [
"//:gtest",
],
) )
cc_test( cc_test(
...@@ -108,16 +150,14 @@ cc_test( ...@@ -108,16 +150,14 @@ cc_test(
) )
cc_test( cc_test(
name = "gtest-param-test_test", name = "googletest-param-test-test",
size = "small", size = "small",
srcs = [ srcs = [
"gtest-param-test2_test.cc", "googletest-param-test-test.cc",
"gtest-param-test_test.cc", "googletest-param-test-test.h",
"gtest-param-test_test.h", "googletest-param-test2-test.cc",
],
deps = [
"//:gtest",
], ],
deps = ["//:gtest"],
) )
cc_test( cc_test(
...@@ -135,7 +175,6 @@ py_library( ...@@ -135,7 +175,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 +183,7 @@ cc_binary( ...@@ -144,6 +183,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",
...@@ -153,82 +193,92 @@ py_test( ...@@ -153,82 +193,92 @@ py_test(
) )
cc_binary( cc_binary(
name = "gtest_output_test_", name = "googletest-output-test_",
testonly = 1, testonly = 1,
srcs = ["gtest_output_test_.cc"], srcs = ["googletest-output-test_.cc"],
deps = ["//:gtest"], deps = ["//:gtest"],
) )
py_test( py_test(
name = "gtest_output_test", name = "googletest-output-test",
size = "small", size = "small",
srcs = ["gtest_output_test.py"], srcs = ["googletest-output-test.py"],
args = select({
":has_absl": [],
"//conditions:default": ["--no_stacktrace_support"],
}),
data = [ data = [
"gtest_output_test_golden_lin.txt", "googletest-output-test-golden-lin.txt",
":gtest_output_test_", ":googletest-output-test_",
], ],
deps = [":gtest_test_utils"], deps = [":gtest_test_utils"],
) )
cc_binary( cc_binary(
name = "gtest_color_test_", name = "googletest-color-test_",
testonly = 1, testonly = 1,
srcs = ["gtest_color_test_.cc"], srcs = ["googletest-color-test_.cc"],
deps = ["//:gtest"], deps = ["//:gtest"],
) )
py_test( py_test(
name = "gtest_color_test", name = "googletest-color-test",
size = "small", size = "small",
srcs = ["gtest_color_test.py"], srcs = ["googletest-color-test.py"],
data = [":gtest_color_test_"], data = [":googletest-color-test_"],
deps = [":gtest_test_utils"], deps = [":gtest_test_utils"],
) )
cc_binary( cc_binary(
name = "gtest_env_var_test_", name = "googletest-env-var-test_",
testonly = 1, testonly = 1,
srcs = ["gtest_env_var_test_.cc"], srcs = ["googletest-env-var-test_.cc"],
deps = ["//:gtest"], deps = ["//:gtest"],
) )
py_test( py_test(
name = "gtest_env_var_test", name = "googletest-env-var-test",
size = "small", size = "medium",
srcs = ["gtest_env_var_test.py"], srcs = ["googletest-env-var-test.py"],
data = [":gtest_env_var_test_"], data = [":googletest-env-var-test_"],
deps = [":gtest_test_utils"], deps = [":gtest_test_utils"],
) )
cc_binary( cc_binary(
name = "gtest_filter_unittest_", name = "googletest-filter-unittest_",
testonly = 1, testonly = 1,
srcs = ["gtest_filter_unittest_.cc"], srcs = ["googletest-filter-unittest_.cc"],
deps = ["//:gtest"], deps = ["//:gtest"],
) )
py_test( py_test(
name = "gtest_filter_unittest", name = "googletest-filter-unittest",
size = "small", size = "medium",
srcs = ["gtest_filter_unittest.py"], srcs = ["googletest-filter-unittest.py"],
data = [":gtest_filter_unittest_"], data = [":googletest-filter-unittest_"],
deps = [":gtest_test_utils"], deps = [":gtest_test_utils"],
) )
cc_binary( cc_binary(
name = "gtest_break_on_failure_unittest_", name = "googletest-break-on-failure-unittest_",
testonly = 1, testonly = 1,
srcs = ["gtest_break_on_failure_unittest_.cc"], srcs = ["googletest-break-on-failure-unittest_.cc"],
deps = ["//:gtest"], deps = ["//:gtest"],
) )
py_test( py_test(
name = "gtest_break_on_failure_unittest", name = "googletest-break-on-failure-unittest",
size = "small", size = "small",
srcs = ["gtest_break_on_failure_unittest.py"], srcs = ["googletest-break-on-failure-unittest.py"],
data = [":gtest_break_on_failure_unittest_"], data = [":googletest-break-on-failure-unittest_"],
deps = [":gtest_test_utils"], deps = [":gtest_test_utils"],
) )
cc_test( cc_test(
name = "gtest_assert_by_exception_test", name = "gtest_assert_by_exception_test",
size = "small", size = "small",
...@@ -236,72 +286,75 @@ cc_test( ...@@ -236,72 +286,75 @@ cc_test(
deps = ["//:gtest"], deps = ["//:gtest"],
) )
cc_binary( cc_binary(
name = "gtest_throw_on_failure_test_", name = "googletest-throw-on-failure-test_",
testonly = 1, testonly = 1,
srcs = ["gtest_throw_on_failure_test_.cc"], srcs = ["googletest-throw-on-failure-test_.cc"],
deps = ["//:gtest"], deps = ["//:gtest"],
) )
py_test( py_test(
name = "gtest_throw_on_failure_test", name = "googletest-throw-on-failure-test",
size = "small", size = "small",
srcs = ["gtest_throw_on_failure_test.py"], srcs = ["googletest-throw-on-failure-test.py"],
data = [":gtest_throw_on_failure_test_"], data = [":googletest-throw-on-failure-test_"],
deps = [":gtest_test_utils"], deps = [":gtest_test_utils"],
) )
cc_binary( cc_binary(
name = "gtest_list_tests_unittest_", name = "googletest-list-tests-unittest_",
testonly = 1, testonly = 1,
srcs = ["gtest_list_tests_unittest_.cc"], srcs = ["googletest-list-tests-unittest_.cc"],
deps = ["//:gtest"], deps = ["//:gtest"],
) )
py_test( py_test(
name = "gtest_list_tests_unittest", name = "googletest-list-tests-unittest",
size = "small", size = "small",
srcs = ["gtest_list_tests_unittest.py"], srcs = ["googletest-list-tests-unittest.py"],
data = [":gtest_list_tests_unittest_"], data = [":googletest-list-tests-unittest_"],
deps = [":gtest_test_utils"], deps = [":gtest_test_utils"],
) )
cc_binary( cc_binary(
name = "gtest_shuffle_test_", name = "googletest-shuffle-test_",
srcs = ["gtest_shuffle_test_.cc"], srcs = ["googletest-shuffle-test_.cc"],
deps = ["//:gtest"], deps = ["//:gtest"],
) )
py_test( py_test(
name = "gtest_shuffle_test", name = "googletest-shuffle-test",
size = "small", size = "small",
srcs = ["gtest_shuffle_test.py"], srcs = ["googletest-shuffle-test.py"],
data = [":gtest_shuffle_test_"], data = [":googletest-shuffle-test_"],
deps = [":gtest_test_utils"], deps = [":gtest_test_utils"],
) )
cc_binary( cc_binary(
name = "gtest_catch_exceptions_no_ex_test_", name = "googletest-catch-exceptions-no-ex-test_",
testonly = 1, testonly = 1,
srcs = ["gtest_catch_exceptions_test_.cc"], srcs = ["googletest-catch-exceptions-test_.cc"],
deps = ["//:gtest_main"], deps = ["//:gtest_main"],
) )
cc_binary( cc_binary(
name = "gtest_catch_exceptions_ex_test_", name = "googletest-catch-exceptions-ex-test_",
testonly = 1, testonly = 1,
srcs = ["gtest_catch_exceptions_test_.cc"], srcs = ["googletest-catch-exceptions-test_.cc"],
copts = ["-fexceptions"], copts = ["-fexceptions"],
deps = ["//:gtest_main"], deps = ["//:gtest_main"],
) )
py_test( py_test(
name = "gtest_catch_exceptions_test", name = "googletest-catch-exceptions-test",
size = "small", size = "small",
srcs = ["gtest_catch_exceptions_test.py"], srcs = ["googletest-catch-exceptions-test.py"],
data = [ data = [
":gtest_catch_exceptions_ex_test_", ":googletest-catch-exceptions-ex-test_",
":gtest_catch_exceptions_no_ex_test_", ":googletest-catch-exceptions-no-ex-test_",
], ],
deps = [":gtest_test_utils"], deps = [":gtest_test_utils"],
) )
...@@ -327,6 +380,10 @@ py_test( ...@@ -327,6 +380,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.
...@@ -365,17 +422,17 @@ py_test( ...@@ -365,17 +422,17 @@ py_test(
) )
cc_binary( cc_binary(
name = "gtest_uninitialized_test_", name = "googletest-uninitialized-test_",
testonly = 1, testonly = 1,
srcs = ["gtest_uninitialized_test_.cc"], srcs = ["googletest-uninitialized-test_.cc"],
deps = ["//:gtest"], deps = ["//:gtest"],
) )
py_test( py_test(
name = "gtest_uninitialized_test", name = "googletest-uninitialized-test",
size = "medium", size = "medium",
srcs = ["gtest_uninitialized_test.py"], srcs = ["googletest-uninitialized-test.py"],
data = [":gtest_uninitialized_test_"], data = ["googletest-uninitialized-test_"],
deps = [":gtest_test_utils"], deps = [":gtest_test_utils"],
) )
...@@ -394,3 +451,77 @@ py_test( ...@@ -394,3 +451,77 @@ py_test(
data = [":gtest_testbridge_test_"], data = [":gtest_testbridge_test_"],
deps = [":gtest_test_utils"], deps = [":gtest_test_utils"],
) )
py_test(
name = "googletest-json-outfiles-test",
size = "small",
srcs = [
"googletest-json-outfiles-test.py",
"gtest_json_test_utils.py",
],
data = [
":gtest_xml_outfile1_test_",
":gtest_xml_outfile2_test_",
],
deps = [":gtest_test_utils"],
)
py_test(
name = "googletest-json-output-unittest",
size = "medium",
srcs = [
"googletest-json-output-unittest.py",
"gtest_json_test_utils.py",
],
data = [
# We invoke gtest_no_test_unittest to verify the JSON output
# when the test program contains no test definition.
":gtest_no_test_unittest",
":gtest_xml_output_unittest_",
],
args = select({
":has_absl": [],
"//conditions:default": ["--no_stacktrace_support"],
}),
deps = [":gtest_test_utils"],
)
# Verifies interaction of death tests and exceptions.
cc_test(
name = "googletest-death-test_ex_catch_test",
size = "medium",
srcs = ["googletest-death-test_ex_test.cc"],
copts = ["-fexceptions"],
defines = ["GTEST_ENABLE_CATCH_EXCEPTIONS_=1"],
deps = ["//:gtest"],
)
cc_binary(
name = "googletest-param-test-invalid-name1-test_",
testonly = 1,
srcs = ["googletest-param-test-invalid-name1-test_.cc"],
deps = ["//:gtest"],
)
cc_binary(
name = "googletest-param-test-invalid-name2-test_",
testonly = 1,
srcs = ["googletest-param-test-invalid-name2-test_.cc"],
deps = ["//:gtest"],
)
py_test(
name = "googletest-param-test-invalid-name1-test",
size = "small",
srcs = ["googletest-param-test-invalid-name1-test.py"],
data = [":googletest-param-test-invalid-name1-test_"],
deps = [":gtest_test_utils"],
)
py_test(
name = "googletest-param-test-invalid-name2-test",
size = "small",
srcs = ["googletest-param-test-invalid-name2-test.py"],
data = [":googletest-param-test-invalid-name2-test_"],
deps = [":gtest_test_utils"],
)
...@@ -34,12 +34,10 @@ ...@@ -34,12 +34,10 @@
A user can ask Google Test to seg-fault when an assertion fails, using A user can ask Google Test to seg-fault when an assertion fails, using
either the GTEST_BREAK_ON_FAILURE environment variable or the either the GTEST_BREAK_ON_FAILURE environment variable or the
--gtest_break_on_failure flag. This script tests such functionality --gtest_break_on_failure flag. This script tests such functionality
by invoking gtest_break_on_failure_unittest_ (a program written with by invoking googletest-break-on-failure-unittest_ (a program written with
Google Test) with different environments and command line flags. Google Test) with different environments and command line flags.
""" """
__author__ = 'wan@google.com (Zhanyong Wan)'
import os import os
import gtest_test_utils import gtest_test_utils
...@@ -59,9 +57,9 @@ THROW_ON_FAILURE_ENV_VAR = 'GTEST_THROW_ON_FAILURE' ...@@ -59,9 +57,9 @@ THROW_ON_FAILURE_ENV_VAR = 'GTEST_THROW_ON_FAILURE'
# The environment variable for enabling/disabling the catch-exceptions mode. # The environment variable for enabling/disabling the catch-exceptions mode.
CATCH_EXCEPTIONS_ENV_VAR = 'GTEST_CATCH_EXCEPTIONS' CATCH_EXCEPTIONS_ENV_VAR = 'GTEST_CATCH_EXCEPTIONS'
# Path to the gtest_break_on_failure_unittest_ program. # Path to the googletest-break-on-failure-unittest_ program.
EXE_PATH = gtest_test_utils.GetTestExecutablePath( EXE_PATH = gtest_test_utils.GetTestExecutablePath(
'gtest_break_on_failure_unittest_') 'googletest-break-on-failure-unittest_')
environ = gtest_test_utils.environ environ = gtest_test_utils.environ
...@@ -95,7 +93,7 @@ class GTestBreakOnFailureUnitTest(gtest_test_utils.TestCase): ...@@ -95,7 +93,7 @@ class GTestBreakOnFailureUnitTest(gtest_test_utils.TestCase):
""" """
def RunAndVerify(self, env_var_value, flag_value, expect_seg_fault): def RunAndVerify(self, env_var_value, flag_value, expect_seg_fault):
"""Runs gtest_break_on_failure_unittest_ and verifies that it does """Runs googletest-break-on-failure-unittest_ and verifies that it does
(or does not) have a seg-fault. (or does not) have a seg-fault.
Args: Args:
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Unit test for Google Test's break-on-failure mode. // Unit test for Google Test's break-on-failure mode.
// //
......
...@@ -30,13 +30,11 @@ ...@@ -30,13 +30,11 @@
"""Tests Google Test's exception catching behavior. """Tests Google Test's exception catching behavior.
This script invokes gtest_catch_exceptions_test_ and This script invokes googletest-catch-exceptions-test_ and
gtest_catch_exceptions_ex_test_ (programs written with googletest-catch-exceptions-ex-test_ (programs written with
Google Test) and verifies their output. Google Test) and verifies their output.
""" """
__author__ = 'vladl@google.com (Vlad Losev)'
import gtest_test_utils import gtest_test_utils
# Constants. # Constants.
...@@ -45,15 +43,15 @@ LIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests' ...@@ -45,15 +43,15 @@ LIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests'
NO_CATCH_EXCEPTIONS_FLAG = FLAG_PREFIX + 'catch_exceptions=0' NO_CATCH_EXCEPTIONS_FLAG = FLAG_PREFIX + 'catch_exceptions=0'
FILTER_FLAG = FLAG_PREFIX + 'filter' FILTER_FLAG = FLAG_PREFIX + 'filter'
# Path to the gtest_catch_exceptions_ex_test_ binary, compiled with # Path to the googletest-catch-exceptions-ex-test_ binary, compiled with
# exceptions enabled. # exceptions enabled.
EX_EXE_PATH = gtest_test_utils.GetTestExecutablePath( EX_EXE_PATH = gtest_test_utils.GetTestExecutablePath(
'gtest_catch_exceptions_ex_test_') 'googletest-catch-exceptions-ex-test_')
# Path to the gtest_catch_exceptions_test_ binary, compiled with # Path to the googletest-catch-exceptions-test_ binary, compiled with
# exceptions disabled. # exceptions disabled.
EXE_PATH = gtest_test_utils.GetTestExecutablePath( EXE_PATH = gtest_test_utils.GetTestExecutablePath(
'gtest_catch_exceptions_no_ex_test_') 'googletest-catch-exceptions-no-ex-test_')
environ = gtest_test_utils.environ environ = gtest_test_utils.environ
SetEnvVar = gtest_test_utils.SetEnvVar SetEnvVar = gtest_test_utils.SetEnvVar
......
...@@ -26,17 +26,17 @@ ...@@ -26,17 +26,17 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
// //
// Tests for Google Test itself. Tests in this file throw C++ or SEH // Tests for Google Test itself. Tests in this file throw C++ or SEH
// exceptions, and the output is verified by gtest_catch_exceptions_test.py. // exceptions, and the output is verified by
// googletest-catch-exceptions-test.py.
#include "gtest/gtest.h"
#include <stdio.h> // NOLINT #include <stdio.h> // NOLINT
#include <stdlib.h> // For exit(). #include <stdlib.h> // For exit().
#include "gtest/gtest.h"
#if GTEST_HAS_SEH #if GTEST_HAS_SEH
# include <windows.h> # include <windows.h>
#endif #endif
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
"""Verifies that Google Test correctly determines whether to use colors.""" """Verifies that Google Test correctly determines whether to use colors."""
__author__ = 'wan@google.com (Zhanyong Wan)'
import os import os
import gtest_test_utils import gtest_test_utils
...@@ -40,7 +38,7 @@ IS_WINDOWS = os.name == 'nt' ...@@ -40,7 +38,7 @@ IS_WINDOWS = os.name == 'nt'
COLOR_ENV_VAR = 'GTEST_COLOR' COLOR_ENV_VAR = 'GTEST_COLOR'
COLOR_FLAG = 'gtest_color' COLOR_FLAG = 'gtest_color'
COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_color_test_') COMMAND = gtest_test_utils.GetTestExecutablePath('googletest-color-test_')
def SetEnvVar(env_var, value): def SetEnvVar(env_var, value):
...@@ -53,7 +51,7 @@ def SetEnvVar(env_var, value): ...@@ -53,7 +51,7 @@ def SetEnvVar(env_var, value):
def UsesColor(term, color_env_var, color_flag): def UsesColor(term, color_env_var, color_flag):
"""Runs gtest_color_test_ and returns its exit code.""" """Runs googletest-color-test_ and returns its exit code."""
SetEnvVar('TERM', term) SetEnvVar('TERM', term)
SetEnvVar(COLOR_ENV_VAR, color_env_var) SetEnvVar(COLOR_ENV_VAR, color_env_var)
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// A helper program for testing how Google Test determines whether to use // A helper program for testing how Google Test determines whether to use
// colors in the output. It prints "YES" and returns 1 if Google Test // colors in the output. It prints "YES" and returns 1 if Google Test
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// //
// Tests for death tests. // Tests for death tests.
...@@ -784,7 +783,7 @@ static void TestExitMacros() { ...@@ -784,7 +783,7 @@ static void TestExitMacros() {
// Of all signals effects on the process exit code, only those of SIGABRT // Of all signals effects on the process exit code, only those of SIGABRT
// are documented on Windows. // are documented on Windows.
// See http://msdn.microsoft.com/en-us/library/dwwzkt4c(VS.71).aspx. // See https://msdn.microsoft.com/en-us/query-bi/m/dwwzkt4c.
EXPECT_EXIT(raise(SIGABRT), testing::ExitedWithCode(3), "") << "b_ar"; EXPECT_EXIT(raise(SIGABRT), testing::ExitedWithCode(3), "") << "b_ar";
# elif !GTEST_OS_FUCHSIA # elif !GTEST_OS_FUCHSIA
...@@ -1280,7 +1279,7 @@ TEST(ParseNaturalNumberTest, WorksForShorterIntegers) { ...@@ -1280,7 +1279,7 @@ TEST(ParseNaturalNumberTest, WorksForShorterIntegers) {
# if GTEST_OS_WINDOWS # if GTEST_OS_WINDOWS
TEST(EnvironmentTest, HandleFitsIntoSizeT) { TEST(EnvironmentTest, HandleFitsIntoSizeT) {
// TODO(vladl@google.com): Remove this test after this condition is verified // FIXME: Remove this test after this condition is verified
// in a static assertion in gtest-death-test.cc in the function // in a static assertion in gtest-death-test.cc in the function
// GetStatusFileDescriptor. // GetStatusFileDescriptor.
ASSERT_TRUE(sizeof(HANDLE) <= sizeof(size_t)); ASSERT_TRUE(sizeof(HANDLE) <= sizeof(size_t));
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
// //
// Tests that verify interaction of exceptions and death tests. // Tests that verify interaction of exceptions and death tests.
...@@ -69,7 +68,7 @@ TEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) { ...@@ -69,7 +68,7 @@ TEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) {
"exceptional message"); "exceptional message");
// Verifies that the location is mentioned in the failure text. // Verifies that the location is mentioned in the failure text.
EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw TestException(), ""), EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw TestException(), ""),
"gtest-death-test_ex_test.cc"); "googletest-death-test_ex_test.cc");
} }
# endif // GTEST_HAS_EXCEPTIONS # endif // GTEST_HAS_EXCEPTIONS
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
"""Verifies that Google Test correctly parses environment variables.""" """Verifies that Google Test correctly parses environment variables."""
__author__ = 'wan@google.com (Zhanyong Wan)'
import os import os
import gtest_test_utils import gtest_test_utils
...@@ -40,7 +38,7 @@ import gtest_test_utils ...@@ -40,7 +38,7 @@ import gtest_test_utils
IS_WINDOWS = os.name == 'nt' IS_WINDOWS = os.name == 'nt'
IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux' IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_env_var_test_') COMMAND = gtest_test_utils.GetTestExecutablePath('googletest-env-var-test_')
environ = os.environ.copy() environ = os.environ.copy()
...@@ -62,7 +60,7 @@ def SetEnvVar(env_var, value): ...@@ -62,7 +60,7 @@ def SetEnvVar(env_var, value):
def GetFlag(flag): def GetFlag(flag):
"""Runs gtest_env_var_test_ and returns its output.""" """Runs googletest-env-var-test_ and returns its output."""
args = [COMMAND] args = [COMMAND]
if flag is not None: if flag is not None:
......
...@@ -26,16 +26,14 @@ ...@@ -26,16 +26,14 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// A helper program for testing that Google Test parses the environment // A helper program for testing that Google Test parses the environment
// variables correctly. // variables correctly.
#include "gtest/gtest.h"
#include <iostream> #include <iostream>
#include "gtest/gtest.h"
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
using ::std::cout; using ::std::cout;
...@@ -115,7 +113,7 @@ int main(int argc, char** argv) { ...@@ -115,7 +113,7 @@ int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, argv);
if (argc != 2) { if (argc != 2) {
cout << "Usage: gtest_env_var_test_ NAME_OF_FLAG\n"; cout << "Usage: googletest-env-var-test_ NAME_OF_FLAG\n";
return 1; return 1;
} }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
//
// Google Test filepath utilities // Google Test filepath utilities
// //
// This file tests classes and functions used internally by // This file tests classes and functions used internally by
...@@ -51,7 +50,7 @@ namespace internal { ...@@ -51,7 +50,7 @@ namespace internal {
namespace { namespace {
#if GTEST_OS_WINDOWS_MOBILE #if GTEST_OS_WINDOWS_MOBILE
// TODO(wan@google.com): Move these to the POSIX adapter section in // FIXME: Move these to the POSIX adapter section in
// gtest-port.h. // gtest-port.h.
// Windows CE doesn't have the remove C function. // Windows CE doesn't have the remove C function.
......
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