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

insta review fails with a hidden snapshot directory (starting with '.') #326

Closed
ngryman opened this issue Jan 3, 2023 · 4 comments · Fixed by #331
Closed

insta review fails with a hidden snapshot directory (starting with '.') #326

ngryman opened this issue Jan 3, 2023 · 4 comments · Fixed by #331
Labels
bug Something isn't working

Comments

@ngryman
Copy link

ngryman commented Jan 3, 2023

What happened?

Hi,

I'm using a custom directory for my snapshot located at the root of my project at $CARGO_MANIFEST_DIR/.snapshots. When running my tests, snapshots are generated correctly. However, cargo insta review fails to locate them.

Changing the directory to a non-hidden one; removing the . prefix; works fine.

Theory

After quickly scanning the source I think it may come from these lines:

.hidden(false)
.standard_filters(!no_ignore)

From the WalkDir documentation, it seems that the standard_filters re-enables the hidden option. So it might be the case that it's overriding the previous hidden(false) option in the context of reviewing snapshots.

As a side note, my .snapshots directory is not git ignored so my issue must come from the hidden option, and not the git_ignore one enabled by standard_filters.

Reproduction steps

  1. Set a hidden directory as the snapshot directory with with_settings!.
  2. Run your test.
  3. Check that snapshots are generated properly.
  4. Run cargo insta review.
  5. The following message appears: done: no snapshots to review.

Insta Version

No response

rustc Version

No response

What did you expect?

I expect cargo insta review to properly locate the snapshot directory.

@ngryman ngryman added the bug Something isn't working label Jan 3, 2023
@mitsuhiko
Copy link
Owner

mitsuhiko commented Jan 3, 2023

This is intentional behavior. You need to pass --no-ignore to cargo insta review. I will consider changing this however.

EDIT: It doesn't look like it was intentional to turn on hidden folders at all. The current logic skips it in the filter even when no_ignore is passed.

@mitsuhiko
Copy link
Owner

With the next version you will be able to pass --include-hidden to have insta walk into hidden folders.

@ngryman
Copy link
Author

ngryman commented Jan 3, 2023

@mitsuhiko Thanks for the quick reply & fix!

@ngryman
Copy link
Author

ngryman commented Jan 4, 2023

Hi @mitsuhiko,

I just updated to 1.24.0 and my issue is resolved but not as expected.

tl;dr --include-ignored works but --include-hidden has no effect.


I have the same use case as before, which is:

  1. I want my snapshot directories to be .snapshots.
  2. I don't ignore .snapshots in any of the files listed in WalkBuilder's standard filters.

Current behavior

1️⃣ When I run cargo-insta with --include-hidden, I get the following:

Screen Shot 2023-01-04 at 11 22 29 AM

2️⃣ When I run cargo-insta with --include-ignored, it works.

Expected behavior

In my use case, I would expect 1️⃣ to have the same behavior than 2️⃣.

The error message in 1️⃣ should not appear as it advises me to use the flag I did use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants