googletest
googletest copied to clipboard
TEST_TMPDIR is ignored on macOS
Describe the bug
On macOS, testing::TempDir() returns /tmp even when using bazel to run test. It would be better to use $TEST_TMPDIR or $GTEST_TMP_DIR if running under bazel.
Steps to reproduce the bug
In a bazel workspace, run a cc_test that uses testing::TempDir(), note that it uses /tmp
BUILD:
cc_test(
name = "tempdir_test",
srcs = ["tempdir_test.cc"],
deps = ["@gtest//:gtest"]
)
// tempdir_test.cc
#include "gtest/gtest.h"
TEST(TempDirTest, CheckTempdir) { //
EXPECT_NE("/tmp/", testing::TempDir());
}
int main() {
testing::InitGoogleTest();
return RUN_ALL_TESTS();
}
It's important that we are able to reproduce the problem that you are
experiencing. Please provide all code and relevant steps to reproduce the
problem, including your BUILD
/CMakeLists.txt
file and build commands. Links
to a GitHub branch or godbolt.org that demonstrate the
problem are also helpful.
Does the bug persist in the most recent commit?
yes
What operating system and version are you using?
macOS 12.3.1
What compiler and version are you using?
Apple clang version 13.1.6 (clang-1316.0.21.2.3) Target: arm64-apple-darwin21.4.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin
What build system are you using?
bazel 5.1.1-homebrew
Additional context
#3807 has the fix
https://github.com/google/googletest/pull/3807#issuecomment-1117642798
this can be closed?
Yes, all done. Thank you for the reminder.