-
Notifications
You must be signed in to change notification settings - Fork 393
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
tests: run insta --force-update-snapshots
#5558
base: main
Are you sure you want to change the base?
tests: run insta --force-update-snapshots
#5558
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the allow_duplicates
issue, we can add a patch that inserts allow_duplicates!
block per snapshot.
@@ -1274,7 +1272,7 @@ mod tests { | |||
|
|||
insta::assert_snapshot!( | |||
str::from_utf8(recorder.data()).unwrap(), | |||
@" outer1 inner1 inner2 outer2 "); | |||
@" outer1 inner1 inner2 outer2"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It's not important that the trailing space is preserved here, but it looks a bit odd. We might have to add leading/trailing non-space character to the snapshot sample.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also file a bug to insta
. (Update: Thought I'm not 100% sure they would consider it a bug. See below for another possibility)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a better option is to change the test (in a separate commit, like with inserting allow_duplicates!
), so that we are in fact testing everything:
insta::assert_snapshot!(
format!("|{}|",str::from_utf8(recorder.data()).unwrap()),
@"| outer1 inner1 inner2 outer2 |")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. iirc, insta isn't strict about leading/trailing whitespaces, and I assume that's by design. I just pointed that out because this patch contained whitespace changes like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. iirc, insta isn't strict about leading/trailing whitespaces
What's weird is that it strips the whitespace at the end, but not at the start. I would have expected either both or neither.
@@ -702,7 +702,7 @@ mod tests { | |||
}; | |||
// First output is after the initial delay | |||
assert_snapshot!(update(crate::progress::INITIAL_DELAY - Duration::from_millis(1), 0.1), @""); | |||
assert_snapshot!(update(Duration::from_millis(1), 0.10), @"[?25l\r 10% [█▊ ][K"); | |||
assert_snapshot!(update(Duration::from_millis(1), 0.10), @"\u{1b}[?25l\r 10% [█▊ ]\u{1b}[K"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be changed by mitsuhiko/insta#715 ? If that's the case, it's probably better to merge this PR after new insta is released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also not very difficult to compile cargo-insta from source. I do it for mitsuhiko/insta#438.
cargo build -p cargo-insta --release && cp target/release/cargo-insta ~/.cargo/bin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be changed by mitsuhiko/insta#715?
Yes, this is with mitsuhiko/insta#716 merged.
The current logic is that if there are any bad control characters, then everything will be escaped.
So, because the string contains \r
, the \x1b
will be escaped as well.
One could imagine another solution where even if there are unrenderable control characters, only they are escaped, and \n
, \t
, \x1b
are kept as is, but that is not implemented in insta right now.
485fecf
to
cec83a7
Compare
Run
cargo insta test --test-runner nextest --force-update-snapshots
.There are a few additional changes that insta makes that break the tests, but only inside
allow_duplicates
, so that's related to mitsuhiko/insta#712and
If applicable:
CHANGELOG.md