-
Notifications
You must be signed in to change notification settings - Fork 339
Ensure that expect_snapshot() registers restart
#2271
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,7 +131,12 @@ expect_snapshot_ <- function( | |
| if (error) { | ||
| fail(msg, trace = state$error[["trace"]]) | ||
| } else { | ||
| cnd_signal(state$error) | ||
| # This might be a failed expectation, so we need to make sure | ||
| # that we can muffle it | ||
| withRestarts( | ||
| cnd_signal(state$error), | ||
| muffle_expectation = function() NULL | ||
| ) | ||
| } | ||
|
Comment on lines
-134
to
140
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know very little about testthat internals, but is this supposed to be It feels like there should only be 1 place in testthat where you set up I'm not totally sure what
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree that there shouldn't be multiple places where we have to add this restart, but the condition handling in snapshots is complicated and I know I've got it wrong before, so I don't really want to touch that code. (I just looked back at the blame and it seems like literally every line of that if statement required a different PR to get right 😭). (But I'll take one more look)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I tried again, and it got me into an even weirder state. So I don't think it's worth 100% reasoning through again, and this should be the only place where we need it.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds fine |
||
| return() | ||
| } | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Maybe also add a warning message within
continue_testfor a smoother transition?Changing the news entry for testthat 2.3.0 (and not adding an entry for 3.3.0) feels odd.
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.
I think the news change was accidental. You're saying your package relied on the
continue_testrestart? I think my working assumption was that it was an internal implementation detail that no one new about 😞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.
Correct. Shinytest2 used it.
All good. Making a patch fix.