updated build system

This commit is contained in:
2024-08-31 12:32:10 -05:00
parent d745782b44
commit 3ec8f50382
4 changed files with 143 additions and 4 deletions

View File

@@ -118,8 +118,7 @@ auto get_test_input_dir() -> std::string {
auto get_test_output_dir() -> std::string {
static auto test_path = ([]() -> std::string {
std::string name{"project_test_XXXXXX"};
std::string temp{mktemp(name.data())};
auto temp = utils::file::create_temp_name("project_test");
#if defined(_WIN32)
auto path = utils::path::combine("%TEMP%", {temp});

View File

@@ -263,7 +263,7 @@ TEST(utils_file, smb_parent_is_not_same) {
}
#endif // defined(PROJECT_ENABLE_LIBDSM)
TEST(util_file, directory_exists_in_path) {
TEST(utils_file, directory_exists_in_path) {
auto &test_dir = test::generate_test_directory();
EXPECT_FALSE(
utils::file::directory_exists_in_path(test_dir.get_path(), "moose"));
@@ -293,7 +293,7 @@ TEST(util_file, directory_exists_in_path) {
}
}
TEST(util_file, file_exists_in_path) {
TEST(utils_file, file_exists_in_path) {
auto &test_dir = test::generate_test_directory();
EXPECT_FALSE(
utils::file::file_exists_in_path(test_dir.get_path(), "moose.txt"));
@@ -323,4 +323,104 @@ TEST(util_file, file_exists_in_path) {
utils::string::from_utf8(test_dir.get_path()), L"moose.txt"));
}
}
TEST(utils_file, get_free_drive_space) {
#if defined(_WIN32)
auto space = utils::file::get_free_drive_space("C:");
auto space2 = utils::file::get_free_drive_space(L"C:");
#else // defined(_WIN32)
auto space = utils::file::get_free_drive_space("/");
auto space2 = utils::file::get_free_drive_space(L"/");
#endif // !defined(_WIN32)
EXPECT_TRUE(space.has_value());
EXPECT_LT(0U, space.value());
EXPECT_TRUE(space2.has_value());
EXPECT_EQ(space.value(), space2.value());
}
TEST(utils_file, get_free_drive_space_fails_for_bad_path) {
std::string name{"free_drive_space_test_XXXXXX"};
auto temp = utils::file::create_temp_name("free_drive_space_test");
auto space = utils::file::get_free_drive_space(temp);
EXPECT_FALSE(space.has_value());
}
TEST(utils_file, get_total_drive_space) {
#if defined(_WIN32)
auto space = utils::file::get_total_drive_space("C:");
auto space2 = utils::file::get_total_drive_space(L"C:");
#else // defined(_WIN32)
auto space = utils::file::get_total_drive_space("/");
auto space2 = utils::file::get_total_drive_space(L"/");
#endif // !defined(_WIN32)
EXPECT_TRUE(space.has_value());
EXPECT_LT(0U, space.value());
EXPECT_TRUE(space2.has_value());
EXPECT_EQ(space.value(), space2.value());
}
TEST(utils_file, create_temp_name) {
{
auto temp = utils::file::create_temp_name("test_temp");
EXPECT_EQ(18U, temp.size());
auto temp2 = utils::file::create_temp_name("test_temp");
EXPECT_STRNE(temp.c_str(), temp2.c_str());
EXPECT_TRUE(utils::string::begins_with(temp, "test_temp_"));
}
{
auto temp = utils::file::create_temp_name(L"test_temp");
EXPECT_EQ(18U, temp.size());
auto temp2 = utils::file::create_temp_name(L"test_temp");
EXPECT_STRNE(temp.c_str(), temp2.c_str());
EXPECT_TRUE(utils::string::begins_with(temp, L"test_temp_"));
}
}
TEST(utils_file, get_total_drive_space_fails_for_bad_path) {
auto temp = utils::file::create_temp_name("total_drive_space_test");
auto space = utils::file::get_total_drive_space(temp);
EXPECT_FALSE(space.has_value());
}
TEST(utils_file, get_times) {
{
auto times = utils::file::get_times(__FILE__);
EXPECT_TRUE(times.has_value());
EXPECT_LT(0U, times->get(utils::file::time_type::accessed));
EXPECT_LT(0U, times->get(utils::file::time_type::created));
EXPECT_LT(0U, times->get(utils::file::time_type::modified));
EXPECT_LT(0U, times->get(utils::file::time_type::written));
}
{
auto times = utils::file::get_times(utils::string::from_utf8(__FILE__));
EXPECT_TRUE(times.has_value());
EXPECT_LT(0U, times->get(utils::file::time_type::accessed));
EXPECT_LT(0U, times->get(utils::file::time_type::created));
EXPECT_LT(0U, times->get(utils::file::time_type::modified));
EXPECT_LT(0U, times->get(utils::file::time_type::written));
}
}
TEST(utils_file, get_times_fails_if_not_found) {
auto temp = utils::path::combine(".", {"get_times_test"});
auto times = utils::file::get_times(temp);
EXPECT_FALSE(times.has_value());
}
TEST(utils_file, get_time) {}
TEST(utils_file, get_time_fails_if_not_found) {
auto temp = utils::path::combine(".", {"get_times_test"});
}
} // namespace repertory