| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -552,6 +552,10 @@ int AppropriateResolution(FloatType val) { | |||
| 552 | 552 | int full = std::numeric_limits<FloatType>::max_digits10; | |
| 553 | 553 | if (val < 0) val = -val; | |
| 554 | 554 | ||
| 555 | + #ifdef __GNUC__ | ||
| 556 | + #pragma GCC diagnostic push | ||
| 557 | + #pragma GCC diagnostic ignored "-Wfloat-equal" | ||
| 558 | + #endif | ||
| 555 | 559 | if (val < 1000000) { | |
| 556 | 560 | FloatType mulfor6 = 1e10; | |
| 557 | 561 | if (val >= 100000.0) { // 100,000 to 999,999 | |
@@ -595,6 +599,9 @@ int AppropriateResolution(FloatType val) { | |||
| 595 | 599 | val) | |
| 596 | 600 | return 6; | |
| 597 | 601 | } | |
| 602 | + #ifdef __GNUC__ | ||
| 603 | + #pragma GCC diagnostic pop | ||
| 604 | + #endif | ||
| 598 | 605 | return full; | |
| 599 | 606 | } | |
| 600 | 607 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -338,9 +338,10 @@ | |||
| 338 | 338 | #define GTEST_HAS_NOTIFICATION_ 0 | |
| 339 | 339 | #endif | |
| 340 | 340 | ||
| 341 | - #ifdef GTEST_HAS_ABSL | ||
| 342 | - #include "absl/flags/declare.h" | ||
| 341 | + #if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS) | ||
| 342 | + #define GTEST_INTERNAL_HAS_ABSL_FLAGS // Used only in this file. | ||
| 343 | 343 | #include "absl/flags/flag.h" | |
| 344 | + #include "absl/flags/declare.h" | ||
| 344 | 345 | #include "absl/flags/reflection.h" | |
| 345 | 346 | #endif | |
| 346 | 347 | ||
@@ -2005,7 +2006,9 @@ inline std::string StripTrailingSpaces(std::string str) { | |||
| 2005 | 2006 | namespace posix { | |
| 2006 | 2007 | ||
| 2007 | 2008 | // File system porting. | |
| 2008 | - #if GTEST_HAS_FILE_SYSTEM | ||
| 2009 | + // Note: Not every I/O-related function is related to file systems, so don't | ||
| 2010 | + // just disable all of them here. For example, fileno() and isatty(), etc. must | ||
| 2011 | + // always be available in order to detect if a pipe points to a terminal. | ||
| 2009 | 2012 | #ifdef GTEST_OS_WINDOWS | |
| 2010 | 2013 | ||
| 2011 | 2014 | typedef struct _stat StatStruct; | |
@@ -2016,27 +2019,32 @@ inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); } | |||
| 2016 | 2019 | // time and thus not defined there. | |
| 2017 | 2020 | #else | |
| 2018 | 2021 | inline int FileNo(FILE* file) { return _fileno(file); } | |
| 2022 | + #if GTEST_HAS_FILE_SYSTEM | ||
| 2019 | 2023 | inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); } | |
| 2020 | 2024 | inline int RmDir(const char* dir) { return _rmdir(dir); } | |
| 2021 | 2025 | inline bool IsDir(const StatStruct& st) { return (_S_IFDIR & st.st_mode) != 0; } | |
| 2026 | + #endif | ||
| 2022 | 2027 | #endif // GTEST_OS_WINDOWS_MOBILE | |
| 2023 | 2028 | ||
| 2024 | 2029 | #elif defined(GTEST_OS_ESP8266) | |
| 2025 | 2030 | typedef struct stat StatStruct; | |
| 2026 | 2031 | ||
| 2027 | 2032 | inline int FileNo(FILE* file) { return fileno(file); } | |
| 2033 | + #if GTEST_HAS_FILE_SYSTEM | ||
| 2028 | 2034 | inline int Stat(const char* path, StatStruct* buf) { | |
| 2029 | 2035 | // stat function not implemented on ESP8266 | |
| 2030 | 2036 | return 0; | |
| 2031 | 2037 | } | |
| 2032 | 2038 | inline int RmDir(const char* dir) { return rmdir(dir); } | |
| 2033 | 2039 | inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); } | |
| 2040 | + #endif | ||
| 2034 | 2041 | ||
| 2035 | 2042 | #else | |
| 2036 | 2043 | ||
| 2037 | 2044 | typedef struct stat StatStruct; | |
| 2038 | 2045 | ||
| 2039 | 2046 | inline int FileNo(FILE* file) { return fileno(file); } | |
| 2047 | + #if GTEST_HAS_FILE_SYSTEM | ||
| 2040 | 2048 | inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); } | |
| 2041 | 2049 | #ifdef GTEST_OS_QURT | |
| 2042 | 2050 | // QuRT doesn't support any directory functions, including rmdir | |
@@ -2045,9 +2053,9 @@ inline int RmDir(const char*) { return 0; } | |||
| 2045 | 2053 | inline int RmDir(const char* dir) { return rmdir(dir); } | |
| 2046 | 2054 | #endif | |
| 2047 | 2055 | inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); } | |
| 2056 | + #endif | ||
| 2048 | 2057 | ||
| 2049 | 2058 | #endif // GTEST_OS_WINDOWS | |
| 2050 | - #endif // GTEST_HAS_FILE_SYSTEM | ||
| 2051 | 2059 | ||
| 2052 | 2060 | // Other functions with a different name on Windows. | |
| 2053 | 2061 | ||
@@ -2245,7 +2253,7 @@ using TimeInMillis = int64_t; // Represents time in milliseconds. | |||
| 2245 | 2253 | #endif // !defined(GTEST_FLAG) | |
| 2246 | 2254 | ||
| 2247 | 2255 | // Pick a command line flags implementation. | |
| 2248 | - #ifdef GTEST_HAS_ABSL | ||
| 2256 | + #ifdef GTEST_INTERNAL_HAS_ABSL_FLAGS | ||
| 2249 | 2257 | ||
| 2250 | 2258 | // Macros for defining flags. | |
| 2251 | 2259 | #define GTEST_DEFINE_bool_(name, default_val, doc) \ | |
@@ -2270,7 +2278,8 @@ using TimeInMillis = int64_t; // Represents time in milliseconds. | |||
| 2270 | 2278 | (void)(::absl::SetFlag(>EST_FLAG(name), value)) | |
| 2271 | 2279 | #define GTEST_USE_OWN_FLAGFILE_FLAG_ 0 | |
| 2272 | 2280 | ||
| 2273 | - #else // GTEST_HAS_ABSL | ||
| 2281 | + #undef GTEST_INTERNAL_HAS_ABSL_FLAGS | ||
| 2282 | + #else // ndef GTEST_INTERNAL_HAS_ABSL_FLAGS | ||
| 2274 | 2283 | ||
| 2275 | 2284 | // Macros for defining flags. | |
| 2276 | 2285 | #define GTEST_DEFINE_bool_(name, default_val, doc) \ | |
@@ -2312,7 +2321,7 @@ using TimeInMillis = int64_t; // Represents time in milliseconds. | |||
| 2312 | 2321 | #define GTEST_FLAG_SET(name, value) (void)(::testing::GTEST_FLAG(name) = value) | |
| 2313 | 2322 | #define GTEST_USE_OWN_FLAGFILE_FLAG_ 1 | |
| 2314 | 2323 | ||
| 2315 | - #endif // GTEST_HAS_ABSL | ||
| 2324 | + #endif // GTEST_INTERNAL_HAS_ABSL_FLAGS | ||
| 2316 | 2325 | ||
| 2317 | 2326 | // Thread annotations | |
| 2318 | 2327 | #if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -162,6 +162,10 @@ | |||
| 162 | 162 | #define GTEST_HAS_BUILTIN(x) 0 | |
| 163 | 163 | #endif // defined(__has_builtin) | |
| 164 | 164 | ||
| 165 | + #if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS) | ||
| 166 | + #define GTEST_HAS_ABSL_FLAGS | ||
| 167 | + #endif | ||
| 168 | + | ||
| 165 | 169 | namespace testing { | |
| 166 | 170 | ||
| 167 | 171 | using internal::CountIf; | |
@@ -459,7 +463,12 @@ void AssertHelper::operator=(const Message& message) const { | |||
| 459 | 463 | UnitTest::GetInstance()->AddTestPartResult( | |
| 460 | 464 | data_->type, data_->file, data_->line, | |
| 461 | 465 | AppendUserMessage(data_->message, message), | |
| 462 | - UnitTest::GetInstance()->impl()->CurrentOsStackTraceExceptTop(1) | ||
| 466 | + // Suppress emission of the stack trace for GTEST_SKIP() since skipping is | ||
| 467 | + // an intentional act by the developer rather than a failure requiring | ||
| 468 | + // investigation. | ||
| 469 | + data_->type != TestPartResult::kSkip | ||
| 470 | + ? UnitTest::GetInstance()->impl()->CurrentOsStackTraceExceptTop(1) | ||
| 471 | + : "" | ||
| 463 | 472 | // Skips the stack frame for this function itself. | |
| 464 | 473 | ); // NOLINT | |
| 465 | 474 | } | |
@@ -3283,11 +3292,9 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) { | |||
| 3283 | 3292 | va_start(args, fmt); | |
| 3284 | 3293 | ||
| 3285 | 3294 | static const bool in_color_mode = | |
| 3286 | - #if GTEST_HAS_FILE_SYSTEM | ||
| 3295 | + // We don't condition this on GTEST_HAS_FILE_SYSTEM because we still need | ||
| 3296 | + // to be able to detect terminal I/O regardless. | ||
| 3287 | 3297 | ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0); | |
| 3288 | - #else | ||
| 3289 | - false; | ||
| 3290 | - #endif // GTEST_HAS_FILE_SYSTEM | ||
| 3291 | 3298 | ||
| 3292 | 3299 | const bool use_color = in_color_mode && (color != GTestColor::kDefault); | |
| 3293 | 3300 | ||
@@ -6685,7 +6692,7 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { | |||
| 6685 | 6692 | // remain in place. Unrecognized flags are not reported and do not cause the | |
| 6686 | 6693 | // program to exit. | |
| 6687 | 6694 | void ParseGoogleTestFlagsOnly(int* argc, char** argv) { | |
| 6688 | - #ifdef GTEST_HAS_ABSL | ||
| 6695 | + #ifdef GTEST_HAS_ABSL_FLAGS | ||
| 6689 | 6696 | if (*argc <= 0) return; | |
| 6690 | 6697 | ||
| 6691 | 6698 | std::vector<char*> positional_args; | |
@@ -6771,11 +6778,13 @@ void InitGoogleTestImpl(int* argc, CharType** argv) { | |||
| 6771 | 6778 | #ifdef GTEST_HAS_ABSL | |
| 6772 | 6779 | absl::InitializeSymbolizer(g_argvs[0].c_str()); | |
| 6773 | 6780 | ||
| 6781 | + #ifdef GTEST_HAS_ABSL_FLAGS | ||
| 6774 | 6782 | // When using the Abseil Flags library, set the program usage message to the | |
| 6775 | 6783 | // help message, but remove the color-encoding from the message first. | |
| 6776 | 6784 | absl::SetProgramUsageMessage(absl::StrReplaceAll( | |
| 6777 | 6785 | kColorEncodedHelpMessage, | |
| 6778 | 6786 | {{"@D", ""}, {"@R", ""}, {"@G", ""}, {"@Y", ""}, {"@@", "@"}})); | |
| 6787 | + #endif // GTEST_HAS_ABSL_FLAGS | ||
| 6779 | 6788 | #endif // GTEST_HAS_ABSL | |
| 6780 | 6789 | ||
| 6781 | 6790 | ParseGoogleTestFlagsOnly(argc, argv); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments