googletest icon indicating copy to clipboard operation
googletest copied to clipboard

TEST_TMPDIR is ignored on macOS

Open muro opened this issue 2 years ago • 1 comments

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

muro avatar Apr 26 '22 07:04 muro

#3807 has the fix

muro avatar Apr 26 '22 07:04 muro

https://github.com/google/googletest/pull/3807#issuecomment-1117642798

this can be closed?

lummax avatar Dec 08 '22 09:12 lummax

Yes, all done. Thank you for the reminder.

muro avatar Dec 20 '22 13:12 muro