bacon icon indicating copy to clipboard operation
bacon copied to clipboard

`bacon test` with something like `insta` can endlessly trigger re-runs

Open CosmicHorrorDev opened this issue 2 years ago • 6 comments

insta will create a new snapshot file when a snapshot test fails that is used for the next run of cargo insta review. insta creating this file on failure does mean that bacon test can get stuck in a loop of:

  1. bacon test runs the test suite
  2. A snapshot test fails creating a new pending file for review
  3. The new file triggers a re-run (return to step 2.)

For possible solutions I was thinking either allowing for excluding files from the file watcher by glob, or allowing for a debouncing period. I'm personally leaning towards the former since having to deal with a debouncing period would be annoying for my workflow when dealing with projects that have longer compile/test times

I'd be willing to make a PR if you think that this would be a worthwhile addition

CosmicHorrorDev avatar Jun 12 '23 23:06 CosmicHorrorDev

If your project sources are controlled with git, you shouldn't have any problem: I don't know insta but the file it creates, being automatically generated from sources, should probably be ignored, and changes on gitignored files don't trigger bacon runs.

Are you using another source version control system than git ?

Canop avatar Jun 13 '23 05:06 Canop

No, but the snapshots should not be ignored. The snapshot files are the source of truth for snapshot tests. You can essentially think of their contents as the expected value in an assert_eq!()

CosmicHorrorDev avatar Jun 13 '23 05:06 CosmicHorrorDev

I guess I could setup git to ignore the pending snapshots, but I kind of rely on pending snapshots to show up in git status to notice that I forgot to review

I can't recall a project that uses insta and ignores pending snapshots, but I also don't make a habit of checking .gitignore files. It could be a workable solution I suppose

Edit: I'll go ahead and give it a try :)

I'll re-open if I end up running into any issues with the different workflow

CosmicHorrorDev avatar Jun 13 '23 05:06 CosmicHorrorDev

I wasn't asking you to close the issue, you can keep it open until everybody thinks it's OK. For once, git shouldn't be a requirement to use bacon.

Canop avatar Jun 13 '23 05:06 Canop

I occasionally get this as well, even though my pending snapshot files are under .gitignore for some reason.

GeeWee avatar Jun 20 '23 11:06 GeeWee

One approach that works well — we use it in PRQL — is to add .snap.new and .pending-snap to gitignore.

It comes with the downside of potentially being a bit less clear for new contributors who aren't used to insta, but it's worked fine on net.

max-sixty avatar Jul 01 '24 00:07 max-sixty