insta icon indicating copy to clipboard operation
insta copied to clipboard

`--delete-unreferenced-snapshots` does not delete .snap files ignored by .gitignore/.ignore

Open aminya opened this issue 3 years ago • 5 comments

What happened?

I expected --delete-unreferenced-snapshots to delete all the snap files under the snapshots folder that are not used in the tests, but apparently, this has no effect.

Reproduction steps

  1. create a snap file under the snapshots folder
  2. run cargo insta test --delete-unreferenced-snapshots
  3. See the snap file not being removed

Insta Version

1.19.0

rustc Version

rustc 1.64.0-nightly (1b57946a4 2022-08-03)

What did you expect?

Removal of excess snap files

aminya avatar Aug 26 '22 03:08 aminya

Did the tests pass or did the process fail with an error? The deletion will only happen if all tests passed.

mitsuhiko avatar Aug 26 '22 09:08 mitsuhiko

The tests passed. I used insta test --review --delete-unreferenced-snapshots --accept-unseen command (more sensible defaults for me)

aminya avatar Aug 26 '22 10:08 aminya

I cannot reproduce this. The command works for me. Can you create a test case in a repo that shows the issue?

mitsuhiko avatar Aug 30 '22 07:08 mitsuhiko

Here you go. I think the trick is to add the snap files to the gitignore. That apparently breaks the flag.

https://github.com/aminya/insta-unreferenced-bug

aminya avatar Aug 30 '22 09:08 aminya

That makes sense. This is very much intentional to ignore files which are not tracked in version control. The assumption is that this does not happen in practice. I will change the description of the issue.

mitsuhiko avatar Aug 31 '22 07:08 mitsuhiko

I think this can be closed as completed now we have include_ignored?

max-sixty avatar Apr 10 '23 21:04 max-sixty