-
Notifications
You must be signed in to change notification settings - Fork 333
Use restart in test_code()
#2153
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
base: main
Are you sure you want to change the base?
Conversation
@@ -175,7 +167,7 @@ test_code <- function(test, code, env, reporter, skip_on_empty = TRUE) { | |||
|
|||
debug_end <- if (inherits(e, "skip_empty")) -1 else 2 | |||
register_expectation(e, debug_end) | |||
signalCondition(e) | |||
invokeRestart("end_test") |
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.
This now seems like a clear bug — resignalling a condition inside a calling handler would have just duplicated the condition.
} | ||
handle_fatal <- function(e) { | ||
handled <<- TRUE | ||
# Error caught in handle_error() has precedence |
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.
No longer needed because we jump out of both the tryCatch + withCallingHandlers stack with a restart.
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.
hmm... According to the comment on line 123, register_expectation()
might fail, and one of the reasons the test_error
setup was done is so the original error, rather than the internal one, would be registered here.
But we call register_expectation()
again below (albeit with a different debug_end
) so I'm not sure why this really matters.
Perhaps just remove the comment on line 123?
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.
Looks like you can remove all mentions of test_error
which is now dangling.
} | ||
handle_fatal <- function(e) { | ||
handled <<- TRUE | ||
# Error caught in handle_error() has precedence |
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.
hmm... According to the comment on line 123, register_expectation()
might fail, and one of the reasons the test_error
setup was done is so the original error, rather than the internal one, would be registered here.
But we call register_expectation()
again below (albeit with a different debug_end
) so I'm not sure why this really matters.
Perhaps just remove the comment on line 123?
No description provided.