mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
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:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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_);
|
||||
|
||||
@@ -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));
|
||||
|
||||
2
third-party/googletest
vendored
2
third-party/googletest
vendored
Submodule third-party/googletest updated: af29db7ec2...f8d7d77c06
Reference in New Issue
Block a user