-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
Support Helm unittest snapshots #19264
Support Helm unittest snapshots #19264
Conversation
Interesting problem! Re "A modification of the test goal that collects the snapshot files from the workspace" - could this be accomplished via dep inference, with no modification of the test goal? The snapshot files are test inputs, so they are resource/file deps, and we could infer them by the presence of the snapshot dir, no? |
Would that mean that Pants would be able to see if the Or the user would still need to add those to the |
Ideally the former. The user would need to add a |
Huh, I was just thinking about snapshot testing (in Python, specifically) over the last few days, this is convenient! Thanks for starting it. For Python (and other languages like JS) with a less strong convention, I was wondering about having an option like: [pytest]
snapshot_globs = [
"./__snapshots__/{test_file_name}.*", # substitutable templates
"./__snapshots__/{test_file_name}/**/*"
] (or maybe fields on the targets, in a way that's This could hook into tailoring, dependency inference and a For instance, if I had the config above, and a test
Some potential enhancements beyond that basic functionality might be:
Some of this feels very specific to snapshot testing, and there might be a more general framing (e.g. #18235 is related)... but that's probably okay? |
In general I like the idea of having the snapshots referenced from a But I see two points of contention here in where we have at least two different approaches: 1) How to provide those targets to Pants and 2) The generation of the snapshot data. Providing the targetsConsidering how little standardization on the topic there is across languages (or even across frameworks/tooling of the same language). I see providing the snapshot globs as a field in the test targets as a fantastic option. Gives the possibility of having a default value that then can be overridden in different areas of the repo using However this approach looks to me to be at odds with the generation of the Generating the snapshot dataIn this implementation in the Helm backend and I'm making use of the The reason I see that potential problem is that subsystem settings can be input via command line or In other conversations it was mentioned to use The third option is what is discussed in #18235. A goal like that one could pass the appropriate args to the underlying tooling and it feels also intentional from the user perspective. However I don't believe that this is something that has been agreed on yet. |
debb266
to
a4fa316
Compare
Re the "providing the targets" part: As you say - we already solve this today for "manual snapshots" that don't use any snapshotting framework. These are just data files that we manually write a resources() target and dependency for... I think we're better off leveraging that mechanism. BUT: That said - if we need global/target config to specify a snapshot dir for generating the data, then we might as well leverage that for the first part as well. I do think a |
It makes sense to me to leverage the usage of Made an initial implementation for a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how this turned out! I have a bunch of suggestions and nits for phrasing of docs, and some questions.
Co-authored-by: Benjy Weinberger <benjyw@gmail.com>
Co-authored-by: Benjy Weinberger <benjyw@gmail.com>
Co-authored-by: Benjy Weinberger <benjyw@gmail.com>
Co-authored-by: Benjy Weinberger <benjyw@gmail.com>
Co-authored-by: Benjy Weinberger <benjyw@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I guess we should support generate-snapshots
for Python too now... :)
@tobni for JavaScript snapshot testing |
Requesting feedback for #16532 and #11622.
The solution here is ad-hoc and specific for Helm. I'm unfamiliar with
pytest-snapshot
and thepytest
implementation is more complex. This could however be broken down into two rules (as I think is one of the suggestions in #11622):run
goal implementation that only generates the snapshot files.test
goal that collects the snapshot files from the workspace (relative to the test files being run).In Helm unittest this is somewhat easy as the snapshot resulting folder is hardcoded and can't be changed by the end user. However in Python world it seems that user could decide to use a different one, so a way of providing that info to Pants would be required.
EDIT: Closes #16532 providing an implementation in the Helm backend and a new core goal to keep the snapshots updated.