Skip to content

Commit

Permalink
Address PR review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sploder12 committed Jan 17, 2025
1 parent 650830a commit 48de023
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/platform/platform_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@ bool mp::platform::Platform::set_permissions(const std::filesystem::path& path,
std::error_code ec{};
std::filesystem::permissions(path, permissions, ec);

return !static_cast<bool>(ec);
if (ec)
{
mpl::log(mpl::Level::warning,

Check warning on line 69 in src/platform/platform_unix.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/platform_unix.cpp#L69

Added line #L69 was not covered by tests
"permissions",
fmt::format("failed to set permissions for {}: {}", path.u8string(), ec.message()));

Check warning on line 71 in src/platform/platform_unix.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/platform_unix.cpp#L71

Added line #L71 was not covered by tests
}

return !ec;
}

bool mp::platform::Platform::symlink(const char* target, const char* link, bool is_dir) const
Expand Down
4 changes: 2 additions & 2 deletions tests/linux/test_platform_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ TEST_F(PlatformLinux, create_alias_script_overwrites)

EXPECT_CALL(*mock_utils, make_file_with_content(_, _, true)).Times(1);
EXPECT_CALL(*mock_file_ops, get_permissions(_))
.WillOnce(Return(std::filesystem::perms::owner_read | std::filesystem::perms::owner_write));
.WillOnce(Return(mp::fs::perms::owner_read | mp::fs::perms::owner_write));
EXPECT_CALL(*mock_platform, set_permissions(_, _)).WillOnce(Return(true));

// Calls the platform function directly since MP_PLATFORM is mocked.
Expand Down Expand Up @@ -673,7 +673,7 @@ TEST_F(PlatformLinux, create_alias_script_throws_if_cannot_set_permissions)

EXPECT_CALL(*mock_utils, make_file_with_content(_, _, true)).Times(1);
EXPECT_CALL(*mock_file_ops, get_permissions(_))
.WillOnce(Return(std::filesystem::perms::owner_read | std::filesystem::perms::owner_write));
.WillOnce(Return(mp::fs::perms::owner_read | mp::fs::perms::owner_write));
EXPECT_CALL(*mock_platform, set_permissions(_, _)).WillOnce(Return(false));

MP_EXPECT_THROW_THAT(
Expand Down

0 comments on commit 48de023

Please sign in to comment.