rust-analyzer / expect-test

Minimalistic snapshot testing for Rust.
Apache License 2.0
248 stars 22 forks source link

Option to not add indents when updating tests #10

Closed lunacookies closed 3 years ago

lunacookies commented 3 years ago

I would find this helpful because I don’t indent the test string literals, so when I update tests I have to go back and manually dedent them all.

matklad commented 3 years ago

Seems fine by me!

Not sure what's the best API though...

We can either go with a compile-time switch or a runtime env var.

lunacookies commented 3 years ago

How would the compile-time switch work? The only thing I can think of is a feature flag.

matklad commented 3 years ago

Yeah, a feature flag is what I had in mind.

Hm, as a third alternative, I originally intended to include assert_eq_exact method, which doesn't do any kind of auto-indent or newline transformation. But that would be slightly different aim as supporting different preferred styles of testing.

Do you have any thoughts about which approach would work better? New method, special env-var (UPDATE_EXPECT=no-indent), feature flag?

lunacookies commented 3 years ago

I think my preferred option is a feature flag, since an env var would likely lead to inconsistency from contributors and a new method would require changing existing code. Plus, how would the auto updating detect the usage of the other method?