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_)
0 commit comments