-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Suggestion: Templated snapshot file paths #647
Comments
This sounds great! Couple of small questions, no need to answer them all before adding some code. (If we're confident it's extensible, we could add something quite small to the repo and then gradually expand...)
|
A bunch of answers/comments to/on your questions.
I envisioned templating the whole path and file name. For example
I would allow relative paths (no absolute ones) without any path traversals (
Yes, that makes sense. I wasn't sure what the exact status of the config file is, but I can see that we want to make it a first class citizen. I can imagine it might be quite hard to make it accessible in all assertions in an efficient way.
Actually, good question. I would say we always add the extension ( If we want to enable customizing it, Happy to hear your opinions on it.
Yes, makes sense. I would also argue that the simple syntax should be sufficient to start with. |
That all sounds great! Very much agree with your points. Re the root path — I do think we want to be able to write a template that gives the current behavior. The current behavior is FWIW we already have some support for custom extensions, and I've improved the support in 1.41. But ideally we can merge parts of the broader features without dealing with all possible issues, and extensions seem particularly minor. Would you want to have a swing at an initial version of this, to start? |
True, I didn't think about that, so good catch.
What exactly do you mean by that? Maybe a better solution might look like this:
Yes, we can delay this feature/discussion. It would however be nice if you could bring me up to speed on the current situation. I haven't looked into custom extensions yet.
Sure thing, I can start cooking up some stuff. Once I have some code ready, I will open a PR in the next few hours/days. |
Yes this sort of thing sounds good! And we could have |
This is a field on Line 65 in ee829d8
--extensions to cargo-insta: Lines 93 to 95 in 53dc3de
|
This came up in #456 regarding #377.
I suggest supporting templated snapshot file paths. The user has access to various variables to construct the final path. The exact variables (and their names) will be discussed in this issue.
In #456 I suggested the following ones:
crate
,module
,test_function_name
,suffix
, andinput_file
(for glob tests). To get the discussion going, I will lay out a bunch of details for the variables I initially suggested.crate
variable will resolve to the crate the test is part of.module
variable will resolve to the module the test is defined in. This variable will contain nested modules in a normalized form. For example for unit tests defined infoo::bar::test
the value will befoo_bar_test
.test_function_name
will resolve to the test function name. One thing I don't know: How does this behave for integration tests? Or is this only useful for unit tests?input_file
variable will resolve to the input file used inglob!
tests.suffix
(andprefix
) variables will be defined inSettings
. If not defined, they will either produce an empty value or error out when used in the templated file name.Additionally, we need to decide where and how to define the file name template. One obvious place is the
Settings
struct. Also, we need to decide the templating syntax, for example using{ var }
or{{ var }}
.I'm happy to hear feedback and I'm also happy to implement this once we nailed down all parts of this suggestion.
The text was updated successfully, but these errors were encountered: