Unverified Commit 76bce79a authored by Andy Soffer's avatar Andy Soffer Committed by GitHub
Browse files

Merge branch 'main' into fixes_std_pair_diff

parents 6f1c4b3d f345b2ca
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-port.h"
#if GTEST_HAS_FILE_SYSTEM
namespace { namespace {
class SetEnv { class SetEnv {
...@@ -94,4 +96,6 @@ TEST(SrcDirTest, NotInEnvironment) { ...@@ -94,4 +96,6 @@ TEST(SrcDirTest, NotInEnvironment) {
EXPECT_NE(testing::SrcDir(), ""); EXPECT_NE(testing::SrcDir(), "");
} }
#endif // GTEST_HAS_FILE_SYSTEM
} // namespace } // namespace
...@@ -43,6 +43,7 @@ import sys ...@@ -43,6 +43,7 @@ import sys
from googletest.test import gtest_test_utils from googletest.test import gtest_test_utils
IS_DARWIN = os.name == 'posix' and os.uname()[0] == 'Darwin'
IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux' IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
IS_GNUHURD = os.name == 'posix' and os.uname()[0] == 'GNU' IS_GNUHURD = os.name == 'posix' and os.uname()[0] == 'GNU'
IS_GNUKFREEBSD = os.name == 'posix' and os.uname()[0] == 'GNU/kFreeBSD' IS_GNUKFREEBSD = os.name == 'posix' and os.uname()[0] == 'GNU/kFreeBSD'
...@@ -53,7 +54,6 @@ PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_help_test_') ...@@ -53,7 +54,6 @@ PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_help_test_')
FLAG_PREFIX = '--gtest_' FLAG_PREFIX = '--gtest_'
DEATH_TEST_STYLE_FLAG = FLAG_PREFIX + 'death_test_style' DEATH_TEST_STYLE_FLAG = FLAG_PREFIX + 'death_test_style'
STREAM_RESULT_TO_FLAG = FLAG_PREFIX + 'stream_result_to' STREAM_RESULT_TO_FLAG = FLAG_PREFIX + 'stream_result_to'
UNKNOWN_GTEST_PREFIXED_FLAG = FLAG_PREFIX + 'unknown_flag_for_testing'
LIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests' LIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests'
INTERNAL_FLAG_FOR_TESTING = FLAG_PREFIX + 'internal_flag_for_testing' INTERNAL_FLAG_FOR_TESTING = FLAG_PREFIX + 'internal_flag_for_testing'
...@@ -136,7 +136,7 @@ class GTestHelpTest(gtest_test_utils.TestCase): ...@@ -136,7 +136,7 @@ class GTestHelpTest(gtest_test_utils.TestCase):
self.assertTrue(HELP_REGEX.search(output), output) self.assertTrue(HELP_REGEX.search(output), output)
if IS_LINUX or IS_GNUHURD or IS_GNUKFREEBSD or IS_OPENBSD: if IS_DARWIN or IS_LINUX or IS_GNUHURD or IS_GNUKFREEBSD or IS_OPENBSD:
self.assertIn(STREAM_RESULT_TO_FLAG, output) self.assertIn(STREAM_RESULT_TO_FLAG, output)
else: else:
self.assertNotIn(STREAM_RESULT_TO_FLAG, output) self.assertNotIn(STREAM_RESULT_TO_FLAG, output)
...@@ -176,16 +176,6 @@ class GTestHelpTest(gtest_test_utils.TestCase): ...@@ -176,16 +176,6 @@ class GTestHelpTest(gtest_test_utils.TestCase):
def testPrintsHelpWithFullFlag(self): def testPrintsHelpWithFullFlag(self):
self.TestHelpFlag('--help') self.TestHelpFlag('--help')
def testPrintsHelpWithUnrecognizedGoogleTestFlag(self):
# The behavior is slightly different when Abseil flags is
# used. Abseil flags rejects all unknown flags, while the builtin
# GTest flags implementation interprets an unknown flag with a
# '--gtest_' prefix as a request for help.
if HAS_ABSL_FLAGS:
self.TestUnknownFlagWithAbseil(UNKNOWN_GTEST_PREFIXED_FLAG)
else:
self.TestHelpFlag(UNKNOWN_GTEST_PREFIXED_FLAG)
def testRunsTestsWithoutHelpFlag(self): def testRunsTestsWithoutHelpFlag(self):
"""Verifies correct behavior when no help flag is specified. """Verifies correct behavior when no help flag is specified.
......
...@@ -39,6 +39,6 @@ TEST(HelpFlagTest, ShouldNotBeRun) { ...@@ -39,6 +39,6 @@ TEST(HelpFlagTest, ShouldNotBeRun) {
ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified."; ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified.";
} }
#if GTEST_HAS_DEATH_TEST #ifdef GTEST_HAS_DEATH_TEST
TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {} TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {}
#endif #endif
...@@ -61,7 +61,7 @@ int g_environment_tear_down_count = 0; ...@@ -61,7 +61,7 @@ int g_environment_tear_down_count = 0;
class MyEnvironment : public testing::Environment { class MyEnvironment : public testing::Environment {
public: public:
MyEnvironment() {} MyEnvironment() = default;
void SetUp() override { g_environment_set_up_count++; } void SetUp() override { g_environment_set_up_count++; }
void TearDown() override { g_environment_tear_down_count++; } void TearDown() override { g_environment_tear_down_count++; }
}; };
......
...@@ -30,12 +30,15 @@ ...@@ -30,12 +30,15 @@
// Tests that SCOPED_TRACE() and various Google Test assertions can be // Tests that SCOPED_TRACE() and various Google Test assertions can be
// used in a large number of threads concurrently. // used in a large number of threads concurrently.
#include <algorithm>
#include <memory>
#include <string>
#include <vector> #include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#if GTEST_IS_THREADSAFE #ifdef GTEST_IS_THREADSAFE
namespace testing { namespace testing {
namespace { namespace {
...@@ -118,8 +121,8 @@ TEST(StressTest, CanUseScopedTraceAndAssertionsInManyThreads) { ...@@ -118,8 +121,8 @@ TEST(StressTest, CanUseScopedTraceAndAssertionsInManyThreads) {
std::unique_ptr<ThreadWithParam<int> > threads[kThreadCount]; std::unique_ptr<ThreadWithParam<int> > threads[kThreadCount];
Notification threads_can_start; Notification threads_can_start;
for (int i = 0; i != kThreadCount; i++) for (int i = 0; i != kThreadCount; i++)
threads[i].reset( threads[i] = std::make_unique<ThreadWithParam<int>>(&ManyAsserts, i,
new ThreadWithParam<int>(&ManyAsserts, i, &threads_can_start)); &threads_can_start);
threads_can_start.Notify(); threads_can_start.Notify();
......
...@@ -60,8 +60,10 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) { ...@@ -60,8 +60,10 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include <cstdint> #include <cstdint>
#include <map> #include <map>
#include <memory>
#include <ostream> #include <ostream>
#include <set> #include <set>
#include <stdexcept>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include <unordered_set> #include <unordered_set>
...@@ -210,7 +212,6 @@ using testing::TestPartResult; ...@@ -210,7 +212,6 @@ using testing::TestPartResult;
using testing::TestPartResultArray; using testing::TestPartResultArray;
using testing::TestProperty; using testing::TestProperty;
using testing::TestResult; using testing::TestResult;
using testing::TestSuite;
using testing::TimeInMillis; using testing::TimeInMillis;
using testing::UnitTest; using testing::UnitTest;
using testing::internal::AlwaysFalse; using testing::internal::AlwaysFalse;
...@@ -226,7 +227,6 @@ using testing::internal::FloatingPoint; ...@@ -226,7 +227,6 @@ using testing::internal::FloatingPoint;
using testing::internal::ForEach; using testing::internal::ForEach;
using testing::internal::FormatEpochTimeInMillisAsIso8601; using testing::internal::FormatEpochTimeInMillisAsIso8601;
using testing::internal::FormatTimeInMillisAsSeconds; using testing::internal::FormatTimeInMillisAsSeconds;
using testing::internal::GetCurrentOsStackTraceExceptTop;
using testing::internal::GetElementOr; using testing::internal::GetElementOr;
using testing::internal::GetNextRandomSeed; using testing::internal::GetNextRandomSeed;
using testing::internal::GetRandomSeedFromFlag; using testing::internal::GetRandomSeedFromFlag;
...@@ -243,8 +243,6 @@ using testing::internal::IsNotContainer; ...@@ -243,8 +243,6 @@ using testing::internal::IsNotContainer;
using testing::internal::kMaxRandomSeed; using testing::internal::kMaxRandomSeed;
using testing::internal::kTestTypeIdInGoogleTest; using testing::internal::kTestTypeIdInGoogleTest;
using testing::internal::NativeArray; using testing::internal::NativeArray;
using testing::internal::OsStackTraceGetter;
using testing::internal::OsStackTraceGetterInterface;
using testing::internal::ParseFlag; using testing::internal::ParseFlag;
using testing::internal::RelationToSourceCopy; using testing::internal::RelationToSourceCopy;
using testing::internal::RelationToSourceReference; using testing::internal::RelationToSourceReference;
...@@ -258,7 +256,6 @@ using testing::internal::StreamableToString; ...@@ -258,7 +256,6 @@ using testing::internal::StreamableToString;
using testing::internal::String; using testing::internal::String;
using testing::internal::TestEventListenersAccessor; using testing::internal::TestEventListenersAccessor;
using testing::internal::TestResultAccessor; using testing::internal::TestResultAccessor;
using testing::internal::UnitTestImpl;
using testing::internal::WideStringToUtf8; using testing::internal::WideStringToUtf8;
using testing::internal::edit_distance::CalculateOptimalEdits; using testing::internal::edit_distance::CalculateOptimalEdits;
using testing::internal::edit_distance::CreateUnifiedDiff; using testing::internal::edit_distance::CreateUnifiedDiff;
...@@ -269,7 +266,7 @@ using testing::internal::CaptureStdout; ...@@ -269,7 +266,7 @@ using testing::internal::CaptureStdout;
using testing::internal::GetCapturedStdout; using testing::internal::GetCapturedStdout;
#endif #endif
#if GTEST_IS_THREADSAFE #ifdef GTEST_IS_THREADSAFE
using testing::internal::ThreadWithParam; using testing::internal::ThreadWithParam;
#endif #endif
...@@ -424,10 +421,12 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { ...@@ -424,10 +421,12 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
private: private:
void SetUp() override { void SetUp() override {
saved_tz_ = nullptr; saved_tz_.reset();
GTEST_DISABLE_MSC_DEPRECATED_PUSH_(/* getenv, strdup: deprecated */) GTEST_DISABLE_MSC_DEPRECATED_PUSH_(/* getenv: deprecated */)
if (getenv("TZ")) saved_tz_ = strdup(getenv("TZ")); if (const char* tz = getenv("TZ")) {
saved_tz_ = std::make_unique<std::string>(tz);
}
GTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_DEPRECATED_POP_()
// Set up the time zone for FormatEpochTimeInMillisAsIso8601 to use. We // Set up the time zone for FormatEpochTimeInMillisAsIso8601 to use. We
...@@ -437,16 +436,15 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { ...@@ -437,16 +436,15 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
} }
void TearDown() override { void TearDown() override {
SetTimeZone(saved_tz_); SetTimeZone(saved_tz_ != nullptr ? saved_tz_->c_str() : nullptr);
free(const_cast<char*>(saved_tz_)); saved_tz_.reset();
saved_tz_ = nullptr;
} }
static void SetTimeZone(const char* time_zone) { static void SetTimeZone(const char* time_zone) {
// tzset() distinguishes between the TZ variable being present and empty // tzset() distinguishes between the TZ variable being present and empty
// and not being present, so we have to consider the case of time_zone // and not being present, so we have to consider the case of time_zone
// being NULL. // being NULL.
#if defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW #if defined(_MSC_VER) || defined(GTEST_OS_WINDOWS_MINGW)
// ...Unless it's MSVC, whose standard library's _putenv doesn't // ...Unless it's MSVC, whose standard library's _putenv doesn't
// distinguish between an empty and a missing variable. // distinguish between an empty and a missing variable.
const std::string env_var = const std::string env_var =
...@@ -456,7 +454,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { ...@@ -456,7 +454,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
tzset(); tzset();
GTEST_DISABLE_MSC_WARNINGS_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
#else #else
#if GTEST_OS_LINUX_ANDROID && __ANDROID_API__ < 21 #if defined(GTEST_OS_LINUX_ANDROID) && __ANDROID_API__ < 21
// Work around KitKat bug in tzset by setting "UTC" before setting "UTC+00". // Work around KitKat bug in tzset by setting "UTC" before setting "UTC+00".
// See https://github.com/android/ndk/issues/1604. // See https://github.com/android/ndk/issues/1604.
setenv("TZ", "UTC", 1); setenv("TZ", "UTC", 1);
...@@ -471,7 +469,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { ...@@ -471,7 +469,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
#endif #endif
} }
const char* saved_tz_; std::unique_ptr<std::string> saved_tz_; // Empty and null are different here
}; };
const TimeInMillis FormatEpochTimeInMillisAsIso8601Test::kMillisPerSec; const TimeInMillis FormatEpochTimeInMillisAsIso8601Test::kMillisPerSec;
...@@ -1088,7 +1086,7 @@ TEST(StringTest, CaseInsensitiveWideCStringEquals) { ...@@ -1088,7 +1086,7 @@ TEST(StringTest, CaseInsensitiveWideCStringEquals) {
EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(L"FOOBAR", L"foobar")); EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(L"FOOBAR", L"foobar"));
} }
#if GTEST_OS_WINDOWS #ifdef GTEST_OS_WINDOWS
// Tests String::ShowWideCString(). // Tests String::ShowWideCString().
TEST(StringTest, ShowWideCString) { TEST(StringTest, ShowWideCString) {
...@@ -1097,7 +1095,7 @@ TEST(StringTest, ShowWideCString) { ...@@ -1097,7 +1095,7 @@ TEST(StringTest, ShowWideCString) {
EXPECT_STREQ("foo", String::ShowWideCString(L"foo").c_str()); EXPECT_STREQ("foo", String::ShowWideCString(L"foo").c_str());
} }
#if GTEST_OS_WINDOWS_MOBILE #ifdef GTEST_OS_WINDOWS_MOBILE
TEST(StringTest, AnsiAndUtf16Null) { TEST(StringTest, AnsiAndUtf16Null) {
EXPECT_EQ(NULL, String::AnsiToUtf16(NULL)); EXPECT_EQ(NULL, String::AnsiToUtf16(NULL));
EXPECT_EQ(NULL, String::Utf16ToAnsi(NULL)); EXPECT_EQ(NULL, String::Utf16ToAnsi(NULL));
...@@ -1187,7 +1185,7 @@ TEST_F(ScopedFakeTestPartResultReporterTest, DeprecatedConstructor) { ...@@ -1187,7 +1185,7 @@ TEST_F(ScopedFakeTestPartResultReporterTest, DeprecatedConstructor) {
EXPECT_EQ(1, results.size()); EXPECT_EQ(1, results.size());
} }
#if GTEST_IS_THREADSAFE #ifdef GTEST_IS_THREADSAFE
class ScopedFakeTestPartResultReporterWithThreadsTest class ScopedFakeTestPartResultReporterWithThreadsTest
: public ScopedFakeTestPartResultReporterTest { : public ScopedFakeTestPartResultReporterTest {
...@@ -1345,7 +1343,7 @@ TEST_F(ExpectNonfatalFailureTest, AcceptsMacroThatExpandsToUnprotectedComma) { ...@@ -1345,7 +1343,7 @@ TEST_F(ExpectNonfatalFailureTest, AcceptsMacroThatExpandsToUnprotectedComma) {
""); "");
} }
#if GTEST_IS_THREADSAFE #ifdef GTEST_IS_THREADSAFE
typedef ScopedFakeTestPartResultReporterWithThreadsTest typedef ScopedFakeTestPartResultReporterWithThreadsTest
ExpectFailureWithThreadsTest; ExpectFailureWithThreadsTest;
...@@ -1674,7 +1672,7 @@ TEST_F(GTestFlagSaverTest, VerifyGTestFlags) { VerifyAndModifyFlags(); } ...@@ -1674,7 +1672,7 @@ TEST_F(GTestFlagSaverTest, VerifyGTestFlags) { VerifyAndModifyFlags(); }
// value. If the value argument is "", unsets the environment // value. If the value argument is "", unsets the environment
// variable. The caller must ensure that both arguments are not NULL. // variable. The caller must ensure that both arguments are not NULL.
static void SetEnv(const char* name, const char* value) { static void SetEnv(const char* name, const char* value) {
#if GTEST_OS_WINDOWS_MOBILE #ifdef GTEST_OS_WINDOWS_MOBILE
// Environment variables are not supported on Windows CE. // Environment variables are not supported on Windows CE.
return; return;
#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9) #elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
...@@ -1697,7 +1695,7 @@ static void SetEnv(const char* name, const char* value) { ...@@ -1697,7 +1695,7 @@ static void SetEnv(const char* name, const char* value) {
// We cast away the 'const' since that would work for both variants. // We cast away the 'const' since that would work for both variants.
putenv(const_cast<char*>(added_env[name]->c_str())); putenv(const_cast<char*>(added_env[name]->c_str()));
delete prev_env; delete prev_env;
#elif GTEST_OS_WINDOWS // If we are on Windows proper. #elif defined(GTEST_OS_WINDOWS) // If we are on Windows proper.
_putenv((Message() << name << "=" << value).GetString().c_str()); _putenv((Message() << name << "=" << value).GetString().c_str());
#else #else
if (*value == '\0') { if (*value == '\0') {
...@@ -1708,7 +1706,7 @@ static void SetEnv(const char* name, const char* value) { ...@@ -1708,7 +1706,7 @@ static void SetEnv(const char* name, const char* value) {
#endif // GTEST_OS_WINDOWS_MOBILE #endif // GTEST_OS_WINDOWS_MOBILE
} }
#if !GTEST_OS_WINDOWS_MOBILE #ifndef GTEST_OS_WINDOWS_MOBILE
// Environment variables are not supported on Windows CE. // Environment variables are not supported on Windows CE.
using testing::internal::Int32FromGTestEnv; using testing::internal::Int32FromGTestEnv;
...@@ -1817,7 +1815,7 @@ TEST(ParseInt32FlagTest, ParsesAndReturnsValidValue) { ...@@ -1817,7 +1815,7 @@ TEST(ParseInt32FlagTest, ParsesAndReturnsValidValue) {
// Tests that Int32FromEnvOrDie() parses the value of the var or // Tests that Int32FromEnvOrDie() parses the value of the var or
// returns the correct default. // returns the correct default.
// Environment variables are not supported on Windows CE. // Environment variables are not supported on Windows CE.
#if !GTEST_OS_WINDOWS_MOBILE #ifndef GTEST_OS_WINDOWS_MOBILE
TEST(Int32FromEnvOrDieTest, ParsesAndReturnsValidValue) { TEST(Int32FromEnvOrDieTest, ParsesAndReturnsValidValue) {
EXPECT_EQ(333, Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ "UnsetVar", 333)); EXPECT_EQ(333, Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ "UnsetVar", 333));
SetEnv(GTEST_FLAG_PREFIX_UPPER_ "UnsetVar", "123"); SetEnv(GTEST_FLAG_PREFIX_UPPER_ "UnsetVar", "123");
...@@ -1890,7 +1888,7 @@ TEST_F(ShouldShardTest, ReturnsFalseWhenTotalShardIsOne) { ...@@ -1890,7 +1888,7 @@ TEST_F(ShouldShardTest, ReturnsFalseWhenTotalShardIsOne) {
// Tests that sharding is enabled if total_shards > 1 and // Tests that sharding is enabled if total_shards > 1 and
// we are not in a death test subprocess. // we are not in a death test subprocess.
// Environment variables are not supported on Windows CE. // Environment variables are not supported on Windows CE.
#if !GTEST_OS_WINDOWS_MOBILE #ifndef GTEST_OS_WINDOWS_MOBILE
TEST_F(ShouldShardTest, WorksWhenShardEnvVarsAreValid) { TEST_F(ShouldShardTest, WorksWhenShardEnvVarsAreValid) {
SetEnv(index_var_, "4"); SetEnv(index_var_, "4");
SetEnv(total_var_, "22"); SetEnv(total_var_, "22");
...@@ -3920,7 +3918,7 @@ TEST(AssertionTest, NamedEnum) { ...@@ -3920,7 +3918,7 @@ TEST(AssertionTest, NamedEnum) {
enum { enum {
kCaseA = -1, kCaseA = -1,
#if GTEST_OS_LINUX #ifdef GTEST_OS_LINUX
// We want to test the case where the size of the anonymous enum is // We want to test the case where the size of the anonymous enum is
// larger than sizeof(int), to make sure our implementation of the // larger than sizeof(int), to make sure our implementation of the
...@@ -3943,7 +3941,7 @@ enum { ...@@ -3943,7 +3941,7 @@ enum {
}; };
TEST(AssertionTest, AnonymousEnum) { TEST(AssertionTest, AnonymousEnum) {
#if GTEST_OS_LINUX #ifdef GTEST_OS_LINUX
EXPECT_EQ(static_cast<int>(kCaseA), static_cast<int>(kCaseB)); EXPECT_EQ(static_cast<int>(kCaseA), static_cast<int>(kCaseB));
...@@ -3977,7 +3975,7 @@ TEST(AssertionTest, AnonymousEnum) { ...@@ -3977,7 +3975,7 @@ TEST(AssertionTest, AnonymousEnum) {
#endif // !GTEST_OS_MAC && !defined(__SUNPRO_CC) #endif // !GTEST_OS_MAC && !defined(__SUNPRO_CC)
#if GTEST_OS_WINDOWS #ifdef GTEST_OS_WINDOWS
static HRESULT UnexpectedHRESULTFailure() { return E_UNEXPECTED; } static HRESULT UnexpectedHRESULTFailure() { return E_UNEXPECTED; }
...@@ -4337,7 +4335,7 @@ TEST(AssertionWithMessageTest, ASSERT_TRUE) { ...@@ -4337,7 +4335,7 @@ TEST(AssertionWithMessageTest, ASSERT_TRUE) {
"(null)(null)"); "(null)(null)");
} }
#if GTEST_OS_WINDOWS #ifdef GTEST_OS_WINDOWS
// Tests using wide strings in assertion messages. // Tests using wide strings in assertion messages.
TEST(AssertionWithMessageTest, WideStringMessage) { TEST(AssertionWithMessageTest, WideStringMessage) {
EXPECT_NONFATAL_FAILURE( EXPECT_NONFATAL_FAILURE(
...@@ -4949,7 +4947,7 @@ TEST(ComparisonAssertionTest, AcceptsUnprintableArgs) { ...@@ -4949,7 +4947,7 @@ TEST(ComparisonAssertionTest, AcceptsUnprintableArgs) {
// both in a TEST and in a TEST_F. // both in a TEST and in a TEST_F.
class Foo { class Foo {
public: public:
Foo() {} Foo() = default;
private: private:
int Bar() const { return 1; } int Bar() const { return 1; }
...@@ -6172,12 +6170,12 @@ TEST_F(ParseFlagsTest, FilterBad) { ...@@ -6172,12 +6170,12 @@ TEST_F(ParseFlagsTest, FilterBad) {
const char* argv2[] = {"foo.exe", "--gtest_filter", nullptr}; const char* argv2[] = {"foo.exe", "--gtest_filter", nullptr};
#if GTEST_HAS_ABSL && GTEST_HAS_DEATH_TEST #if defined(GTEST_HAS_ABSL) && defined(GTEST_HAS_DEATH_TEST)
// Invalid flag arguments are a fatal error when using the Abseil Flags. // Invalid flag arguments are a fatal error when using the Abseil Flags.
EXPECT_EXIT(GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true), EXPECT_EXIT(GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true),
testing::ExitedWithCode(1), testing::ExitedWithCode(1),
"ERROR: Missing the value for the flag 'gtest_filter'"); "ERROR: Missing the value for the flag 'gtest_filter'");
#elif !GTEST_HAS_ABSL #elif !defined(GTEST_HAS_ABSL)
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true);
#else #else
static_cast<void>(argv); static_cast<void>(argv);
...@@ -6191,12 +6189,12 @@ TEST_F(ParseFlagsTest, OutputEmpty) { ...@@ -6191,12 +6189,12 @@ TEST_F(ParseFlagsTest, OutputEmpty) {
const char* argv2[] = {"foo.exe", "--gtest_output", nullptr}; const char* argv2[] = {"foo.exe", "--gtest_output", nullptr};
#if GTEST_HAS_ABSL && GTEST_HAS_DEATH_TEST #if defined(GTEST_HAS_ABSL) && defined(GTEST_HAS_DEATH_TEST)
// Invalid flag arguments are a fatal error when using the Abseil Flags. // Invalid flag arguments are a fatal error when using the Abseil Flags.
EXPECT_EXIT(GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true), EXPECT_EXIT(GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true),
testing::ExitedWithCode(1), testing::ExitedWithCode(1),
"ERROR: Missing the value for the flag 'gtest_output'"); "ERROR: Missing the value for the flag 'gtest_output'");
#elif !GTEST_HAS_ABSL #elif !defined(GTEST_HAS_ABSL)
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true);
#else #else
static_cast<void>(argv); static_cast<void>(argv);
...@@ -6204,7 +6202,7 @@ TEST_F(ParseFlagsTest, OutputEmpty) { ...@@ -6204,7 +6202,7 @@ TEST_F(ParseFlagsTest, OutputEmpty) {
#endif #endif
} }
#if GTEST_HAS_ABSL #ifdef GTEST_HAS_ABSL
TEST_F(ParseFlagsTest, AbseilPositionalFlags) { TEST_F(ParseFlagsTest, AbseilPositionalFlags) {
const char* argv[] = {"foo.exe", "--gtest_throw_on_failure=1", "--", const char* argv[] = {"foo.exe", "--gtest_throw_on_failure=1", "--",
"--other_flag", nullptr}; "--other_flag", nullptr};
...@@ -6218,7 +6216,16 @@ TEST_F(ParseFlagsTest, AbseilPositionalFlags) { ...@@ -6218,7 +6216,16 @@ TEST_F(ParseFlagsTest, AbseilPositionalFlags) {
} }
#endif #endif
#if GTEST_OS_WINDOWS TEST_F(ParseFlagsTest, UnrecognizedFlags) {
const char* argv[] = {"foo.exe", "--gtest_filter=abcd", "--other_flag",
nullptr};
const char* argv2[] = {"foo.exe", "--other_flag", nullptr};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("abcd"), false);
}
#ifdef GTEST_OS_WINDOWS
// Tests parsing wide strings. // Tests parsing wide strings.
TEST_F(ParseFlagsTest, WideStrings) { TEST_F(ParseFlagsTest, WideStrings) {
const wchar_t* argv[] = {L"foo.exe", const wchar_t* argv[] = {L"foo.exe",
...@@ -6608,7 +6615,7 @@ TEST(ColoredOutputTest, UsesColorsWhenStdoutIsTty) { ...@@ -6608,7 +6615,7 @@ TEST(ColoredOutputTest, UsesColorsWhenStdoutIsTty) {
TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) { TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {
GTEST_FLAG_SET(color, "auto"); GTEST_FLAG_SET(color, "auto");
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW #if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MINGW)
// On Windows, we ignore the TERM variable as it's usually not set. // On Windows, we ignore the TERM variable as it's usually not set.
SetEnv("TERM", "dumb"); SetEnv("TERM", "dumb");
...@@ -6974,7 +6981,7 @@ TEST(EventListenerTest, SuppressEventForwarding) { ...@@ -6974,7 +6981,7 @@ TEST(EventListenerTest, SuppressEventForwarding) {
// Tests that events generated by Google Test are not forwarded in // Tests that events generated by Google Test are not forwarded in
// death test subprocesses. // death test subprocesses.
TEST(EventListenerDeathTest, EventsNotForwardedInDeathTestSubprecesses) { TEST(EventListenerDeathTest, EventsNotForwardedInDeathTestSubprocesses) {
EXPECT_DEATH_IF_SUPPORTED( EXPECT_DEATH_IF_SUPPORTED(
{ {
GTEST_CHECK_(TestEventListenersAccessor::EventForwardingEnabled( GTEST_CHECK_(TestEventListenersAccessor::EventForwardingEnabled(
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
// gtest_xml_outfile2_test_ writes some xml via TestProperty used by // gtest_xml_outfile2_test_ writes some xml via TestProperty used by
// gtest_xml_outfiles_test.py // gtest_xml_outfiles_test.py
#include <atomic>
#include "gtest/gtest.h" #include "gtest/gtest.h"
class PropertyTwo : public testing::Test { class PropertyTwo : public testing::Test {
...@@ -38,9 +40,7 @@ class PropertyTwo : public testing::Test { ...@@ -38,9 +40,7 @@ class PropertyTwo : public testing::Test {
void TearDown() override { RecordProperty("TearDownProp", 2); } void TearDown() override { RecordProperty("TearDownProp", 2); }
}; };
TEST_F(PropertyTwo, TestInt64Properties) { TEST_F(PropertyTwo, TestInt64ConvertibleProperties) {
// Floats and doubles are written as int64_t, so we test that the values
// written are truncated to int64_t.
float float_prop = 3.25; float float_prop = 3.25;
RecordProperty("TestFloatProperty", float_prop); RecordProperty("TestFloatProperty", float_prop);
......
...@@ -57,14 +57,14 @@ EXPECTED_XML_1 = """<?xml version="1.0" encoding="UTF-8"?> ...@@ -57,14 +57,14 @@ EXPECTED_XML_1 = """<?xml version="1.0" encoding="UTF-8"?>
EXPECTED_XML_2 = """<?xml version="1.0" encoding="UTF-8"?> EXPECTED_XML_2 = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests"> <testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
<testsuite name="PropertyTwo" tests="1" failures="0" skipped="0" disabled="0" errors="0" time="*" timestamp="*"> <testsuite name="PropertyTwo" tests="1" failures="0" skipped="0" disabled="0" errors="0" time="*" timestamp="*">
<testcase name="TestInt64Properties" file="gtest_xml_outfile2_test_.cc" line="41" status="run" result="completed" time="*" timestamp="*" classname="PropertyTwo"> <testcase name="TestInt64ConvertibleProperties" file="gtest_xml_outfile2_test_.cc" line="43" status="run" result="completed" time="*" timestamp="*" classname="PropertyTwo">
<properties> <properties>
<property name="SetUpProp" value="2"/> <property name="SetUpProp" value="2"/>
<property name="TestFloatProperty" value="3"/> <property name="TestFloatProperty" value="3.25"/>
<property name="TestDoubleProperty" value="4"/> <property name="TestDoubleProperty" value="4.75"/>
<property name="TestSizetProperty" value="5"/> <property name="TestSizetProperty" value="5"/>
<property name="TestBoolProperty" value="1"/> <property name="TestBoolProperty" value="true"/>
<property name="TestCharProperty" value="65"/> <property name="TestCharProperty" value="A"/>
<property name="TestInt16Property" value="6"/> <property name="TestInt16Property" value="6"/>
<property name="TestInt32Property" value="7"/> <property name="TestInt32Property" value="7"/>
<property name="TestInt64Property" value="8"/> <property name="TestInt64Property" value="8"/>
......
...@@ -59,135 +59,138 @@ SUPPORTS_STACK_TRACES = NO_STACKTRACE_SUPPORT_FLAG not in sys.argv ...@@ -59,135 +59,138 @@ SUPPORTS_STACK_TRACES = NO_STACKTRACE_SUPPORT_FLAG not in sys.argv
if SUPPORTS_STACK_TRACES: if SUPPORTS_STACK_TRACES:
STACK_TRACE_TEMPLATE = '\nStack trace:\n*' STACK_TRACE_TEMPLATE = '\nStack trace:\n*'
STACK_TRACE_ENTITY_TEMPLATE = ''
else: else:
STACK_TRACE_TEMPLATE = '' STACK_TRACE_TEMPLATE = '\n'
STACK_TRACE_ENTITY_TEMPLATE = '&#x0A;'
# unittest.main() can't handle unknown flags # unittest.main() can't handle unknown flags
sys.argv.remove(NO_STACKTRACE_SUPPORT_FLAG) sys.argv.remove(NO_STACKTRACE_SUPPORT_FLAG)
EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?> EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="26" failures="5" disabled="2" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42"> <testsuites tests="26" failures="5" disabled="2" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42">
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="51" status="run" result="completed" time="*" timestamp="*" classname="SuccessfulTest"/> <testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="53" status="run" result="completed" time="*" timestamp="*" classname="SuccessfulTest"/>
</testsuite> </testsuite>
<testsuite name="FailedTest" tests="1" failures="1" disabled="0" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="FailedTest" tests="1" failures="1" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="Fails" file="gtest_xml_output_unittest_.cc" line="59" status="run" result="completed" time="*" timestamp="*" classname="FailedTest"> <testcase name="Fails" file="gtest_xml_output_unittest_.cc" line="61" status="run" result="completed" time="*" timestamp="*" classname="FailedTest">
<failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:* <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Expected equality of these values: Expected equality of these values:
1 1
2%(stack)s]]></failure> 2%(stack)s]]></failure>
</testcase> </testcase>
</testsuite> </testsuite>
<testsuite name="MixedResultTest" tests="3" failures="1" disabled="1" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="MixedResultTest" tests="3" failures="1" disabled="1" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="86" status="run" result="completed" time="*" timestamp="*" classname="MixedResultTest"/> <testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="88" status="run" result="completed" time="*" timestamp="*" classname="MixedResultTest"/>
<testcase name="Fails" file="gtest_xml_output_unittest_.cc" line="91" status="run" result="completed" time="*" timestamp="*" classname="MixedResultTest"> <testcase name="Fails" file="gtest_xml_output_unittest_.cc" line="93" status="run" result="completed" time="*" timestamp="*" classname="MixedResultTest">
<failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:* <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Expected equality of these values: Expected equality of these values:
1 1
2%(stack)s]]></failure> 2%(stack)s]]></failure>
<failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 2&#x0A; 3" type=""><![CDATA[gtest_xml_output_unittest_.cc:* <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 2&#x0A; 3%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Expected equality of these values: Expected equality of these values:
2 2
3%(stack)s]]></failure> 3%(stack)s]]></failure>
</testcase> </testcase>
<testcase name="DISABLED_test" file="gtest_xml_output_unittest_.cc" line="96" status="notrun" result="suppressed" time="*" timestamp="*" classname="MixedResultTest"/> <testcase name="DISABLED_test" file="gtest_xml_output_unittest_.cc" line="98" status="notrun" result="suppressed" time="*" timestamp="*" classname="MixedResultTest"/>
</testsuite> </testsuite>
<testsuite name="XmlQuotingTest" tests="1" failures="1" disabled="0" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="XmlQuotingTest" tests="1" failures="1" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="OutputsCData" file="gtest_xml_output_unittest_.cc" line="100" status="run" result="completed" time="*" timestamp="*" classname="XmlQuotingTest"> <testcase name="OutputsCData" file="gtest_xml_output_unittest_.cc" line="102" status="run" result="completed" time="*" timestamp="*" classname="XmlQuotingTest">
<failure message="gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;XML output: &lt;?xml encoding=&quot;utf-8&quot;&gt;&lt;top&gt;&lt;![CDATA[cdata text]]&gt;&lt;/top&gt;" type=""><![CDATA[gtest_xml_output_unittest_.cc:* <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;XML output: &lt;?xml encoding=&quot;utf-8&quot;&gt;&lt;top&gt;&lt;![CDATA[cdata text]]&gt;&lt;/top&gt;%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Failed Failed
XML output: <?xml encoding="utf-8"><top><![CDATA[cdata text]]>]]&gt;<![CDATA[</top>%(stack)s]]></failure> XML output: <?xml encoding="utf-8"><top><![CDATA[cdata text]]>]]&gt;<![CDATA[</top>%(stack)s]]></failure>
</testcase> </testcase>
</testsuite> </testsuite>
<testsuite name="InvalidCharactersTest" tests="1" failures="1" disabled="0" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="InvalidCharactersTest" tests="1" failures="1" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="InvalidCharactersInMessage" file="gtest_xml_output_unittest_.cc" line="107" status="run" result="completed" time="*" timestamp="*" classname="InvalidCharactersTest"> <testcase name="InvalidCharactersInMessage" file="gtest_xml_output_unittest_.cc" line="109" status="run" result="completed" time="*" timestamp="*" classname="InvalidCharactersTest">
<failure message="gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;Invalid characters in brackets []" type=""><![CDATA[gtest_xml_output_unittest_.cc:* <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;Invalid characters in brackets []%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Failed Failed
Invalid characters in brackets []%(stack)s]]></failure> Invalid characters in brackets []%(stack)s]]></failure>
</testcase> </testcase>
</testsuite> </testsuite>
<testsuite name="DisabledTest" tests="1" failures="0" disabled="1" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="DisabledTest" tests="1" failures="0" disabled="1" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="DISABLED_test_not_run" file="gtest_xml_output_unittest_.cc" line="66" status="notrun" result="suppressed" time="*" timestamp="*" classname="DisabledTest"/> <testcase name="DISABLED_test_not_run" file="gtest_xml_output_unittest_.cc" line="68" status="notrun" result="suppressed" time="*" timestamp="*" classname="DisabledTest"/>
</testsuite> </testsuite>
<testsuite name="SkippedTest" tests="3" failures="1" disabled="0" skipped="2" errors="0" time="*" timestamp="*"> <testsuite name="SkippedTest" tests="3" failures="1" disabled="0" skipped="2" errors="0" time="*" timestamp="*">
<testcase name="Skipped" status="run" file="gtest_xml_output_unittest_.cc" line="73" result="skipped" time="*" timestamp="*" classname="SkippedTest"> <testcase name="Skipped" status="run" file="gtest_xml_output_unittest_.cc" line="75" result="skipped" time="*" timestamp="*" classname="SkippedTest">
<skipped message="gtest_xml_output_unittest_.cc:*&#x0A;"><![CDATA[gtest_xml_output_unittest_.cc:* <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
%(stack)s]]></skipped> %(stack)s]]></skipped>
</testcase> </testcase>
<testcase name="SkippedWithMessage" file="gtest_xml_output_unittest_.cc" line="77" status="run" result="skipped" time="*" timestamp="*" classname="SkippedTest"> <testcase name="SkippedWithMessage" file="gtest_xml_output_unittest_.cc" line="79" status="run" result="skipped" time="*" timestamp="*" classname="SkippedTest">
<skipped message="gtest_xml_output_unittest_.cc:*&#x0A;It is good practice to tell why you skip a test."><![CDATA[gtest_xml_output_unittest_.cc:* <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;It is good practice to tell why you skip a test.%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
It is good practice to tell why you skip a test.%(stack)s]]></skipped> It is good practice to tell why you skip a test.%(stack)s]]></skipped>
</testcase> </testcase>
<testcase name="SkippedAfterFailure" file="gtest_xml_output_unittest_.cc" line="81" status="run" result="completed" time="*" timestamp="*" classname="SkippedTest"> <testcase name="SkippedAfterFailure" file="gtest_xml_output_unittest_.cc" line="83" status="run" result="completed" time="*" timestamp="*" classname="SkippedTest">
<failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:* <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Expected equality of these values: Expected equality of these values:
1 1
2%(stack)s]]></failure> 2%(stack)s]]></failure>
<skipped message="gtest_xml_output_unittest_.cc:*&#x0A;It is good practice to tell why you skip a test."><![CDATA[gtest_xml_output_unittest_.cc:* <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;It is good practice to tell why you skip a test.%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
It is good practice to tell why you skip a test.%(stack)s]]></skipped> It is good practice to tell why you skip a test.%(stack)s]]></skipped>
</testcase> </testcase>
</testsuite> </testsuite>
<testsuite name="PropertyRecordingTest" tests="4" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*" SetUpTestSuite="yes" TearDownTestSuite="aye"> <testsuite name="PropertyRecordingTest" tests="4" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*" SetUpTestSuite="yes" TearDownTestSuite="aye">
<testcase name="OneProperty" file="gtest_xml_output_unittest_.cc" line="119" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest"> <testcase name="OneProperty" file="gtest_xml_output_unittest_.cc" line="121" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
<properties> <properties>
<property name="key_1" value="1"/> <property name="key_1" value="1"/>
</properties> </properties>
</testcase> </testcase>
<testcase name="IntValuedProperty" file="gtest_xml_output_unittest_.cc" line="123" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest"> <testcase name="IntValuedProperty" file="gtest_xml_output_unittest_.cc" line="125" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
<properties> <properties>
<property name="key_int" value="1"/> <property name="key_int" value="1"/>
</properties> </properties>
</testcase> </testcase>
<testcase name="ThreeProperties" file="gtest_xml_output_unittest_.cc" line="127" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest"> <testcase name="ThreeProperties" file="gtest_xml_output_unittest_.cc" line="129" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
<properties> <properties>
<property name="key_1" value="1"/> <property name="key_1" value="1"/>
<property name="key_2" value="2"/> <property name="key_2" value="2"/>
<property name="key_3" value="3"/> <property name="key_3" value="3"/>
</properties> </properties>
</testcase> </testcase>
<testcase name="TwoValuesForOneKeyUsesLastValue" file="gtest_xml_output_unittest_.cc" line="133" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest"> <testcase name="TwoValuesForOneKeyUsesLastValue" file="gtest_xml_output_unittest_.cc" line="135" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
<properties> <properties>
<property name="key_1" value="2"/> <property name="key_1" value="2"/>
</properties> </properties>
</testcase> </testcase>
</testsuite> </testsuite>
<testsuite name="NoFixtureTest" tests="3" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="NoFixtureTest" tests="3" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="RecordProperty" file="gtest_xml_output_unittest_.cc" line="138" status="run" result="completed" time="*" timestamp="*" classname="NoFixtureTest"> <testcase name="RecordProperty" file="gtest_xml_output_unittest_.cc" line="140" status="run" result="completed" time="*" timestamp="*" classname="NoFixtureTest">
<properties> <properties>
<property name="key" value="1"/> <property name="key" value="1"/>
</properties> </properties>
</testcase> </testcase>
<testcase name="ExternalUtilityThatCallsRecordIntValuedProperty" file="gtest_xml_output_unittest_.cc" line="151" status="run" result="completed" time="*" timestamp="*" classname="NoFixtureTest"> <testcase name="ExternalUtilityThatCallsRecordIntValuedProperty" file="gtest_xml_output_unittest_.cc" line="153" status="run" result="completed" time="*" timestamp="*" classname="NoFixtureTest">
<properties> <properties>
<property name="key_for_utility_int" value="1"/> <property name="key_for_utility_int" value="1"/>
</properties> </properties>
</testcase> </testcase>
<testcase name="ExternalUtilityThatCallsRecordStringValuedProperty" file="gtest_xml_output_unittest_.cc" line="155" status="run" result="completed" time="*" timestamp="*" classname="NoFixtureTest"> <testcase name="ExternalUtilityThatCallsRecordStringValuedProperty" file="gtest_xml_output_unittest_.cc" line="157" status="run" result="completed" time="*" timestamp="*" classname="NoFixtureTest">
<properties> <properties>
<property name="key_for_utility_string" value="1"/> <property name="key_for_utility_string" value="1"/>
</properties> </properties>
</testcase> </testcase>
</testsuite> </testsuite>
<testsuite name="Single/ValueParamTest" tests="4" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="Single/ValueParamTest" tests="4" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="HasValueParamAttribute/0" file="gtest_xml_output_unittest_.cc" line="162" value_param="33" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" /> <testcase name="HasValueParamAttribute/0" file="gtest_xml_output_unittest_.cc" line="164" value_param="33" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
<testcase name="HasValueParamAttribute/1" file="gtest_xml_output_unittest_.cc" line="162" value_param="42" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" /> <testcase name="HasValueParamAttribute/1" file="gtest_xml_output_unittest_.cc" line="164" value_param="42" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
<testcase name="AnotherTestThatHasValueParamAttribute/0" file="gtest_xml_output_unittest_.cc" line="163" value_param="33" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" /> <testcase name="AnotherTestThatHasValueParamAttribute/0" file="gtest_xml_output_unittest_.cc" line="165" value_param="33" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
<testcase name="AnotherTestThatHasValueParamAttribute/1" file="gtest_xml_output_unittest_.cc" line="163" value_param="42" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" /> <testcase name="AnotherTestThatHasValueParamAttribute/1" file="gtest_xml_output_unittest_.cc" line="165" value_param="42" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
</testsuite> </testsuite>
<testsuite name="TypedTest/0" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="TypedTest/0" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="171" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="TypedTest/0" /> <testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="173" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="TypedTest/0" />
</testsuite> </testsuite>
<testsuite name="TypedTest/1" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="TypedTest/1" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="171" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="TypedTest/1" /> <testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="173" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="TypedTest/1" />
</testsuite> </testsuite>
<testsuite name="Single/TypeParameterizedTestSuite/0" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="Single/TypeParameterizedTestSuite/0" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="178" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="Single/TypeParameterizedTestSuite/0" /> <testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="180" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="Single/TypeParameterizedTestSuite/0" />
</testsuite> </testsuite>
<testsuite name="Single/TypeParameterizedTestSuite/1" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="Single/TypeParameterizedTestSuite/1" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="178" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="Single/TypeParameterizedTestSuite/1" /> <testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="180" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="Single/TypeParameterizedTestSuite/1" />
</testsuite> </testsuite>
</testsuites>""" % { </testsuites>""" % {
'stack': STACK_TRACE_TEMPLATE 'stack': STACK_TRACE_TEMPLATE,
'stack_entity': STACK_TRACE_ENTITY_TEMPLATE,
} }
EXPECTED_FILTERED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?> EXPECTED_FILTERED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
...@@ -195,24 +198,24 @@ EXPECTED_FILTERED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?> ...@@ -195,24 +198,24 @@ EXPECTED_FILTERED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
timestamp="*" name="AllTests" ad_hoc_property="42"> timestamp="*" name="AllTests" ad_hoc_property="42">
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" skipped="0" <testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" skipped="0"
errors="0" time="*" timestamp="*"> errors="0" time="*" timestamp="*">
<testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="51" status="run" result="completed" time="*" timestamp="*" classname="SuccessfulTest"/> <testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="53" status="run" result="completed" time="*" timestamp="*" classname="SuccessfulTest"/>
</testsuite> </testsuite>
</testsuites>""" </testsuites>"""
EXPECTED_SHARDED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?> EXPECTED_SHARDED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="3" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42"> <testsuites tests="3" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42">
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="51" status="run" result="completed" time="*" timestamp="*" classname="SuccessfulTest"/> <testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="53" status="run" result="completed" time="*" timestamp="*" classname="SuccessfulTest"/>
</testsuite> </testsuite>
<testsuite name="PropertyRecordingTest" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*" SetUpTestSuite="yes" TearDownTestSuite="aye"> <testsuite name="PropertyRecordingTest" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*" SetUpTestSuite="yes" TearDownTestSuite="aye">
<testcase name="IntValuedProperty" file="gtest_xml_output_unittest_.cc" line="123" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest"> <testcase name="IntValuedProperty" file="gtest_xml_output_unittest_.cc" line="125" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
<properties> <properties>
<property name="key_int" value="1"/> <property name="key_int" value="1"/>
</properties> </properties>
</testcase> </testcase>
</testsuite> </testsuite>
<testsuite name="Single/ValueParamTest" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="Single/ValueParamTest" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="HasValueParamAttribute/0" file="gtest_xml_output_unittest_.cc" line="162" value_param="33" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" /> <testcase name="HasValueParamAttribute/0" file="gtest_xml_output_unittest_.cc" line="164" value_param="33" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
</testsuite> </testsuite>
</testsuites>""" </testsuites>"""
...@@ -221,14 +224,15 @@ EXPECTED_NO_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?> ...@@ -221,14 +224,15 @@ EXPECTED_NO_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
timestamp="*" name="AllTests"> timestamp="*" name="AllTests">
<testsuite name="NonTestSuiteFailure" tests="1" failures="1" disabled="0" skipped="0" errors="0" time="*" timestamp="*"> <testsuite name="NonTestSuiteFailure" tests="1" failures="1" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="" status="run" result="completed" time="*" timestamp="*" classname=""> <testcase name="" status="run" result="completed" time="*" timestamp="*" classname="">
<failure message="gtest_no_test_unittest.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2" type=""><![CDATA[gtest_no_test_unittest.cc:* <failure message="gtest_no_test_unittest.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2%(stack_entity)s" type=""><![CDATA[gtest_no_test_unittest.cc:*
Expected equality of these values: Expected equality of these values:
1 1
2%(stack)s]]></failure> 2%(stack)s]]></failure>
</testcase> </testcase>
</testsuite> </testsuite>
</testsuites>""" % { </testsuites>""" % {
'stack': STACK_TRACE_TEMPLATE 'stack': STACK_TRACE_TEMPLATE,
'stack_entity': STACK_TRACE_ENTITY_TEMPLATE,
} }
GTEST_PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath(GTEST_PROGRAM_NAME) GTEST_PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath(GTEST_PROGRAM_NAME)
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
// directly. // directly.
// clang-format off // clang-format off
#include <string>
#include "gtest/gtest.h" #include "gtest/gtest.h"
using ::testing::InitGoogleTest; using ::testing::InitGoogleTest;
......
...@@ -218,7 +218,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): ...@@ -218,7 +218,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
) )
if element.tagName in ('testsuites', 'testsuite', 'testcase'): if element.tagName in ('testsuites', 'testsuite', 'testcase'):
time = element.getAttributeNode('time') time = element.getAttributeNode('time')
# The value for exact N seconds has a traling decimal point (e.g., "10." # The value for exact N seconds has a trailing decimal point (e.g., "10."
# instead of "10") # instead of "10")
time.value = re.sub(r'^\d+\.(\d+)?$', '*', time.value) time.value = re.sub(r'^\d+\.(\d+)?$', '*', time.value)
type_param = element.getAttributeNode('type_param') type_param = element.getAttributeNode('type_param')
......
"""Load dependencies needed to use the googletest library as a 3rd-party consumer."""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def googletest_deps():
"""Loads common dependencies needed to use the googletest library."""
if not native.existing_rule("com_googlesource_code_re2"):
http_archive(
name = "com_googlesource_code_re2", # 2022-12-21T14:29:10Z
sha256 = "b9ce3a51beebb38534d11d40f8928d40509b9e18a735f6a4a97ad3d014c87cb5",
strip_prefix = "re2-d0b1f8f2ecc2ea74956c7608b6f915175314ff0e",
urls = ["https://github.com/google/re2/archive/d0b1f8f2ecc2ea74956c7608b6f915175314ff0e.zip"],
)
if not native.existing_rule("com_google_absl"):
http_archive(
name = "com_google_absl", # 2023-04-06T14:42:25Z
sha256 = "a50452f02402262f9a61a8eedda60f76dda6b9538d36b34b55bce9f74a4d5ef8",
strip_prefix = "abseil-cpp-e73b9139ee9b853a4bd7812531442c138da09084",
urls = ["https://github.com/abseil/abseil-cpp/archive/e73b9139ee9b853a4bd7812531442c138da09084.zip"],
)
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