-
Notifications
You must be signed in to change notification settings - Fork 3
Filter support added #16
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
base: main
Are you sure you want to change the base?
Conversation
Make use of existing filePath test functions
Next step, add missing tests.
Also fixed clang-tidy suggestions
- Do some function name changes to reduce stuttering.
- It worked (wrong) on Windows - Failed on macOS
- Caused a warning as error on macOS - Wasn't being used so safe to remove.
- Fails to build on macOS (incorrect casing, warning as errors)
- Change includes both tools and tests
…ePaths - Temporarily adding debug information to test in order to see why it is failing for macOS in TeamCity
Changed tests: - ResourceFilter_Load_validSimpleExample1_ini_usingRelativePaths - ResourceFilter_Load_validSimpleExample1_ini_usingAbsolutePaths - ResourceFilter_Load_validComplexExample1_ini_usingRelativePaths - ResourceFilter_Load2iniFiles_validComplexExample1_and_validSimpleExample1 New tests: - ResourceFilter_Load_validComplexExample1_ini_usingAbsolutePaths
- To be removed later
- Done to generate the missing "gold" compare files on macOS
CCPCookies
left a comment
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.
Looks nice, left some comments.
Not managed to go through it completely yet but just wanted to submit this for now as I ran out of day.
| } No newline at end of file | ||
| } | ||
|
|
||
| void CliTestFixture::CleanupTestOutputFiles( const std::vector<std::filesystem::path>& filesToRemove ) |
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.
Should probably be called just RemoveFiles as it could be called with any file, not just test output files.
| #include <FilterResourceFile.h> | ||
| #include <ResourceFilter.h> | ||
|
|
||
| TEST_F( ResourceFilterTest, Example1IniParsing ) |
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.
Test name is not descriptive; from test name it should be obvious what the test is testing.
|
|
||
| // ----------------------------------------- | ||
|
|
||
| TEST_F( ResourceFilterTest, FilterResourceFilter_OnlyIncludeFilter ) |
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.
From title I'm not sure what this test is supposed to do.
| EXPECT_TRUE( excludes.empty() ); | ||
| } | ||
|
|
||
| TEST_F( ResourceFilterTest, FilterResourceFilter_OnlyExcludeFilter_Toplevel ) |
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.
Again, filter name is confusing.
| EXPECT_EQ( includes[0], "*" ); // Wild-card added when no include filter specified for TOP-LEVEL filter | ||
| } | ||
|
|
||
| TEST_F( ResourceFilterTest, FilterResourceFilter_OnlyExcludeFilter_Inline ) |
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.
Same as above
|
|
||
| #include <string> | ||
| #include <map> | ||
| #include <vector> |
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.
Unused?
| #define FILTERNAMEDSECTION_H | ||
|
|
||
| #include <string> | ||
| #include <vector> |
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.
Unused?
| // Resolved PathMap for all named sections defined in a resource .ini file | ||
| std::map<std::string, FilterResourceFilter> m_iniFileResolvedPathMap; | ||
|
|
||
| void ParseIniFile(); |
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.
Not a fan of having a function below members.
Personally, I like to have two private: areas to split private functions and private members but I think our coding standards says not to do this.
|
|
||
| bool HasFilters() const | ||
| { | ||
| return !m_filterFiles.empty(); |
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.
Why inline this?
| FilterResourceFile::FilterResourceFile( const std::filesystem::path& iniFilePath ) : | ||
| m_iniFilePath( iniFilePath ) | ||
| { | ||
| m_iniFileResolvedPathMap.clear(); |
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.
Wont this always be clear at this point anyway?
- Done to try to fix C++20 arm64 osx triplet cmake error for inih
- Use string() instead of generic_string()
- Also change Filter cli tests to set an override
CCPCookies
left a comment
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.
Likely lots of stuff due to this being a draft.
Made a first pass of it now.
| { | ||
|
|
||
| FilterResourceFilter::FilterResourceFilter( const std::string& rawFilter, bool isToplevelFilter /* = false */ ) : | ||
| m_rawFilter( rawFilter ), |
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.
std::string being passed by const ref here, fine with that.
Previously in other areas std::move was used which I am also fine with.
Not huge deal but a bit strange to have two styles in the changes.
| @@ -0,0 +1,20 @@ | |||
| // Copyright © 2025 CCP ehf. | |||
|
|
|||
| #include <stdexcept> | |||
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.
Is this used?
| m_respaths( respaths, parentPrefixMap, m_filter ), | ||
| m_resfile( resfile.empty() ? std::nullopt : std::make_optional<FilterResourcePathFile>( resfile, parentPrefixMap, m_filter ) ) | ||
| { | ||
| m_resolvedCombinedPathMap.clear(); |
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.
Isn't this already clear?
| } | ||
|
|
||
| // Return empty map if no resfile present | ||
| static const std::map<std::string, FilterResourceFilter> emptyResfileMap; |
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.
This feels odd.Assuming this was a way for this function to sort of continue on fail.
Is it important to hide this failure from the caller?
-
Have it return a bool and take in a ref to the map which gets populated on success. Though probably requires a copy.
-
Perhaps it doesn't make full sense to have a function to GetResourceResfileMap from a named section? Perhaps caller should access resfile externally to this and so this function no longer is a wrapper around this data? (Hard to fully grasp from GitHub Diff sorry)
|
|
||
| FilterPrefixMap::FilterPrefixMap( const std::string& rawPrefixMap ) | ||
| { | ||
| m_prefixMapEntries.clear(); |
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.
Again, isn't this clear already?
| { | ||
| // Replace ... with a unique token | ||
| std::string pat = pattern; | ||
| std::string token = "\x01"; |
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.
Needs to follow our constants coding guidelines
| include/RollingChecksum.h | ||
| include/ScopedFile.h | ||
| include/StatusCallback.h | ||
| include/FilterResourceFile.h |
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.
The list was alphabetical :D but this can go down as a nitpick :D
| src/ScopedFile.cpp | ||
| src/Patching.cpp | ||
| src/RollingChecksum.cpp | ||
| src/FilterResourceFile.cpp |
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.
Same as above :D
| vcpkg_registry_cache/ | ||
|
|
||
| ### Ignored Test Run Files ### | ||
| /tests/testData/IgnoredTestOutputFiles/ |
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.
? There are now output files generated in the repo during test?
| include(cmake/CcpBuildConfigurations.cmake) | ||
|
|
||
| find_package(yaml-cpp CONFIG REQUIRED) | ||
| find_package(unofficial-inih CONFIG REQUIRED) |
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.
What's with the unofficial name? Is it that we use features that are not strictly supported through just inih or something?
Allow filtering of included resource files based on rules defined in one or more supplied filter.ini files.
Same changes as in PR/14 (done to try to trigger TC build on new project after latest changes from template project were added)
The change contains: