Skip to content

test: Add some snapshot tests for linker-diff#2018

Merged
davidlattimore merged 1 commit into
mainfrom
push-uqvsrlwvxkpq
Jun 12, 2026
Merged

test: Add some snapshot tests for linker-diff#2018
davidlattimore merged 1 commit into
mainfrom
push-uqvsrlwvxkpq

Conversation

@davidlattimore

Copy link
Copy Markdown
Member

No description provided.

@davidlattimore davidlattimore force-pushed the push-uqvsrlwvxkpq branch 2 times, most recently from ae57560 to 0fd0ea7 Compare June 6, 2026 05:50
@marxin

marxin commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

@davidlattimore have you consider using the insta crate for the actual comparison against the existing snapshots? I've had some experience with that crate and enjoyed the diffs and ability to quickly update the expected snapshots once an expected change lands.

@davidlattimore

Copy link
Copy Markdown
Member Author

I did look briefly at insta when I started this, but it seems to be aimed at rust tests where each snapshot file corresponds to a different macro invocation in the test. Our scenario is somewhat different in that our tests are generated dynamically at runtime by finding files on the filesystem. It's not obvious to me how we'd hook into insta. Even if we could, it's not clear what we'd get from doing so. The code to update the expected outputs is only a few lines. It sounds like they've got some neat tools for viewing the diffs of what changed, but git/jj are also really good at viewing diffs of what changed. Updating expected outputs is currently just a matter of running the tests with WILD_SNAPSHOT=update. I can definitely see the benefit of insta if you've got lots of #[test]-style rust tests with assertions in them that are subject to change.

@marxin marxin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, thanks for the explanation.

@mati865 mati865 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did look briefly at insta when I started this, but it seems to be aimed at rust tests where each snapshot file corresponds to a different macro invocation in the test. Our scenario is somewhat different in that our tests are generated dynamically at runtime by finding files on the filesystem. It's not obvious to me how we'd hook into insta. Even if we could, it's not clear what we'd get from doing so. The code to update the expected outputs is only a few lines. It sounds like they've got some neat tools for viewing the diffs of what changed, but git/jj are also really good at viewing diffs of what changed. Updating expected outputs is currently just a matter of running the tests with WILD_SNAPSHOT=update. I can definitely see the benefit of insta if you've got lots of #[test]-style rust tests with assertions in them that are subject to change.

This would be more like a case for https://docs.rs/trycmd/latest/trycmd/ but that would require some changes to how we test. Given the cost of creating the snapshotting infra is already paid (this PR) and it integrates nicely with existing tests, current approach looks good.

git/jj are also really good at viewing diffs of what changed

I'm not sure about git. Last time I used it without any third-party tools for viewing diffs of snapshots it wasn't that good. On the other hand, jj is really nice.
Perhaps git experience can be improved with highlighters like https://github.com/dandavison/delta but that's a matter of personal preference.

@marxin

marxin commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Perhaps git experience can be improved with highlighters like https://github.com/dandavison/delta but that's a matter of personal preference.

Oh, what an interesting crate - have you been using it on a daily basis @mati865?

@mati865

mati865 commented Jun 7, 2026

Copy link
Copy Markdown
Member

Oh, what an interesting crate - have you been using it on a daily basis @mati865?

I had used to, but like two years ago I've made the switch to jj. Since then, I didn't feel the need to use tools like that.

I found delta diffs better for reading but annoying for copy pasting. Arguably I should have made an alias to easily disable it, but it wasn't annoying enough to bother.

@davidlattimore davidlattimore merged commit 41907c8 into main Jun 12, 2026
25 checks passed
@davidlattimore davidlattimore deleted the push-uqvsrlwvxkpq branch June 12, 2026 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants