-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify usage of file helpers #566
Merged
TomasTurina
merged 18 commits into
main
from
enhancement/550-unify-usage-of-file-helpers
Feb 13, 2025
Merged
Unify usage of file helpers #566
TomasTurina
merged 18 commits into
main
from
enhancement/550-unify-usage-of-file-helpers
Feb 13, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 tasks
b8fe1c0
to
c1b3dde
Compare
4 tasks
a5480ee
to
dc7a627
Compare
TomasTurina
reviewed
Feb 7, 2025
TomasTurina
reviewed
Feb 7, 2025
jr0me
reviewed
Feb 10, 2025
jr0me
reviewed
Feb 10, 2025
jr0me
reviewed
Feb 10, 2025
jr0me
reviewed
Feb 10, 2025
jr0me
reviewed
Feb 10, 2025
src/common/data_provider/src/packages/packageLinuxParserRpm.hpp
Outdated
Show resolved
Hide resolved
jr0me
reviewed
Feb 10, 2025
jr0me
reviewed
Feb 10, 2025
src/common/data_provider/tests/sysInfoPackageLinuxParserRpm/CMakeLists.txt
Outdated
Show resolved
Hide resolved
jr0me
reviewed
Feb 10, 2025
5da3c52
to
5e24022
Compare
The functions is_regular_file and directory_iterator have been moved to the new library `file_handler`. Since the other functions in `fileHelper` were redundant, this file has been removed, and all its usages have been replaced with the new library. Additionally, the moved functions have been added to the. filesystem mock used in the centralized configuration tests.
The function is moved to the new file_handler, renamed to expand_absolute_path, all its usages are replaced, and associated tests are fixed.
The function is moved to the new file_handler, renamed to enumerate_dir, all its usages are replaced.
The class is created to host the method getRpmInfo. This way, it will be possible to mock the filesystem of file_handler and thus remove the use of existsRegular function.
This function has been removed, and its usage has been replaced by functions already present in the library. This results in simpler code. Additionally, the necessary changes have been made to ensure that the tests run successfully.
This class and its readLineByLinea method have been moved to the new library, and the necessary changes have been made to ensure that the tests run successfully.
These functions have been moved to the new FileIO class in file_handler. Their usages have been replaced, and new functions have been documented. Additionally, an interface has been added to allow mocking the functions in future tests.
The implementation and name of this method have been changed to return a vector instead of an iterator. This makes its use in tests and the way the method is mocked much simpler. Its usages have been replaced and tests fixed.
The remaining fileHelper files have been removed. The remaining tests for the expand_absolute_path function have been moved. A call to configure_target has been added in CMakeLists.txt file, which required some changes to avoid warnings and compilation errors.
5e24022
to
3c5b884
Compare
The enumerate_dir function has been removed and its usages replaced with list_directory. To do so, some checks have been added in the code and the format of the returned values has been changed.
Methods have been added to the ifile_io interface to allow testing of the FileIO class functions. A mock has been added within the test file for internal testing, and the MockFileIO class has been completed for other tests that require it as an external dependency.
Pure abstract base class was missing a = 0 in create_ifstream
1ca7dd8
to
1854779
Compare
This class member is added to avoid using std::filesystem in the class implementation.
26ee55f
to
0bc4293
Compare
3 tasks
jr0me
approved these changes
Feb 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Good job! |
TomasTurina
approved these changes
Feb 13, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Closes #550
The proposal is to unify the use of all functions related to files in a file_handler libray, where the implementation of filesystem-related functions is separated from IO operation.
Proposed Changes
File_helper is created, which is composed of the FilesystemWrapper and FileIO libraries. These contain functions that wrap standard functions and others that perform operations related to files and their directories.
In summary:
Results and Evidence
E2E tests
Inventory - Network
Inventory - RPM Package
Inventory - NPM Package
Inventory - PYPI Package
Inventory - Hardware
Inventory - Process Info
Unit tests
Filesystem tests
FileIO tests
Manual tests for macOS
Inventory - Hardware
Inventory - Package
Artifacts Affected
Executable files, all platforms.
Configuration Changes
None
Documentation Updates
None
Tests Introduced
Added:
Moved:
Fixed:
Review Checklist