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.
- One for .ini file that does not exist - Another for .ini file with wrong format
CCPCookies
left a comment
There was a problem hiding this comment.
I love how many tests there are and the descriptions are super useful.
Some more comments.
I also think we should take advantage of your knowledge of the filter files and make add a file spec to the documentaiton for the filter ini files.
Here you can see resourceGroup file format https://carbonengine.github.io/resources/DesignDocuments/resourceGroupFileFormat.html
tests/src/CliTestFixture.cpp
Outdated
| std::cout << "---------------------------" << std::endl; | ||
|
|
||
| TinyProcessLib::Process process1a( | ||
| arguments, workingDirectory, |
There was a problem hiding this comment.
Why do you need to change the working directory?
There was a problem hiding this comment.
Because the working directory is in the cmake made location for the generated exe where the tests are running.
I need the CLI to know what the working directory is in order to be able to resolve the relative contents of the .ini filter files correctly (as the files it wants to apply filter rules on are all relative to the TEST_DATA_BASE_PATH).
If I don't do that, then when it tries to resolve the relative paths from the .ini files it does so from the WRONG start position (i.e. not the TEST_DATA_BASE_PATH, but from the folder where the resources-cli.exe is located in CARBON_RESOURCES_CLI_EXE_FULLPATH)
This is also one of the reasons why I want to do the comparison on actual absolute lexical paths (see my earlier comment on: #16 (comment))
There was a problem hiding this comment.
Wouldn't this base path be better passed in as an argument rather than relying on working directory?
There was a problem hiding this comment.
Base path is being passed in now as an argument via the CLI (--filter-file-basepath)
The signature for the RunCLI() function takes in an optional parameter to set the working directory.
None of the tests however call it with an overriding working directory parameter.
All of them just use the default ("" empty string).
tests/src/ResourcesCliTest.cpp
Outdated
| arguments.push_back( "--output-file" ); | ||
| arguments.push_back( outputFilePath.lexically_normal().string() ); | ||
|
|
||
| int res = RunCli( arguments, output, errorOutput, TEST_DATA_BASE_PATH ); |
There was a problem hiding this comment.
The working directory doesn't need to be changed, there is a helper to resolve paths that the other tests use.
e.g.
std::filesystem::path inputDirectory = GetTestFileFileAbsolutePath( "CreateResourceFiles/ResourceFiles" );
There was a problem hiding this comment.
See my other answers on the issue.
There was a problem hiding this comment.
Working directory is now not being passed in as a parameter to the RunCli() function.
The filter file basepath can however be set as a command line argument "--filter-file-basepath" which gets passed down as an argument to the tools library.
- Updated tests accordingly.
…lResolvedPathMap() function.
- Change the FilePathMatchesIncludeFilterRules() function to use relative paths for comparison on the incoming file vs the resolved path from the filter .ini file. - Make sure that any path sent into the function or resolved from a .ini file are also force converted to their relative version, (from std::filesystem::current_path)
- Using relative paths for comparison can fail on Windows for a valid prefixmap entry of e.g. "rootRes:." where it has trouble interpreting e.g. a path of "./SomeFolder/*"
- Make sure to reset inFilePathAbs and resolvedPathAbs path variables to their normalized versions
- This should work for tests running on Windows ("gold" file comparison)
- Hope is that the macOS "gold" files will work as well (else re-run and generate those on a macOS machine and submit those)
- It is no longer needed after reliance on current working directory was removed.
…into filter-changes Merge in correct macOS output files from upstream, and add a test for the new filter-changes functionality.
# Conflicts: # cli/src/CreateResourceGroupCliOperation.cpp # src/ResourceGroupImpl.cpp
CCPCookies
left a comment
There was a problem hiding this comment.
I left some comments but didn't finish completely.
I tried a build and was confused why my ini file was not being found. I pulled the code down to get a better idea. There are some issues with path handling still, confusion with relative/absolute path things.
I've managed to make a few local changes to sort most of it, I'll continue when I'm back on Thurs and push to this branch.
|
|
||
| AddArgument( m_createResourceGroupExportResourcesDestinationPathId, "Represents the base path where the exported resources will be saved. Requires --export-resources", false, false, defaultImportParams.exportResourcesDestinationSettings.basePath.string() ); | ||
|
|
||
| AddArgument( m_createResourceGroupIniFilterFilesArgumentId, "Path to INI file(s) for resource filtering.", false, true, "" ); |
There was a problem hiding this comment.
Should remove the (s) as it suggests this accepts a list.
The argument only accepts one path.
The append bool here being true results in docs added so user knows many can be supplied.
Path to INI file for resource filtering. [Accepts multiple] [default: ""]
There was a problem hiding this comment.
Fixed, made it singular
|
|
||
| set (VCPKG_USE_HOST_TOOLS ON CACHE STRING "") | ||
| set (CMAKE_CXX_STANDARD 20 CACHE STRING "") | ||
| set (CMAKE_CXX_STANDARD 17 CACHE STRING "") |
There was a problem hiding this comment.
What's the story here?
There was a problem hiding this comment.
When Toebeans applied the Template project changes into carbonengine/resources, he changed the macOS Arm config to use C++ 20 on his local and checked it it (forgot to revert it back to 17).
Windows and macOS x64 are already using C++ 17.
When we upgrade to a newer version we'll do so on all flavors at the same time.
| // Check if the file, i.e. entry.path() should be included or excluded based on filtering rules | ||
| if( !resourceFilter.FilePathMatchesIncludeFilterRules( entry.path() ) ) | ||
| { | ||
| continue; |
There was a problem hiding this comment.
Could add in a status update here.
fileProcessingInnerStatusSettings.Update( CarbonResources::StatusProgressType::UNBOUNDED, 0, 0, "Skipping file as it doesn't match filters: " + entry.path().string() );
Probably be very useful later.
Also, if all files are skipped then it will be a long time until any status updates were hit, might look like it's hanging.
There was a problem hiding this comment.
Add fileProcessing update message for skipped filter files
- Logged out message for every 25th file skipped.
- Done to limit the "skip spam", but enough to see that there is progress.
tests/src/CliTestFixture.cpp
Outdated
| int CliTestFixture::RunCli( std::vector<std::string>& arguments, | ||
| std::string* standardOutput /* = nullptr */, | ||
| std::string* errorOutput /* = nullptr */, | ||
| const std::string& workingDirectory /* = "" (empty = do not alter it) */ ) |
There was a problem hiding this comment.
working directory change here needs removing.
This way we stop others maybe creating changes that rely on working directory
There was a problem hiding this comment.
WorkingDirectory default parameter removed from RunCli() function
tests/src/CliTestFixture.cpp
Outdated
| // Only populate the output and errorOutput if the caller provided non-nullptr for them, otherwise discard them | ||
| TinyProcessLib::Process process1a( | ||
| arguments, | ||
| workingDirectory, |
There was a problem hiding this comment.
workingDirectory doesn't need setting same reasoning as the previous one
There was a problem hiding this comment.
WorkingDirectory default parameter removed from RunCli() function
tests/src/CliTestFixture.h
Outdated
| { | ||
|
|
||
| int RunCli( std::vector<std::string>& arguments, std::string& output ); | ||
| int RunCli( std::vector<std::string>& arguments, std::string* standardOutput = nullptr, std::string* errorOutput = nullptr, const std::string& workingDirectory = "" ); |
There was a problem hiding this comment.
working directory setting removal
There was a problem hiding this comment.
WorkingDirectory default parameter removed from RunCli() function
tests/src/ResourcesCliTest.cpp
Outdated
| std::string output; | ||
| std::string errorOutput; | ||
| std::vector<std::string> arguments; | ||
| std::filesystem::path inputDirectoryPath = GetTestFileFileAbsolutePath( "" ); // The base testData directory |
There was a problem hiding this comment.
Will this give TEST_DATA_BASE_PATH?
Could use that instead
There was a problem hiding this comment.
Yes, changed it.
| m_createResourceGroupExportResourcesDestinationPathId( "--export-resources-destination-path" ) | ||
| m_createResourceGroupExportResourcesDestinationPathId( "--export-resources-destination-path" ), | ||
| m_createResourceGroupIniFilterFilesArgumentId( "--filter-file" ), | ||
| m_createResourceGroupIniFilterFilesBasePathArgumentId( "--filter-file-basepath" ) |
There was a problem hiding this comment.
The argument name is misleading. This isn't the base path of the filter file.
This is the base path from where the prefix maps are based
There was a problem hiding this comment.
Fixed, removed abiguity by renaming it --filter-file-prefixmap-basepath
src/ResourceGroupImpl.cpp
Outdated
| { | ||
| try | ||
| { | ||
| resourceFilter.Initialize( params.resourceFilterIniFiles, params.resourceFilterIniFilesBaseDirectory, params.directory ); |
There was a problem hiding this comment.
Why would the filter file require the directory passed in?
I think there is still some confusion with paths happening here
There was a problem hiding this comment.
This was done in order to handle cases IF incoming files (the ones being checked against the filter rules) were sent in with a relative path (instead of the expected absolute path).
In that case, the idea was to try and resolve that relative path based on the params.directory parameter.
Currently that (params.directory) is absolute, making all of the input files absolute, therefore making this redundant.
Will simplify and remove this.
- Rename --filter-file-basepath to --filter-file-prefixmap-basepath - Fix plural to singular typo.
Remove ambiguity of the intention of those: - resourceFilterIniFilesPrefixmapBaseDirectory - m_createResourceGroupIniFilterFilesPrefixmapBasePathArgumentId
- Only send in the prefixmapAbsoluteBasePath along with the vector of .ini files.
- Logged out message for every 25th file skipped. - Done to limit the "skip spam", but enough to see that there is progress.
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: