-
Notifications
You must be signed in to change notification settings - Fork 52
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
Impossible to use UNC filename in TemplatedCustomNamer [removeRedundantDirectorySeparators()
breaks use of UNC paths, which contain \\
]
#225
Comments
Hi,
Please give a source code sample that we can use to test the problem. And what backslash are you referring to? I only see forward slashes. |
A snippet from our main.cpp: ::ApprovalTests::initializeApprovalTestsForGoogleTests();
APPROVAL_TESTS_REGISTER_MAIN_DIRECTORY
auto defaultNamer = ::ApprovalTests::Approvals::useAsDefaultNamer([]()
{
auto approvalFilesBaseDir = kernel::utilities::Environment::GetEnvironmentVariable(L"KERNEL_TEST_APPROVAL_FILES_BASE_DIR");
return std::make_shared<ApprovalTests::TemplatedCustomNamer>(
kernel::utilities::Convert::WStringToUTF8String(approvalFilesBaseDir) +
"/{RelativeTestSourceDirectory}/{TestFileName}.{TestCaseName}.{ApprovedOrReceived}.{FileExtension}"
);
}); In the environment variable I tried using something like In both cases the doubled (back)slash is eliminated in "removeRedundantDirectorySeparators". Looks like using a UNC path is currently impossible. |
Thanks. In case it helps in future, this is how to format code so it's readable here:
I've made that edit in your post above. |
removeRedundantDirectorySeparators()
breaks use of UNC paths, which contain \\
]
Thank you for the code.
Yes, I'm sure that's the problem. I see that we have no explicit tests for that function. The fix would be be to:
|
Likely something like this: TEST_CASE("Path retains initial slashes in UNC paths")
{
const std::string start = R"(\\a\b\c.txt)";
Path path = Path(start);
CHECK("//a/b/c.txt" == path.toString("/"));
CHECK("\\\\a\\b\\c.txt" == path.toString("\\"));
} |
If the TemplatesCustomNamer is instructed to create a filename starting with "//SomeHost/SomeDir..", the double (back)slash is removed in "removeRedundantDirectorySeparators", which makes it impossible to use UNC paths.
The text was updated successfully, but these errors were encountered: