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.
- Adding 2 more tests as well.
- 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: ""]
|
|
||
| AddArgument( m_createResourceGroupIniFilterFilesArgumentId, "Path to INI file(s) for resource filtering.", false, true, "" ); | ||
|
|
||
| AddArgument( m_createResourceGroupIniFilterFilesBasePathArgumentId, "Base directory for resolving relative paths contained within filter INI file(s).", false, false, "" ); |
|
|
||
| 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?
| // 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.
| 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
| // 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
| { | ||
|
|
||
| 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
| 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
| 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
| { | ||
| 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
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: