updated build system
This commit is contained in:
@ -29,19 +29,16 @@ static std::vector<std::unique_ptr<repertory::utils::file::i_fs_item>>
|
||||
|
||||
static void delete_generated_files() {
|
||||
repertory::recur_mutex_lock lock{file_mtx};
|
||||
std::optional<std::string> parent_path;
|
||||
std::map<std::string, bool> parent_paths;
|
||||
for (auto &&path : generated_files) {
|
||||
if (parent_path->empty()) {
|
||||
parent_path = repertory::utils::path::get_parent_path(path->get_path());
|
||||
}
|
||||
|
||||
[[maybe_unused]] auto removed = path->remove();
|
||||
parent_paths[repertory::utils::path::get_parent_path(path->get_path())] =
|
||||
true;
|
||||
}
|
||||
generated_files.clear();
|
||||
|
||||
if (parent_path.has_value()) {
|
||||
for (auto &&entry : parent_paths) {
|
||||
EXPECT_TRUE(
|
||||
repertory::utils::file::directory(*parent_path).remove_recursively());
|
||||
repertory::utils::file::directory(entry.first).remove_recursively());
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +46,9 @@ struct file_deleter final {
|
||||
~file_deleter() { delete_generated_files(); }
|
||||
};
|
||||
|
||||
static auto deleter{std::make_unique<file_deleter>()};
|
||||
static auto deleter{
|
||||
std::make_unique<file_deleter>(),
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace repertory::test {
|
||||
|
@ -37,7 +37,11 @@ TEST(utils_error, check_default_exception_handler) {
|
||||
}
|
||||
|
||||
TEST(utils_error, can_override_exception_handler) {
|
||||
struct my_exc_handler : public utils::error::i_exception_handler {
|
||||
struct my_exc_handler final : public utils::error::i_exception_handler {
|
||||
MOCK_METHOD(void, handle_error,
|
||||
(std::string_view function_name, std::string_view msg),
|
||||
(const, override));
|
||||
|
||||
MOCK_METHOD(void, handle_exception, (std::string_view function_name),
|
||||
(const, override));
|
||||
|
||||
@ -49,6 +53,9 @@ TEST(utils_error, can_override_exception_handler) {
|
||||
my_exc_handler handler{};
|
||||
utils::error::set_exception_handler(&handler);
|
||||
|
||||
EXPECT_CALL(handler, handle_error("test_func", "error")).WillOnce(Return());
|
||||
utils::error::handle_error("test_func", "error");
|
||||
|
||||
EXPECT_CALL(handler, handle_exception("test_func")).WillOnce(Return());
|
||||
utils::error::handle_exception("test_func");
|
||||
|
||||
|
@ -26,7 +26,7 @@ static constexpr const auto file_type_count{1U};
|
||||
}
|
||||
|
||||
namespace repertory {
|
||||
TEST(utils_file, can_create_file) {
|
||||
TEST(utils_file, can_create_and_remove_file) {
|
||||
for (auto idx = 0U; idx < file_type_count; ++idx) {
|
||||
auto path = test::generate_test_file_name("utils_file");
|
||||
EXPECT_FALSE(utils::file::file(path).exists() ||
|
||||
@ -37,6 +37,12 @@ TEST(utils_file, can_create_file) {
|
||||
EXPECT_TRUE(*file);
|
||||
|
||||
EXPECT_TRUE(utils::file::file(path).exists());
|
||||
EXPECT_TRUE(file->exists());
|
||||
|
||||
EXPECT_TRUE(file->remove());
|
||||
|
||||
EXPECT_FALSE(utils::file::file(path).exists());
|
||||
EXPECT_FALSE(file->exists());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user