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

test: Remove orphaned snapshots #64

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

stevenhuyn
Copy link
Contributor

This PR will now make any invocation of cargo test remove any snapshots with no corresponding test file.

We have moved the vine/fail tests to its own folder vine_fail

Closes #49

@stevenhuyn stevenhuyn marked this pull request as ready for review October 22, 2024 07:01
@stevenhuyn
Copy link
Contributor Author

Proof of it working on these 2 commits:
image

let mut orphans = false;
for entry in entries {
let Ok(entry) = entry else {
continue;
Copy link
Member

Choose a reason for hiding this comment

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

if you remove the semicolon here (and on the other continues), rustfmt should collapse these to a single line, which I think looks a bit nicer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

very neat


let file_name = file_name_str.to_owned();
if !names.contains(&file_name) {
orphans = true;
Copy link
Member

Choose a reason for hiding this comment

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

When there are orphaned snapshots, instead of always deleting the files and always failing, can you branch on should_write_snapshot() and either delete the snapshots and succeed, or fail and leave the snapshots be?

remove_orphan_snapshots("tests/snaps/vine", &vine_tests);
});
t.test("vine_fail", move || {
remove_orphan_snapshots("tests/snaps/vine_fail", &vine_fail_tests);
Copy link
Member

Choose a reason for hiding this comment

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

can you change this to fail/vine? should make tab completing nicer

@stevenhuyn
Copy link
Contributor Author

It's not very robust atm, so I'm thinking if there's a nice way to do it without pulling in a dependency like https://docs.rs/ignore/latest/ignore/

@tjjfvi
Copy link
Member

tjjfvi commented Oct 23, 2024

IMO it's fine for it to depend on the non-existence of other things in those directories

@stevenhuyn stevenhuyn marked this pull request as draft November 11, 2024 09:03
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.

test: should detect snapshots with no corresponding test
2 participants