Skip to content
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

Document snapshot-testing in Marker's codebase #202

Open
xFrednet opened this issue Jul 26, 2023 · 1 comment
Open

Document snapshot-testing in Marker's codebase #202

xFrednet opened this issue Jul 26, 2023 · 1 comment
Labels
A-infra Area: Infrastructure and CI magic :sparkles: C-documentation Category: Improvements or additions to documentation

Comments

@xFrednet
Copy link
Member

Marker has a few tests, that check the size of structs. @Veetaha suggested to potentially use snapshot-testing to allow automatic updates of these tests:

I recommend you to use a snapshot-testing library.
I've been using expect-test, which is a suprisingly low-overhead crate for snapshot testing.

This way you can capture all the data about the types and their sizes in a string snapshot (inline our out-of-line in a separate file) and re-generate it if something changes with UPDATE_EXPECT=1 cargo test, which means maintaining tests becomes almost a zero-effort task, because they rewrite themselves, and you just review the diff.

This testing library was originally developed for use in rust-analyzer by @matklad and I've been using it in production successfuly so far. The one thing is that the library is barebones, and requires some small amount of batteries (like I added in my repo here) to make JSON snapshots and auto-format snapshots such that they don't exceed 80 lines in the editor

Source: #196 (comment)

@xFrednet xFrednet added E-help-wanted Participation: Issues with some complexity and where help would be highly appreciated A-infra Area: Infrastructure and CI magic :sparkles: labels Jul 26, 2023
@xFrednet
Copy link
Member Author

xFrednet commented Sep 4, 2023

Support has been implemented in #233, now it only needs to be documented, or at least linked to in our docs, than we can close this issue :)

@xFrednet xFrednet added C-documentation Category: Improvements or additions to documentation and removed E-help-wanted Participation: Issues with some complexity and where help would be highly appreciated labels Sep 4, 2023
@xFrednet xFrednet changed the title Investigate using snapshot-testing Document snapshot-testing in Marker's codebase Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-infra Area: Infrastructure and CI magic :sparkles: C-documentation Category: Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant