-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Binary snapshots (in-memory) #610
Binary snapshots (in-memory) #610
Conversation
This is the somewhat simplified version of mitsuhiko#489 where we keep the full files in-memory during the assert and when reviewing.
…snapshots This merge is far from compiling. I just picked the side of each conflict that makes more sense to build upon.
…snapshots Still WIP like the previous merge.
This fixes the failing tests.
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.
It's in impressive effort! And thank you for redoing on top of the new master
.
It does add lots more data structures & some complications to the code. I'm going to think about how much we could simplify (I've already simplified the existing code somewhat..). If you have ideas, that would be great too.
FWIW I think the ontology is quite an interesting case — The proposed structure seems reasonable (as above I'd like to see if we can reduce the number of data structures a bit, but I don't think there are any easy large clean-ups) |
To sketch out what I think we need to do to merge:
|
Co-authored-by: Maximilian Roos <5635139+max-sixty@users.noreply.github.com>
Let's add a couple of examples to the docs and then hit the big button. Thank you very much for all your persistence here, I know it was a long road. It's a great feature for insta! |
The deleting of unreferenced snapshots does not work for binary snapshots yet. I'm working on fixing that now. |
Previously it only deleted the .snap file, but not the binary file next to it.
Now it works, but I'm not quite sure what the best error handling strategy there is. It needs to load the snapshot now to know whether it's binary and to get the extension. It still ignores errors when deleting the files like before. So I think it should probably also ignore errors when loading the snapshot and just skip it and maybe print a log message. |
The message "snapshots are matching" was previously printed when replacing a binary snapshot with an empty string text snapshot.
I meant to reply to this earlier but forgot: |
I've started adding a section for the website: https://github.com/mitsuhiko/insta-website/compare/main...lasernoises:insta-website:binary-snapshots?expand=1. I think I'll wait with opening a PR until this is merged. |
Yes v good point. Would be great to add the comment (but no need to slow down this PR ofc) |
@lasernoises anything else? Or we merge? :) |
I think from my point of view we can merge. |
🎉🎉🎉 Thank you so much for your patience and the many reviews/comments! |
Thank you!! |
The biggest difference to the previous attempt in #489 is that the snapshot contents are now kept in-memory instead of being written into a temporary file directly.
For
SnapshotContents
I decided to make it an enum with two variants like in the previous attempt. I first attempted to change it to three variants so it would also replace theSnapshotKind
enum but I realized that a lot of logic is still shared between inline and file text snapshots. That approach would definitely also work though and it's perhaps also a question of how much the logic between the two is expected to diverge in the future.In
runtime::assert_snapshot
I replaced the combination of therefval
andnew_snapshot_value
with an enum. In that case it is a three variant enum and someFrom
impls for two value tuples for the macros. Maybe it would be better to make it a two variant enum there too for consistency and keep theReferenceValue
enum for the text case. That might be a bit weird because both binary and non-inline text snapshot have a name and that would then be in two different enums.I should probably also add some tests in
cargo-insta
. I'll do that as soon as possible, but I need to figure out how the testing there works.