Skip to content

Commit 2057566

Browse files
Abseil Teamcopybara-github
authored andcommitted
Remove some filesystem APIs and tests under !GTEST_HAS_FILE_SYSTEM
PiperOrigin-RevId: 509537606 Change-Id: I68f7054e34b1fe76c1fd85099fffa4ee3c2b00c0
1 parent b80a07f commit 2057566

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

googletest/src/gtest.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2325,7 +2325,9 @@ static std::vector<std::string> GetReservedAttributesForElement(
23252325
return std::vector<std::string>();
23262326
}
23272327

2328+
#if GTEST_HAS_FILE_SYSTEM
23282329
// TODO(jdesprez): Merge the two getReserved attributes once skip is improved
2330+
// This function is only used when file systems are enabled.
23292331
static std::vector<std::string> GetReservedOutputAttributesForElement(
23302332
const std::string& xml_element) {
23312333
if (xml_element == "testsuites") {
@@ -2340,6 +2342,7 @@ static std::vector<std::string> GetReservedOutputAttributesForElement(
23402342
// This code is unreachable but some compilers may not realizes that.
23412343
return std::vector<std::string>();
23422344
}
2345+
#endif
23432346

23442347
static std::string FormatWordList(const std::vector<std::string>& words) {
23452348
Message word_list;
@@ -6802,7 +6805,7 @@ std::string TempDir() {
68026805
#endif
68036806
}
68046807

6805-
#if !defined(GTEST_CUSTOM_SRCDIR_FUNCTION_)
6808+
#if GTEST_HAS_FILE_SYSTEM && !defined(GTEST_CUSTOM_SRCDIR_FUNCTION_)
68066809
// Returns the directory path (including terminating separator) of the current
68076810
// executable as derived from argv[0].
68086811
static std::string GetCurrentExecutableDirectory() {
@@ -6811,6 +6814,7 @@ static std::string GetCurrentExecutableDirectory() {
68116814
}
68126815
#endif
68136816

6817+
#if GTEST_HAS_FILE_SYSTEM
68146818
std::string SrcDir() {
68156819
#if defined(GTEST_CUSTOM_SRCDIR_FUNCTION_)
68166820
return GTEST_CUSTOM_SRCDIR_FUNCTION_();
@@ -6825,6 +6829,7 @@ std::string SrcDir() {
68256829
'/');
68266830
#endif
68276831
}
6832+
#endif
68286833

68296834
// Class ScopedTrace
68306835

googletest/test/gtest_dirs_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "gtest/gtest.h"
88
#include "gtest/internal/gtest-port.h"
99

10+
#if GTEST_HAS_FILE_SYSTEM
11+
1012
namespace {
1113

1214
class SetEnv {
@@ -94,4 +96,6 @@ TEST(SrcDirTest, NotInEnvironment) {
9496
EXPECT_NE(testing::SrcDir(), "");
9597
}
9698

99+
#endif // GTEST_HAS_FILE_SYSTEM
100+
97101
} // namespace

0 commit comments

Comments
 (0)