Closed p-podsiadly closed 3 years ago
Thanks, I don't think we thought about the use of _
resulting in similar tests giving non-unique file names.
I'd be super nervous about changing the naming convention, though, as it could break the results of existing tests for existing users...
Based on this answer, I'd hesitate to use &
in a file name:
https://superuser.com/a/748264
[]()^ #%&!@:+={}'~ and [`] all have special meanings in many shells, and are annoying to work around, and so should be avoided.
I know it's not a totally general solution, but it's possible to a register custom namer: https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/Namers.md#registering-a-custom-namer
For clarity, I do agree we should look at this - I’m just not sure what approach to take.
An alternative idea would be for us to keep track of all the approval filenames used in a session, and print out a warning if a duplicate filename is encountered.
This would also help users who have two Approvals::verify() calls in the same scope...
It doesn't solve the problem in this ticket, but it does help users track down the cause of the error.
We could even record both the original test name, and the generated file name - so if there are duplicated filenames, we could print out all the matching test names.
Thank you for pointing out this issue.
We have added a customization point that will allow users to handle this in the method of their choice. Here are the docs Converting Test Names to Valid FileNames
Background: I have two test cases:
scale > 1
andscale < 1
. Files generated for both test cases have the same file name:"scale___1.received.png"
(both<
and>
are replaced with underscore).This could be improved. For example, instead of replacing each forbidden character with underscore,
ApprovalTestNamer
could use XML/HTML character references, so that files in the above example would be namedscale_>_1.received.png
andscale_<_1.received.png
.