insta icon indicating copy to clipboard operation
insta copied to clipboard

`INSTA_UPDATE=no` still writes new snapshots

Open max-sixty opened this issue 2 years ago • 2 comments

What happened?

Not a big deal personally, but was surprised by the behavior so I thought worth logging[^1].

INSTA_UPDATE=no still writes new files. The docs describe it as no: does not update snapshot files at all (just runs tests).

I would have thought it's similar to --check.

[^1]: Personally I almost always use --accept and use git as the diff...

Reproduction steps

Create a new snapshot test; test_upper2, and run

INSTA_UPDATE=no cargo insta test -- test_upper2

This will create a new .snap.new file.

Insta Version

cargo-insta 1.29.0

rustc Version

1.65

What did you expect?

Resetting and adding --check has the expected behavior — no new files are written:

INSTA_UPDATE=no cargo insta test --check -- test_upper2

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

I think that's because INSTA_UPDATE is overwritten by cargo insta test. This double use of envvars really needs to be cleaned up.

mitsuhiko avatar Apr 12 '23 16:04 mitsuhiko

@mitsuhiko I came around to looking at this. clap has a bunch of ways of handling overriding env vars, such as default_value_if. That would let us get this & associated issues in order without lots of manual logic.

I know you want to keep dependencies light, so may be keen to stay on structopt rather than moving to clap.

How would you balance this? Notably this is in cargo-insta only, so maybe has less dependency pressure?

max-sixty avatar Mar 06 '24 19:03 max-sixty