bumping googletest from 1.11.0 to 1.14.0 (#6702)

* bumping googletest from 1.11.0 to 1.14.0

* logging ::testing::TempDir()

* sandboxing ::testing::TempDir()
This commit is contained in:
Cœur 2024-03-18 04:13:56 +08:00 committed by GitHub
parent 0c466b4137
commit 0749300090
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 12 deletions

View File

@ -363,7 +363,8 @@ TEST_F(AnnounceListTest, save)
// first, set up a scratch torrent
auto constexpr* const OriginalFile = LIBTRANSMISSION_TEST_ASSETS_DIR "/Android-x86 8.1 r6 iso.torrent";
auto original_content = std::vector<char>{};
auto const test_file = tr_pathbuf{ ::testing::TempDir(), "transmission-announce-list-test.torrent"sv };
auto const sandbox = libtransmission::test::Sandbox::create_sandbox(::testing::TempDir(), "transmission-test-XXXXXX");
auto const test_file = tr_pathbuf{ sandbox, "transmission-announce-list-test.torrent"sv };
auto error = tr_error{};
EXPECT_TRUE(tr_file_read(OriginalFile, original_content, &error));
EXPECT_FALSE(error) << error;

View File

@ -140,6 +140,14 @@ public:
return sandbox_dir_;
}
static std::string create_sandbox(std::string const& parent_dir, std::string const& tmpl)
{
auto path = fmt::format(FMT_STRING("{:s}/{:s}"sv), tr_sys_path_resolve(parent_dir), tmpl);
tr_sys_dir_create_temp(std::data(path));
tr_sys_path_native_separators(std::data(path));
return path;
}
protected:
static std::string get_default_parent_dir()
{
@ -152,14 +160,6 @@ protected:
return tr_sys_dir_get_current(&error);
}
static std::string create_sandbox(std::string const& parent_dir, std::string const& tmpl)
{
auto path = fmt::format(FMT_STRING("{:s}/{:s}"sv), tr_sys_path_resolve(parent_dir), tmpl);
tr_sys_dir_create_temp(std::data(path));
tr_sys_path_native_separators(std::data(path));
return path;
}
static void rimraf(std::string const& path, bool verbose = false)
{
auto remove = [verbose](char const* filename)

View File

@ -134,8 +134,9 @@ TEST_F(TorrentMetainfoTest, AndroidTorrent)
TEST_F(TorrentMetainfoTest, ctorSaveContents)
{
auto const sandbox = libtransmission::test::Sandbox::create_sandbox(::testing::TempDir(), "transmission-test-XXXXXX");
auto const src_filename = tr_pathbuf{ LIBTRANSMISSION_TEST_ASSETS_DIR, "/Android-x86 8.1 r6 iso.torrent"sv };
auto const tgt_filename = tr_pathbuf{ ::testing::TempDir(), "save-contents-test.torrent" };
auto const tgt_filename = tr_pathbuf{ sandbox, "save-contents-test.torrent" };
// try saving without passing any metainfo.
auto* ctor = tr_ctorNew(session_);

View File

@ -262,7 +262,8 @@ TEST_F(UtilsTest, saveFile)
auto filename = tr_pathbuf{};
// save a file to GoogleTest's temp dir
filename.assign(::testing::TempDir(), "filename.txt"sv);
auto const sandbox = libtransmission::test::Sandbox::create_sandbox(::testing::TempDir(), "transmission-test-XXXXXX");
filename.assign(sandbox, "filename.txt"sv);
auto contents = "these are the contents"sv;
auto error = tr_error{};
EXPECT_TRUE(tr_file_save(filename.sv(), contents, &error));

@ -1 +1 @@
Subproject commit af29db7ec28d6df1c7f0f745186884091e602e07
Subproject commit f8d7d77c06936315286eb55f8de22cd23c188571